xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.21", "5cf32f166c493f41c0de7f3fd578d0be1b692c81c54f0c68889e62240fe9ab60")
  8. add_versions("v0.0.20", "417e5ecc40005d9c8008bad2b6a2034e109b2a0a1ebd108b231cb419cfbb980a")
  9. add_versions("v0.0.12", "f310a628d2657b9ed523a19284f58e4a407466f2e17efb2250d2e58524d02c53")
  10. add_patches("v0.0.20", path.join(os.scriptdir(), "patches", "0.0.20", "cmake.patch"), "50d70983aa498e63e02e66d71e3c7c78ed1c802c61063d1b085e8a12abbcf751")
  11. add_includedirs("include", "include/uvwasi")
  12. add_deps("cmake", "libuv")
  13. on_install("linux", "windows", "macosx", function (package)
  14. local configs = {"-DUVWASI_BUILD_TESTS=OFF"}
  15. if package:version():ge("0.0.20") then
  16. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  17. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  18. if package:is_plat("windows") and package:config("shared") then
  19. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  20. end
  21. import("package.tools.cmake").install(package, configs, {packagedeps = "libuv"})
  22. else
  23. table.insert(configs, "-DWITH_SYSTEM_LIBUV=ON")
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. if package:config("shared") then
  27. io.replace("CMakeLists.txt", "-fvisibility=hidden", "", {plain = true})
  28. end
  29. import("package.tools.cmake").install(package, configs, {packagedeps = "libuv"})
  30. os.cp("include", package:installdir())
  31. if package:config("shared") then
  32. os.trycp("build/*.dll", package:installdir("bin"))
  33. os.trycp("build/*.so", package:installdir("lib"))
  34. os.trycp("build/*.dylib", package:installdir("lib"))
  35. else
  36. os.trycp("build/*.a", package:installdir("lib"))
  37. os.trycp("build/*.lib", package:installdir("lib"))
  38. end
  39. end
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("uvwasi_init", {includes = "uvwasi.h"}))
  43. end)