Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add windows support to bdwgc #4586

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions packages/b/bdwgc/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,36 @@ package("bdwgc")
set_homepage("https://www.hboehm.info/gc/")
set_description("The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)")

add_urls("https://github.com/ivmai/bdwgc/-/archive/$(version).tar.gz",
add_urls("https://github.com/ivmai/bdwgc/archive/refs/tags/$(version).tar.gz",
"https://github.com/ivmai/bdwgc.git")

add_versions("v8.2.6", "3bfc2b1dd385bfb46d2dab029211a66249a309795b6893f4e00554904999e40a")
add_versions("v8.2.4", "18e63ab1428bd52e691da107a6a56651c161210b11fbe22e2aa3c31f7fa00ca5")

add_deps("cmake")
add_deps("libatomic_ops")

on_install("macosx", "linux", "android", "iphoneos", function (package)
local configs = {}
if on_check then
on_check("android", function (package)
if package:is_arch("armeabi-v7a") then
local ndk = package:toolchain("ndk")
local ndk_sdkver = ndk:config("ndk_sdkver")
assert(ndk_sdkver and tonumber(ndk_sdkver) > 21, "package(bdwgc/armeabi-v7a): need ndk api level > 21")
end
end)
end

on_install("!wasm", function (package)
local configs = {"-Denable_docs=OFF", "-Dwith_libatomic_ops=ON"}
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
import("package.tools.cmake").install(package, configs)
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
import("package.tools.cmake").install(package, configs, {packagedeps = "libatomic_ops"})

if package:is_plat("windows", "mingw", "cygwin") then
package:add("defines", (package:config("shared") and "GC_DLL" or "GC_NOT_DLL"))
end
end)

on_test(function (package)
assert(package:has_cfuncs({test=[[
void test() {
GC_INIT();
int *ptr = GC_MALLOC(sizeof(int));
*ptr = 42;
printf("Value: %d\n", *ptr);
return 0;
}
]]}),{configs = {includes = "gc.h"}})
assert(package:has_cfuncs("GC_init", {includes = "gc/gc.h"}))
end)