From 9c62fbde4e18b4317fdcbb963c2d04812896464d Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Wed, 8 Jan 2025 12:18:39 +0800 Subject: [PATCH] Add offsetAllocator package --- packages/o/offsetallocator/xmake.lua | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 packages/o/offsetallocator/xmake.lua diff --git a/packages/o/offsetallocator/xmake.lua b/packages/o/offsetallocator/xmake.lua new file mode 100644 index 00000000000..3fd918f45d8 --- /dev/null +++ b/packages/o/offsetallocator/xmake.lua @@ -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)