xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("argus")
  2. set_homepage("https://argus-lib.com")
  3. set_description("Argus is a cross-platform modern feature-rich command-line argument parser for C")
  4. set_license("MIT")
  5. add_urls("https://github.com/lucocozz/Argus/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/lucocozz/Argus.git")
  7. add_versions("v0.1.0", "0e7780db65a06f72268a60336d8621ea17f704ec12c6d679c0ae86048ec6e8fc")
  8. add_configs("regex", {description = "Enable regex validation support using PCRE2", default = false, type = "boolean"})
  9. if is_plat("wasm") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. add_deps("meson", "ninja")
  13. on_load(function (package)
  14. if package:config("regex") then
  15. package:add("deps", "pcre2")
  16. end
  17. end)
  18. on_install(function (package)
  19. if package:is_plat("mingw") then
  20. io.replace("includes/argus/internal/compiler.h", "#define ARGUS_API __declspec(dllimport) __cdecl", "#define ARGUS_API", {plain = true})
  21. elseif package:is_plat("windows") then
  22. io.replace("includes/argus/internal/compiler.h", "#define ARGUS_API __declspec(dllimport)", "#define ARGUS_API", {plain = true})
  23. end
  24. io.replace("meson.build", "werror=true", "werror=false", {plain = true})
  25. io.replace("meson.build", "both_libraries", "library", {plain = true})
  26. local configs = {"-Dregex=" .. (package:config("regex") and "true" or "false")}
  27. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  28. import("package.tools.meson").install(package, configs)
  29. end)
  30. on_test(function (package)
  31. assert(package:has_cfuncs("argus_init", {includes = "argus.h"}))
  32. end)