Skip to content

Commit

Permalink
Add offsetAllocator package (#6150)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjtxietian authored Jan 13, 2025
1 parent f061dd3 commit 3c792d0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/o/offsetallocator/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package("offsetallocator")
set_homepage("https://github.com/sebbbi/OffsetAllocator")
set_description("Fast O(1) offset allocator with minimal fragmentation")
set_license("MIT")

add_urls("https://github.com/sebbbi/OffsetAllocator.git")
add_versions("2023.03.27", "3610a7377088b1e8c8f1525f458c96038a4e6fc0")

on_install(function (package)
if package:is_plat("windows") and package:config("shared") then
io.replace("offsetAllocator.hpp", "namespace OffsetAllocator", [[
#define LIBRARY_API __declspec(dllexport)
namespace OffsetAllocator
]], {plain = true})
io.replace("offsetAllocator.hpp", "struct Allocation", "struct LIBRARY_API Allocation", {plain = true})
io.replace("offsetAllocator.hpp", "struct Region", "struct LIBRARY_API Region", {plain = true})
io.replace("offsetAllocator.hpp", "struct StorageReport", "struct LIBRARY_API StorageReport", {plain = true})
io.replace("offsetAllocator.hpp", "class Allocator", "class LIBRARY_API Allocator", {plain = true})
io.replace("offsetAllocator.hpp", "struct Node", "struct LIBRARY_API Node", {plain = true})
end
io.writefile("xmake.lua", [[
add_rules("mode.release", "mode.debug")
target("OffsetAllocator")
set_kind("$(kind)")
set_languages("c++20")
add_files("offsetAllocator.cpp")
add_headerfiles("offsetAllocator.hpp")
]])
import("package.tools.xmake").install(package)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
using namespace OffsetAllocator;
Allocator allocator(12345);
Allocation a = allocator.allocate(1337);
uint32 offset_a = a.offset;
}
]]}, {configs = {languages = "c++20"}, includes = {"offsetAllocator.hpp"}}))
end)

0 comments on commit 3c792d0

Please sign in to comment.