From 3c9f92705b6913c3b6f55a39f45ff4fd1f2cd7bc Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 21 Sep 2025 21:17:47 +0800 Subject: [PATCH 1/5] libdispatch: add package --- packages/l/libdispatch/xmake.lua | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/l/libdispatch/xmake.lua diff --git a/packages/l/libdispatch/xmake.lua b/packages/l/libdispatch/xmake.lua new file mode 100644 index 00000000000..fe4c2e0759d --- /dev/null +++ b/packages/l/libdispatch/xmake.lua @@ -0,0 +1,34 @@ +package("libdispatch") + set_homepage("swift.org") + set_description("The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware") + set_license("Apache-2.0") + + add_urls("https://github.com/swiftlang/swift-corelibs-libdispatch/archive/refs/tags/$(version).tar.gz") + add_urls("https://github.com/swiftlang/swift-corelibs-libdispatch.git", {alias = "git"}) + + add_versions("6.1.1", "6fc6f8b1767a1348e1d960647b2bfbc52fd7074b7aeab97bd0f4b21af58baa47") + + add_versions("git:6.1.1", "swift-6.1.1-RELEASE") + + add_links("dispatch", "BlocksRuntime") + + if is_plat("windows") then + add_syslinks("shlwapi", "ws2_32", "winmm", "synchronization") + elseif is_plat("linux", "bsd") then + add_syslinks("pthread", "rt") + end + + add_deps("cmake") + + on_install(function (package) + io.replace("cmake/modules/DispatchCompilerWarnings.cmake", "-Werror", "", {plain = true}) + + local configs = {} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:has_cfuncs("dispatch_get_main_queue", {includes = "dispatch/dispatch.h"})) + end) From 2642ab1fdcbe2db8daf750b47b24c8d733c55da5 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 21 Sep 2025 21:21:29 +0800 Subject: [PATCH 2/5] fix url --- packages/l/libdispatch/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/l/libdispatch/xmake.lua b/packages/l/libdispatch/xmake.lua index fe4c2e0759d..fdbdaa85ab2 100644 --- a/packages/l/libdispatch/xmake.lua +++ b/packages/l/libdispatch/xmake.lua @@ -3,7 +3,7 @@ package("libdispatch") set_description("The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware") set_license("Apache-2.0") - add_urls("https://github.com/swiftlang/swift-corelibs-libdispatch/archive/refs/tags/$(version).tar.gz") + add_urls("https://github.com/swiftlang/swift-corelibs-libdispatch/archive/refs/tags/swift-$(version)-RELEASE.tar.gz") add_urls("https://github.com/swiftlang/swift-corelibs-libdispatch.git", {alias = "git"}) add_versions("6.1.1", "6fc6f8b1767a1348e1d960647b2bfbc52fd7074b7aeab97bd0f4b21af58baa47") From defbcab196b9f6d4d7fd53cb53973e79d0129db7 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 21 Sep 2025 23:02:25 +0800 Subject: [PATCH 3/5] add check --- packages/l/libdispatch/xmake.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/l/libdispatch/xmake.lua b/packages/l/libdispatch/xmake.lua index fdbdaa85ab2..96c353063fd 100644 --- a/packages/l/libdispatch/xmake.lua +++ b/packages/l/libdispatch/xmake.lua @@ -12,18 +12,31 @@ package("libdispatch") add_links("dispatch", "BlocksRuntime") - if is_plat("windows") then + if is_plat("windows", "mingw") then add_syslinks("shlwapi", "ws2_32", "winmm", "synchronization") elseif is_plat("linux", "bsd") then add_syslinks("pthread", "rt") end add_deps("cmake") + + on_check(function (package) + if package:is_plat("windows") then + if not package:has_tool("cxx", "clang_cl") then + raise("package(libdispatch) unsupported msvc && clang toolchain, you can use clang-cl toolchain\nadd_requires(\"libdispatch\", {configs = {toolchains = \"clang-cl\"}}))") + end + else + if not package:has_tool("cxx", "clang", "clangxx") then + raise("package(libdispatch) unsupported gcc toolchain, you can use clang toolchain\nadd_requires(\"libdispatch\", {configs = {toolchains = \"clang\"}}))") + end + end + end) on_install(function (package) + io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE YES)", "", {plain = true}) io.replace("cmake/modules/DispatchCompilerWarnings.cmake", "-Werror", "", {plain = true}) - local configs = {} + local configs = {"-DBUILD_TESTING=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) import("package.tools.cmake").install(package, configs) From b082b3b9b8610318e0acfbd99559b1b010bc53a7 Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 22 Sep 2025 00:19:35 +0800 Subject: [PATCH 4/5] fix macos --- packages/l/libdispatch/xmake.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/l/libdispatch/xmake.lua b/packages/l/libdispatch/xmake.lua index 96c353063fd..d6ef1b64e0f 100644 --- a/packages/l/libdispatch/xmake.lua +++ b/packages/l/libdispatch/xmake.lua @@ -30,11 +30,26 @@ package("libdispatch") raise("package(libdispatch) unsupported gcc toolchain, you can use clang toolchain\nadd_requires(\"libdispatch\", {configs = {toolchains = \"clang\"}}))") end end + + if package:is_plat("android") then + local ndk = package:toolchain("ndk"):config("ndkver") + assert(ndk and tonumber(ndk) > 22, "package(libdispatch) require ndk version > 22") + end end) - on_install(function (package) + on_install("!bsd and !iphoneos", function (package) + if not package:config("shared") then + package:add("defines", "dispatch_STATIC") + if not package:is_plat("macosx") then + package:add("defines", "BlocksRuntime_STATIC") + end + end + io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE YES)", "", {plain = true}) io.replace("cmake/modules/DispatchCompilerWarnings.cmake", "-Werror", "", {plain = true}) + if not package:is_plat("macosx") then + io.replace("src/CMakeLists.txt", "BlocksRuntime::BlocksRuntime", "", {plain = true}) + end local configs = {"-DBUILD_TESTING=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) From bfbd43cee6e5e7dc99357128e4f96f0b78b2ac48 Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 22 Sep 2025 00:20:43 +0800 Subject: [PATCH 5/5] fix: correct macOS platform check in libdispatch installation script --- packages/l/libdispatch/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/l/libdispatch/xmake.lua b/packages/l/libdispatch/xmake.lua index d6ef1b64e0f..698f462c58e 100644 --- a/packages/l/libdispatch/xmake.lua +++ b/packages/l/libdispatch/xmake.lua @@ -47,7 +47,7 @@ package("libdispatch") io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE YES)", "", {plain = true}) io.replace("cmake/modules/DispatchCompilerWarnings.cmake", "-Werror", "", {plain = true}) - if not package:is_plat("macosx") then + if package:is_plat("macosx") then io.replace("src/CMakeLists.txt", "BlocksRuntime::BlocksRuntime", "", {plain = true}) end