From 9c67593434add149fe0d465624727ee74afdfa65 Mon Sep 17 00:00:00 2001 From: xpxz <97490782+heheda123123@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:46:35 +0800 Subject: [PATCH] add windows support to bdwgc (#4586) * Update xmake.lua * Update xmake.lua * fix widnows defines * add check for android --------- Co-authored-by: star9029 --- packages/b/bdwgc/xmake.lua | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/b/bdwgc/xmake.lua b/packages/b/bdwgc/xmake.lua index 0d150d93cc2..5589386af14 100644 --- a/packages/b/bdwgc/xmake.lua +++ b/packages/b/bdwgc/xmake.lua @@ -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)