xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. end
  11. if is_plat("linux", "macosx", "iphoneos", "cross") then
  12. add_syslinks("pthread", "dl", "m")
  13. elseif is_plat("android") then
  14. add_syslinks("dl", "m")
  15. end
  16. on_install("linux", "macosx", "iphoneos", "android", "mingw", "cross", function (package)
  17. io.writefile("xmake.lua", ([[
  18. add_rules("mode.debug", "mode.release")
  19. target("quickjs")
  20. set_kind("$(kind)")
  21. add_files("quickjs*.c", "cutils.c", "lib*.c")
  22. add_headerfiles("quickjs-libc.h")
  23. add_headerfiles("quickjs.h")
  24. add_installfiles("*.js", {prefixdir = "share"})
  25. set_languages("c99")
  26. add_defines("CONFIG_VERSION=\"%s\"", "_GNU_SOURCE")
  27. add_defines("CONFIG_BIGNUM")
  28. if is_plat("windows", "mingw") then
  29. add_defines("__USE_MINGW_ANSI_STDIO")
  30. end
  31. ]]):format(package:version_str()))
  32. local configs = {}
  33. if package:config("shared") then
  34. configs.kind = "shared"
  35. end
  36. if package:is_plat("cross") then
  37. io.replace("quickjs.c", "#define CONFIG_PRINTF_RNDN", "")
  38. end
  39. import("package.tools.xmake").install(package, configs)
  40. end)
  41. on_install("windows", function (package)
  42. local configs = {}
  43. if package:config("shared") then
  44. configs.kind = "shared"
  45. end
  46. import("package.tools.xmake").install(package, configs)
  47. end)
  48. on_test(function (package)
  49. assert(package:has_cfuncs("JS_NewRuntime", {includes = "quickjs.h"}))
  50. end)