xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("offsetallocator")
  2. set_homepage("https://github.com/sebbbi/OffsetAllocator")
  3. set_description("Fast O(1) offset allocator with minimal fragmentation")
  4. set_license("MIT")
  5. add_urls("https://github.com/sebbbi/OffsetAllocator.git")
  6. add_versions("2023.03.27", "3610a7377088b1e8c8f1525f458c96038a4e6fc0")
  7. on_install(function (package)
  8. if package:is_plat("windows") and package:config("shared") then
  9. io.replace("offsetAllocator.hpp", "namespace OffsetAllocator", [[
  10. #define LIBRARY_API __declspec(dllexport)
  11. namespace OffsetAllocator
  12. ]], {plain = true})
  13. io.replace("offsetAllocator.hpp", "struct Allocation", "struct LIBRARY_API Allocation", {plain = true})
  14. io.replace("offsetAllocator.hpp", "struct Region", "struct LIBRARY_API Region", {plain = true})
  15. io.replace("offsetAllocator.hpp", "struct StorageReport", "struct LIBRARY_API StorageReport", {plain = true})
  16. io.replace("offsetAllocator.hpp", "class Allocator", "class LIBRARY_API Allocator", {plain = true})
  17. io.replace("offsetAllocator.hpp", "struct Node", "struct LIBRARY_API Node", {plain = true})
  18. end
  19. io.writefile("xmake.lua", [[
  20. add_rules("mode.release", "mode.debug")
  21. target("OffsetAllocator")
  22. set_kind("$(kind)")
  23. set_languages("c++20")
  24. add_files("offsetAllocator.cpp")
  25. add_headerfiles("offsetAllocator.hpp")
  26. ]])
  27. import("package.tools.xmake").install(package)
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. void test() {
  32. using namespace OffsetAllocator;
  33. Allocator allocator(12345);
  34. Allocation a = allocator.allocate(1337);
  35. uint32 offset_a = a.offset;
  36. }
  37. ]]}, {configs = {languages = "c++20"}, includes = {"offsetAllocator.hpp"}}))
  38. end)