xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.7.1" , "fc75b1824aba7a954ef0886371d951c3bf4b6e0a921d1aefc553f309702d6ed1")
  8. add_deps("autoconf", "automake", "libtool")
  9. add_configs("oniguruma", {description = "Build with oniguruma", default = true, type = "boolean"})
  10. add_configs("all_static", {description = "Link jq with static libraries only", default = false, type = "boolean"})
  11. if not is_host("windows") then
  12. add_extsources("pkgconfig::libjq")
  13. end
  14. if is_plat("mingw") and is_subhost("msys") then
  15. add_extsources("pacman::jq")
  16. elseif is_plat("linux") then
  17. add_extsources("apt::libjq-dev")
  18. elseif is_plat("macosx") then
  19. add_extsources("brew::jq")
  20. end
  21. if is_plat("linux", "bsd") then
  22. add_syslinks("m", "pthread")
  23. elseif is_plat("windows", "mingw") then
  24. add_syslinks("shlwapi")
  25. end
  26. on_check(function (package)
  27. assert(not (package:is_plat("android") and is_subhost("windows")), "package(libjq): does not support windows@android.")
  28. assert(not (package:is_plat("mingw") and is_subhost("msys")), "package(libjq): does not support mingw@msys.")
  29. end)
  30. on_load(function (package)
  31. if package:config("oniguruma") then
  32. package:add("deps", "oniguruma")
  33. end
  34. end)
  35. on_install("!windows and !wasm", function (package)
  36. if not package:is_cross() then
  37. package:addenv("PATH", "bin")
  38. end
  39. local configs = {"--enable-docs=no"}
  40. if package:config("shared") then
  41. table.insert(configs, "--enable-shared")
  42. table.insert(configs, "--disable-static")
  43. else
  44. table.insert(configs, "--enable-static")
  45. table.insert(configs, "--disable-shared")
  46. end
  47. if package:debug() then
  48. table.insert(configs, "--enable-debug")
  49. else
  50. table.insert(configs, "--disable-debug")
  51. end
  52. if package:config("all_static") then
  53. table.insert(configs, "--enable-all-static")
  54. end
  55. local opt = {}
  56. if package:config("oniguruma") then
  57. opt.packagedeps = "oniguruma"
  58. end
  59. table.insert(configs, "--with-oniguruma=" .. (package:config("oniguruma") and "yes" or "no"))
  60. import("package.tools.autoconf").install(package, configs, opt)
  61. end)
  62. on_test(function (package)
  63. if not package:is_cross() then
  64. os.vrun("jq --version")
  65. end
  66. assert(package:has_cfuncs("jq_init" , {includes = "jq.h"}))
  67. end)