diff --git a/packages/i/injector/port/xmake.lua b/packages/i/injector/port/xmake.lua new file mode 100644 index 000000000..1f40f73fb --- /dev/null +++ b/packages/i/injector/port/xmake.lua @@ -0,0 +1,45 @@ +add_rules("mode.debug", "mode.release") + +if is_plat("mingw") then + add_syslinks("advapi32", "dbghelp", "psapi") +end + +target("injector") + set_kind("$(kind)") + set_languages("c") + + add_headerfiles("include/(*.h)") + add_includedirs("include", {public = true}) + + if is_arch("arm.*") then + add_defines("__arm__") + if is_arch("arm") then + add_defines("_M_ARMT") + elseif is_arch("arm64") then + add_defines("__arm64__", "__aarch64__", "_M_ARM64") + end + elseif is_arch("x86_64") then + add_defines("__x86_64__") + elseif is_arch("x86") then + add_defines("__i386__", "_M_IX86") + elseif is_arch("x64") then + add_defines("_M_AMD64") + end + + if is_plat("windows", "mingw") then + add_files("src/windows/*.c") + if is_plat("windows") then + add_defines("_WIN32") + end + elseif is_plat("macosx") then + add_headerfiles("src/macos/*.h") + add_files("src/macos/*.c") + elseif is_plat("linux") then + add_files("src/linux/*.c", "src/linux/*.S") + add_defines("__linux__") + end + on_config(function (target) + if target:has_tool("gcc", "gxx") then + target:add("defines", "__USE_GNU") + end + end) diff --git a/packages/i/injector/xmake.lua b/packages/i/injector/xmake.lua new file mode 100644 index 000000000..2aba0a82e --- /dev/null +++ b/packages/i/injector/xmake.lua @@ -0,0 +1,27 @@ +package("injector") + set_homepage("https://github.com/kubo/injector") + set_description("Library for injecting a shared library into a Linux or Windows process") + set_license("LGPL-2.1") + + add_urls("https://github.com/kubo/injector.git") + add_versions("2024.02.18", "c719b4f6b3bde75fd18d4d0c6b752a68dce593aa") + + if is_plat("mingw") then + add_syslinks("advapi32", "dbghelp", "psapi") + end + + on_install("windows", "linux", "macosx", "mingw", function (package) + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + local configs = {} + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + injector_t *injector; + injector_attach(&injector, 1234); + } + ]]})) + end)