xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("quickjs")
  2. set_homepage("https://bellard.org/quickjs/")
  3. set_description("QuickJS is a small and embeddable Javascript engine")
  4. if is_plat("windows") then
  5. add_urls("https://github.com/xmake-mirror/quickjs.git")
  6. add_versions("2021.03.27", "c83f82dce8988334be6c6a7b9b029eb963e7e310")
  7. else
  8. add_urls("https://github.com/bellard/quickjs.git")
  9. add_versions("2021.03.27", "b5e62895c619d4ffc75c9d822c8d85f1ece77e5b")
  10. add_versions("2023.12.09", "daa35bc1e5d43192098af9b51caeb4f18f73f9f9")
  11. add_versions("2024.01.13", "d6c7d169de6fb2c90cd2bd2226ba9dafdef883ce")
  12. end
  13. if is_plat("linux", "macosx", "iphoneos", "cross") then
  14. add_syslinks("pthread", "dl", "m")
  15. elseif is_plat("android") then
  16. add_syslinks("dl", "m")
  17. end
  18. on_install("linux", "macosx", "iphoneos", "android", "mingw", "cross", function (package)
  19. io.writefile("xmake.lua", ([[
  20. add_rules("mode.debug", "mode.release")
  21. target("quickjs")
  22. set_kind("$(kind)")
  23. add_files("quickjs*.c", "cutils.c", "lib*.c")
  24. add_headerfiles("quickjs-libc.h")
  25. add_headerfiles("quickjs.h")
  26. add_installfiles("*.js", {prefixdir = "share"})
  27. set_languages("c99")
  28. add_defines("CONFIG_VERSION=\"%s\"", "_GNU_SOURCE")
  29. add_defines("CONFIG_BIGNUM")
  30. if is_plat("windows", "mingw") then
  31. add_defines("__USE_MINGW_ANSI_STDIO")
  32. end
  33. ]]):format(package:version_str()))
  34. local configs = {}
  35. if package:config("shared") then
  36. configs.kind = "shared"
  37. end
  38. if package:is_plat("cross") then
  39. io.replace("quickjs.c", "#define CONFIG_PRINTF_RNDN", "")
  40. end
  41. import("package.tools.xmake").install(package, configs)
  42. end)
  43. on_install("windows|x86", "windows|x64", function (package)
  44. local configs = {}
  45. if package:config("shared") then
  46. configs.kind = "shared"
  47. end
  48. import("package.tools.xmake").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. assert(package:has_cfuncs("JS_NewRuntime", {includes = "quickjs.h"}))
  52. end)