xmake.lua 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package("quill")
  2. set_homepage("https://github.com/odygrd/quill")
  3. set_description("Asynchronous Low Latency C++ Logging Library")
  4. set_license("MIT")
  5. set_urls("https://github.com/odygrd/quill/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/odygrd/quill.git")
  7. add_versions("v4.3.0", "c97bf3bfac6dfb7ed77fa08d945a490e302ba07e405539fda61985b39750cb29")
  8. add_versions("v3.8.0", "d3e1b349c5d6904c9644e5b79ec65f21692e8094a3d75241a7fe071076eef4dd")
  9. add_versions("v3.6.0", "ba9dc3df262f2e65c57904580cc8407eba9a462001340c17bab7ae1dccddb4bd")
  10. add_versions("v3.3.1", "f929d54a115b45c32dd2acd1a9810336d35c31fde9f5581c51ad2b80f980d0d1")
  11. add_versions("v2.9.0", "dec64c0fbb4bfbafe28fdeeeefac10206285bf2be4a42ec5dfb7987ca4ccb372")
  12. add_versions("v2.9.1", "921e053118136f63cebb2ca1d7e42456fd0bf9626facb755884709092753c054")
  13. add_versions("v2.8.0", "0461a6c314e3d882f3b9ada487ef1bf558925272509ee41a9fd25f7776db6075")
  14. if is_plat("macosx") then
  15. add_extsources("brew::quill")
  16. end
  17. add_configs("fmt_external", {description = "Use external fmt library instead of bundled.(deprecated after v4)", default = false, type = "boolean"})
  18. add_configs("noexcept", {description = "Build without exceptions with -fno-exceptions flag", default = false, type = "boolean"})
  19. if is_plat("mingw") then
  20. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  21. end
  22. add_deps("cmake")
  23. if is_plat("linux") then
  24. add_syslinks("pthread")
  25. end
  26. on_load(function (package)
  27. if package:version() and package:version():ge("4.0.0") then
  28. package:set("kind", "library", {headeronly = true})
  29. else
  30. if package:config("fmt_external") then
  31. package:add("deps", "fmt")
  32. package:add("defines", "QUILL_FMT_EXTERNAL")
  33. end
  34. end
  35. end)
  36. on_install("windows", "linux", "macosx", "mingw", function (package)
  37. local configs = {"-DQUILL_ENABLE_INSTALL=ON"}
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DQUILL_NO_EXCEPTIONS=" .. (package:config("noexcept") and "ON" or "OFF"))
  40. if package:version() and package:version():lt("4.0.0") then
  41. if package:config("shared") and package:is_plat("windows") then
  42. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  43. end
  44. if package:config("fmt_external") then
  45. table.insert(configs, "-DQUILL_FMT_EXTERNAL=ON")
  46. end
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  48. end
  49. import("package.tools.cmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. local code = [[
  53. #include <quill/Quill.h>
  54. void test() {
  55. quill::Config cfg;
  56. cfg.enable_console_colours = true;
  57. quill::configure(cfg);
  58. quill::start();
  59. quill::Logger* logger = quill::get_logger();
  60. logger->set_log_level(quill::LogLevel::TraceL3);
  61. logger->init_backtrace(2, quill::LogLevel::Critical);
  62. }
  63. ]]
  64. if package:version() and package:version():ge("4.0.0") then
  65. code = [[
  66. #include "quill/Backend.h"
  67. #include "quill/Frontend.h"
  68. #include "quill/LogMacros.h"
  69. #include "quill/Logger.h"
  70. #include "quill/sinks/ConsoleSink.h"
  71. void test()
  72. {
  73. quill::Backend::start();
  74. auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>("sink_id_1");
  75. quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink));
  76. LOG_INFO(logger, "This is a log info example {}", 123);
  77. }
  78. ]]
  79. end
  80. assert(package:check_cxxsnippets({test = code}, {configs = {languages = "c++17"}}))
  81. end)