xmake.lua 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package("wasm-micro-runtime")
  2. set_homepage("https://github.com/bytecodealliance/wasm-micro-runtime")
  3. set_description("WebAssembly Micro Runtime (WAMR)")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-$(version).tar.gz", {excludes = {"*/language-bindings/python/LICENSE"}})
  6. add_urls("https://github.com/bytecodealliance/wasm-micro-runtime.git")
  7. add_versions("1.3.2", "58961ba387ed66ace2dd903597f1670a42b8154a409757ae6f06f43fe867a98c")
  8. add_versions("1.2.3", "85057f788630dc1b8c371f5443cc192627175003a8ea63c491beaff29a338346")
  9. add_patches("1.3.2", path.join(os.scriptdir(), "patches", "1.3.2", "cmake.patch"), "cf0e992bdf3fe03f7dc03624fd757444291a5286b1ceef6532bbf3f9567f394b")
  10. add_patches("1.2.3", path.join(os.scriptdir(), "patches", "1.2.3", "cmake.patch"), "97d99509997b86d24a84cd1b2eca0d4dace7b460d5cb85bc23881d02e7ef08ed")
  11. add_patches("1.3.2", path.join(os.scriptdir(), "patches", "libc_uvwasi.patch"), "e83ff42588cc112588c7fde48a1bd9df7ffa8fa41f70dd99af5d6b0325ce46f7")
  12. add_patches("1.2.3", path.join(os.scriptdir(), "patches", "libc_uvwasi.patch"), "e83ff42588cc112588c7fde48a1bd9df7ffa8fa41f70dd99af5d6b0325ce46f7")
  13. add_configs("interp", {description = "Enable interpreter", default = true, type = "boolean"})
  14. add_configs("fast_interp", {description = "Enable fast interpreter", default = false, type = "boolean"})
  15. add_configs("aot", {description = "Enable AOT", default = false, type = "boolean"})
  16. -- TODO: improve llvm
  17. add_configs("jit", {description = "Enable JIT", default = false, type = "boolean", readonly = true})
  18. add_configs("fast_jit", {description = "Enable Fast JIT", default = false, type = "boolean", readonly = true})
  19. add_configs("libc", {description = "Choose libc", default = "builtin", type = "string", values = {"builtin", "wasi", "uvwasi"}})
  20. add_configs("libc_builtin", {description = "Enable builtin libc", default = false, type = "boolean"})
  21. add_configs("libc_wasi", {description = "Enable wasi libc", default = false, type = "boolean"})
  22. add_configs("libc_uvwasi", {description = "Enable uvwasi libc", default = false, type = "boolean"})
  23. add_configs("multi_module", {description = "Enable multiple modules", default = false, type = "boolean"})
  24. add_configs("mini_loader", {description = "Enable wasm mini loader", default = false, type = "boolean"})
  25. add_configs("wasi_threads", {description = "Enable wasi threads library", default = false, type = "boolean"})
  26. add_configs("simd", {description = "Enable SIMD", default = false, type = "boolean"})
  27. add_configs("ref_types", {description = "Enable reference types", default = false, type = "boolean"})
  28. if is_plat("windows", "mingw") then
  29. add_syslinks("ntdll", "ws2_32")
  30. elseif is_plat("linux", "bsd") then
  31. add_syslinks("m", "dl", "pthread")
  32. end
  33. add_deps("cmake")
  34. on_load(function (package)
  35. if package:is_plat("windows") and package:is_arch("x86") and winos.version():le("10.0.17763") then
  36. package:add("patches", "1.3.2", path.join(os.scriptdir(), "patches", "ntapi.patch"), "436c3f6bbb536a362e277d654ef8dc74e0d757dd815de2d89209bd2a9ac2f114")
  37. end
  38. if package:config("libc_uvwasi") or package:config("libc") == "uvwasi" then
  39. if package:is_plat("windows", "linux", "macosx") then
  40. package:add("deps", "uvwasi")
  41. else
  42. raise("xrepo(uvwasi) only support windows/linux/macosx")
  43. end
  44. end
  45. if package:config("jit", "fast_jit") then
  46. package:add("deps", "llvm")
  47. end
  48. end)
  49. on_install("windows", "linux", "macosx", "bsd", "android", function (package)
  50. local configs = {"-DWAMR_BUILD_INVOKE_NATIVE_GENERAL=1"}
  51. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  52. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  53. if package:is_plat("windows") and (not package:config("shared")) then
  54. package:add("defines", "COMPILING_WASM_RUNTIME_API=1")
  55. end
  56. table.insert(configs, "-DWAMR_BUILD_INTERP=" .. (package:config("interp") and "1" or "0"))
  57. table.insert(configs, "-DWAMR_BUILD_FAST_INTERP=" .. (package:config("fast_interp") and "1" or "0"))
  58. table.insert(configs, "-DWAMR_BUILD_AOT=" .. (package:config("aot") and "1" or "0"))
  59. table.insert(configs, "-DWAMR_BUILD_JIT=" .. (package:config("jit") and "1" or "0"))
  60. table.insert(configs, "-DWAMR_BUILD_FAST_JIT=" .. (package:config("fast_jit") and "1" or "0"))
  61. table.insert(configs, "-DWAMR_BUILD_LIBC_BUILTIN=" .. ((package:config("libc_builtin") or package:config("libc") == "builtin" ) and "1" or "0"))
  62. table.insert(configs, "-DWAMR_BUILD_LIBC_WASI=" .. ((package:config("libc_wasi") or package:config("libc") == "wasi" ) and "1" or "0"))
  63. table.insert(configs, "-DWAMR_BUILD_LIBC_UVWASI=" .. ((package:config("libc_uvwasi") or package:config("libc") == "uvwasi" ) and "1" or "0"))
  64. table.insert(configs, "-DWAMR_BUILD_MULTI_MODULE=" .. (package:config("multi_module") and "1" or "0"))
  65. table.insert(configs, "-DWAMR_BUILD_MINI_LOADER=" .. (package:config("mini_loader") and "1" or "0"))
  66. table.insert(configs, "-DWAMR_BUILD_LIB_WASI_THREADS=" .. (package:config("wasi_threads") and "1" or "0"))
  67. table.insert(configs, "-DWAMR_BUILD_SIMD=" .. (package:config("simd") and "1" or "0"))
  68. table.insert(configs, "-DWAMR_BUILD_REF_TYPES=" .. (package:config("ref_types") and "1" or "0"))
  69. local packagedeps
  70. if package:config("libc_uvwasi") or package:config("libc") == "uvwasi" then
  71. if package:is_plat("windows", "linux", "macosx") then
  72. packagedeps = {"uvwasi", "libuv"}
  73. end
  74. end
  75. if package:is_plat("android") then
  76. table.insert(configs, "-DWAMR_BUILD_PLATFORM=android")
  77. end
  78. import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
  79. end)
  80. on_test(function (package)
  81. assert(package:has_cfuncs("wasm_engine_new", {includes = "wasm_c_api.h"}))
  82. end)