xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("nsync")
  2. set_homepage("https://github.com/google/nsync")
  3. set_description("nsync is a C library that exports various synchronization primitives, such as mutexes")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/google/nsync/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/nsync.git")
  7. add_versions("1.30.0", "883a0b3f8ffc1950670425df3453c127c1a3f6ed997719ca1bbe7f474235b6cc")
  8. add_versions("1.29.2", "1d63e967973733d2c97e841e3c05fac4d3fa299f01d14c86f2695594c7a4a2ec")
  9. add_versions("1.29.1", "3045a8922171430426b695edf794053182d245f6a382ddcc59ef4a6190848e98")
  10. add_versions("1.28.1", "0011fc00820088793b6a9ba97536173a25cffd3df2dc62616fb3a2824b3c43f5")
  11. add_patches(">=1.30.0", "patches/1.30.0/cmake.patch", "9cb6c772cefe05af0024e8a0a6931531f000ddea3e54ad258a3b95cc04aa1e0c")
  12. add_patches(">=1.28.1<1.30.0", "patches/1.28.1/cmake.patch", "626a89a5a60884b7aaf44011494e7ba5dbfcdae9fcdb5afcef5b5d1f893b4600")
  13. if is_plat("wasm") then
  14. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  15. end
  16. if is_plat("linux", "bsd") then
  17. add_syslinks("m", "pthread")
  18. end
  19. add_deps("cmake")
  20. on_install(function (package)
  21. if package:is_plat("iphoneos") then
  22. io.replace("CMakeLists.txt", [[elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "DarwinX")]], "elseif(1)", {plain = true})
  23. end
  24. local configs = {"-DNSYNC_ENABLE_TESTS=OFF"}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. if package:config("shared") and package:is_plat("windows") then
  28. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  29. end
  30. import("package.tools.cmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:has_cfuncs("nsync_mu_init", {includes = "nsync.h"}))
  34. assert(package:check_cxxsnippets({test = [[
  35. void test() {
  36. nsync::nsync_mu testing_mu;
  37. nsync::nsync_mu_init (&testing_mu);
  38. }
  39. ]]}, {configs = {languages = "c++11"}, includes = "nsync.h"}))
  40. end)