xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("criterion")
  2. set_homepage("https://github.com/Snaipe/Criterion")
  3. set_description("A cross-platform C and C++ unit testing framework for the 21st century")
  4. set_license("MIT")
  5. add_urls("https://github.com/Snaipe/Criterion/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/Snaipe/Criterion.git")
  7. add_versions("v2.4.2", "83e1a39c8c519fbef0d64057dc61c8100b3a5741595788c9f094bba2eeeef0df")
  8. add_configs("i18n", {description = "Enable i18n", default = false, type = "boolean"})
  9. if is_plat("windows", "mingw") then
  10. add_syslinks("ws2_32", "mswsock")
  11. elseif is_plat("linux", "bsd") then
  12. add_syslinks("m", "pthread", "rt")
  13. end
  14. add_deps("meson", "ninja")
  15. if is_subhost("windows") then
  16. add_deps("pkgconf", "wingetopt")
  17. else
  18. add_deps("pkg-config")
  19. end
  20. add_deps("debugbreak", "klib", "libffi", "nanopb", "nanomsg", "libgit2")
  21. on_load(function (package)
  22. if package:is_plat("bsd") and package:config("shared") then
  23. package:add("deps", "boxfort", {configs = {shared = true}})
  24. else
  25. package:add("deps", "boxfort")
  26. end
  27. end)
  28. on_install("windows|!arm*", "linux", "macosx", "cross", "mingw@windows,msys", "bsd", "msys", function (package)
  29. os.rm("subprojects")
  30. import("patch")(package)
  31. local opt = {}
  32. -- Gather protoc-gen-nanopb from python3 pip
  33. local python = package:is_plat("windows") and "python" or "python3"
  34. os.vrun(python .. " -m pip install protobuf==5.29.3 nanopb==0.4.9.1")
  35. if package:is_plat("bsd") then
  36. opt.cflags = {"-Wno-error=incompatible-function-pointer-types"}
  37. opt.packagedeps = {"llhttp", "openssl3", "pcre2"}
  38. elseif package:is_plat("windows", "mingw") then
  39. opt.packagedeps = {"wingetopt", "nanomsg", "pcre2", "libgit2"}
  40. if package:has_tool("cxx", "cl") then
  41. opt.cxflags = {"/utf-8"}
  42. end
  43. else
  44. opt.packagedeps = {"libgit2"}
  45. end
  46. local configs = {"-Dtests=false", "-Dsamples=false", "-Dc_std=c11"}
  47. table.insert(configs, "-Di18n=" .. (package:config("i18n") and "enabled" or "disabled"))
  48. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  49. import("package.tools.meson").install(package, configs, opt)
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cfuncs("criterion_handle_args", {includes = "criterion/criterion.h"}))
  53. end)