xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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", {submodules = false})
  7. add_versions("v0.6.1", "276edbb30896cdf2eee12a8bdb5b9c1cc2734eac8c898de6d52268ae201e614d")
  8. add_versions("v0.5.0", "41212a6fb84bfe07d61772c02513734b7a06465843ba8f76f1ce1e5df866f489")
  9. add_configs("libc", {description = "Build standard library modules as part of the library", default = false, type = "boolean"})
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("m", "pthread")
  12. end
  13. add_deps("cmake")
  14. if on_check then
  15. on_check("windows", function (package)
  16. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  17. if vs_toolset then
  18. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  19. local minor = vs_toolset_ver:minor()
  20. assert(minor and minor >= 30, "package(quickjs-ng) require vs_toolset >= 14.3")
  21. end
  22. end)
  23. end
  24. on_install("!iphoneos and (!windows or windows|!x86)", function (package)
  25. io.replace("CMakeLists.txt", "xcheck_add_c_compiler_flag(-Werror)", "", {plain = true})
  26. io.replace("CMakeLists.txt", "if(NOT WIN32 AND NOT EMSCRIPTEN)", "if(0)", {plain = true})
  27. local configs = {}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. table.insert(configs, "-DCONFIG_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  31. table.insert(configs, "-DCONFIG_MSAN=" .. (package:config("msan") and "ON" or "OFF"))
  32. table.insert(configs, "-DCONFIG_UBSAN=" .. (package:config("ubsan") and "ON" or "OFF"))
  33. table.insert(configs, "-DBUILD_QJS_LIBC=" .. (package:config("libc") and "ON" or "OFF"))
  34. if package:config("shared") and package:is_plat("windows") then
  35. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  36. end
  37. import("package.tools.cmake").install(package, configs)
  38. end)
  39. on_test(function (package)
  40. assert(package:has_cfuncs("JS_NewRuntime", {includes = "quickjs.h"}))
  41. end)