xmake.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package("libjq")
  2. set_homepage("https://jqlang.org")
  3. set_description("Command-line JSON processor")
  4. set_license("MIT")
  5. add_urls("https://github.com/jqlang/jq/archive/refs/tags/jq-$(version).tar.gz",
  6. "https://github.com/jqlang/jq.git")
  7. add_versions("1.8.0" , "6f4137cfb1744e9729d177707c3880957ec3fab621db921fcb4c04e62ed9e636")
  8. add_versions("1.7.1" , "fc75b1824aba7a954ef0886371d951c3bf4b6e0a921d1aefc553f309702d6ed1")
  9. add_deps("autoconf", "automake", "libtool")
  10. add_configs("oniguruma", {description = "Build with oniguruma", default = true, type = "boolean"})
  11. add_configs("all_static", {description = "Link jq with static libraries only", default = false, type = "boolean"})
  12. if not is_host("windows") then
  13. add_extsources("pkgconfig::libjq")
  14. end
  15. if is_plat("mingw") and is_subhost("msys") then
  16. add_extsources("pacman::jq")
  17. elseif is_plat("linux") then
  18. add_extsources("apt::libjq-dev")
  19. elseif is_plat("macosx") then
  20. add_extsources("brew::jq")
  21. end
  22. if is_plat("linux", "bsd") then
  23. add_syslinks("m", "pthread")
  24. elseif is_plat("windows", "mingw") then
  25. add_syslinks("shlwapi")
  26. end
  27. on_check(function (package)
  28. assert(not (package:is_plat("android") and is_subhost("windows")), "package(libjq): does not support windows@android.")
  29. assert(not (package:is_plat("mingw") and is_subhost("msys")), "package(libjq): does not support mingw@msys.")
  30. end)
  31. on_load(function (package)
  32. if package:config("oniguruma") then
  33. package:add("deps", "oniguruma")
  34. end
  35. end)
  36. on_install("!windows and !wasm", function (package)
  37. if not package:is_cross() then
  38. package:addenv("PATH", "bin")
  39. end
  40. local configs = {"--enable-docs=no"}
  41. if package:config("shared") then
  42. table.insert(configs, "--enable-shared")
  43. table.insert(configs, "--disable-static")
  44. else
  45. table.insert(configs, "--enable-static")
  46. table.insert(configs, "--disable-shared")
  47. end
  48. if package:debug() then
  49. table.insert(configs, "--enable-debug")
  50. else
  51. table.insert(configs, "--disable-debug")
  52. end
  53. if package:config("all_static") then
  54. table.insert(configs, "--enable-all-static")
  55. end
  56. local opt = {}
  57. if package:config("oniguruma") then
  58. opt.packagedeps = "oniguruma"
  59. end
  60. table.insert(configs, "--with-oniguruma=" .. (package:config("oniguruma") and "yes" or "no"))
  61. import("package.tools.autoconf").install(package, configs, opt)
  62. end)
  63. on_test(function (package)
  64. if not package:is_cross() then
  65. os.vrun("jq --version")
  66. end
  67. assert(package:has_cfuncs("jq_init" , {includes = "jq.h"}))
  68. end)