xmake.lua 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("uvwasi")
  2. set_homepage("https://github.com/nodejs/uvwasi")
  3. set_description("WASI syscall API built atop libuv")
  4. set_license("MIT")
  5. add_urls("https://github.com/nodejs/uvwasi/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/nodejs/uvwasi.git")
  7. add_versions("v0.0.23", "cdb148aac298883b51da887657deca910c7c02f35435e24f125cef536fe8d5e1")
  8. add_versions("v0.0.21", "5cf32f166c493f41c0de7f3fd578d0be1b692c81c54f0c68889e62240fe9ab60")
  9. add_versions("v0.0.20", "417e5ecc40005d9c8008bad2b6a2034e109b2a0a1ebd108b231cb419cfbb980a")
  10. add_versions("v0.0.12", "f310a628d2657b9ed523a19284f58e4a407466f2e17efb2250d2e58524d02c53")
  11. add_patches("v0.0.23", path.join(os.scriptdir(), "patches", "0.0.23", "cmake.patch"), "7c572636693a9ade904ca746a3f365299d312d794fe7b4438b7cfb8dbedc7698")
  12. add_patches("v0.0.20", path.join(os.scriptdir(), "patches", "0.0.20", "cmake.patch"), "50d70983aa498e63e02e66d71e3c7c78ed1c802c61063d1b085e8a12abbcf751")
  13. add_includedirs("include", "include/uvwasi")
  14. add_deps("cmake", "libuv")
  15. on_install("linux", "windows", "macosx", function (package)
  16. local test_config = package:version():ge("0.0.22") and "-DBUILD_TESTING=OFF" or "-DUVWASI_BUILD_TESTS=OFF"
  17. local configs = {test_config}
  18. if package:version():ge("0.0.20") then
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. if package:is_plat("windows") and package:config("shared") then
  22. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  23. end
  24. import("package.tools.cmake").install(package, configs, {packagedeps = "libuv"})
  25. else
  26. table.insert(configs, "-DWITH_SYSTEM_LIBUV=ON")
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. if package:config("shared") then
  30. io.replace("CMakeLists.txt", "-fvisibility=hidden", "", {plain = true})
  31. end
  32. import("package.tools.cmake").build(package, configs, {packagedeps = "libuv"})
  33. os.cp("include", package:installdir())
  34. local dir = package.builddir and package:builddir() or package:buildir()
  35. if package:config("shared") then
  36. os.trycp(path.join(dir, "**.dll"), package:installdir("bin"))
  37. os.trycp(path.join(dir, "*.lib"), package:installdir("lib"))
  38. os.trycp(path.join(dir, "*.so"), package:installdir("lib"))
  39. os.trycp(path.join(dir, "*.dylib"), package:installdir("lib"))
  40. else
  41. os.trycp(path.join(dir, "*.a"), package:installdir("lib"))
  42. os.trycp(path.join(dir, "*.lib"), package:installdir("lib"))
  43. end
  44. if package:is_plat("windows") then
  45. package:add("linkdirs", "lib")
  46. package:add("links", "uvwasi_a")
  47. end
  48. end
  49. end)
  50. on_test(function (package)
  51. assert(package:check_csnippets({test = [[
  52. void test() {
  53. uvwasi_t uvwasi;
  54. uvwasi_options_t options = {0};
  55. uvwasi_init(&uvwasi, &options);
  56. }
  57. ]]}, {includes = "uvwasi.h"}))
  58. end)