xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("quickjs-ng")
  2. set_homepage("https://github.com/quickjs-ng/quickjs")
  3. set_description("QuickJS, the Next Generation: a mighty JavaScript engine")
  4. set_license("MIT")
  5. add_urls("https://github.com/quickjs-ng/quickjs/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/quickjs-ng/quickjs.git")
  7. add_versions("v0.5.0", "41212a6fb84bfe07d61772c02513734b7a06465843ba8f76f1ce1e5df866f489")
  8. add_configs("libc", {description = "Build standard library modules as part of the library", default = false, type = "boolean"})
  9. if is_plat("linux", "bsd") then
  10. add_syslinks("m", "pthread")
  11. end
  12. add_deps("cmake")
  13. if on_check then
  14. on_check("windows", function (package)
  15. local msvc = package:toolchain("msvc")
  16. if msvc then
  17. local vs = msvc:config("vs")
  18. assert(vs and tonumber(vs) >= 2022, "package(quickjs-ng): need vs >= 2022")
  19. end
  20. end)
  21. end
  22. on_install("!iphoneos and (!windows or windows|!x86)", function (package)
  23. local configs = {}
  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. table.insert(configs, "-DCONFIG_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  27. table.insert(configs, "-DCONFIG_MSAN=" .. (package:config("msan") and "ON" or "OFF"))
  28. table.insert(configs, "-DCONFIG_UBSAN=" .. (package:config("ubsan") and "ON" or "OFF"))
  29. table.insert(configs, "-DBUILD_QJS_LIBC=" .. (package:config("libc") and "ON" or "OFF"))
  30. if package:config("shared") and package:is_plat("windows") then
  31. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  32. end
  33. import("package.tools.cmake").install(package, configs)
  34. end)
  35. on_test(function (package)
  36. assert(package:has_cfuncs("JS_NewRuntime", {includes = "quickjs.h"}))
  37. end)