xmake.lua 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("g3log")
  2. set_homepage("http://github.com/KjellKod/g3log")
  3. set_description("G3log is an asynchronous, \"crash safe\", logger that is easy to use with default logging sinks or you can add your own. G3log is made with plain C++14 (C++11 support up to release 1.3.2) with no external libraries (except gtest used for unit tests). G3log is made to be cross-platform, currently running on OSX, Windows and several Linux distros. See Readme below for details of usage.")
  4. set_license("Unlicense")
  5. add_urls("https://github.com/KjellKod/g3log/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/KjellKod/g3log.git")
  7. add_versions("2.4", "a240673f6dda17a8d4d5768b6741534e6863e6c4d786c3678e4fe687eb115902")
  8. add_versions("2.3", "a27dc3ff0d962cc6e0b4e60890b4904e664b0df16393d27e14c878d7de09b505")
  9. add_configs("ios", {description = "iOS version of library.", default = false, type = "boolean", readonly = true})
  10. add_configs("log_level", {description = "Turn ON/OFF log levels. An disabled level will not push logs of that level to the sink. By default dynamic logging is disabled", default = false, type = "boolean"})
  11. add_configs("debug_to_dbug", {description = "Use DBUG logging level instead of DEBUG. By default DEBUG is the debugging level", default = false, type = "boolean"})
  12. add_configs("funcsig", {description = "Windows __FUNCSIG__ to expand `Function` location of the LOG call instead of the default __FUNCTION__", default = false, type = "boolean"})
  13. add_configs("pretty_function", {description = "Windows __PRETTY_FUNCTION__ to expand `Function` location of the LOG call instead of the default __FUNCTION__", default = false, type = "boolean"})
  14. add_configs("dynamic_memory", {description = "Use dynamic memory for message buffer during log capturing", default = false, type = "boolean"})
  15. add_configs("full_filename", {description = "Log full filename", default = false, type = "boolean"})
  16. add_configs("fatal_signal_handling", {description = "Vectored exception / crash handling with improved stack trace", default = true, type = "boolean"})
  17. if is_plat("windows") then
  18. add_configs("vectored_exception_handling", {description = "Vectored exception / crash handling with improved stack trace", default = true, type = "boolean"})
  19. end
  20. if is_plat("linux") then
  21. add_syslinks("pthread")
  22. end
  23. add_deps("cmake")
  24. on_install("windows", "linux", "macosx", "iphoneos", function (package)
  25. local configs =
  26. {
  27. "-DADD_FATAL_EXAMPLE=OFF",
  28. "-DADD_G3LOG_PERFORMANCE=OFF",
  29. "-DADD_G3LOG_UNIT_TEST=OFF",
  30. "-DINSTALL_G3LOG =ON",
  31. }
  32. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  33. table.insert(configs, "-DG3_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  34. table.insert(configs, "-DG3_IOS_LIB=" .. (package:config("ios") and "ON" or "OFF"))
  35. table.insert(configs, "-DUSE_DYNAMIC_LOGGING_LEVELS=" .. (package:config("log_level") and "ON" or "OFF"))
  36. table.insert(configs, "-DCHANGE_G3LOG_DEBUG_TO_DBUG=" .. (package:config("debug_to_dbug") and "ON" or "OFF"))
  37. table.insert(configs, "-DWINDOWS_FUNCSIG=" .. (package:config("funcsig") and "ON" or "OFF"))
  38. table.insert(configs, "-DPRETTY_FUNCTION=" .. (package:config("pretty_function") and "ON" or "OFF"))
  39. table.insert(configs, "-DUSE_G3_DYNAMIC_MAX_MESSAGE_SIZE=" .. (package:config("dynamic_memory") and "ON" or "OFF"))
  40. table.insert(configs, "-DG3_LOG_FULL_FILENAME=" .. (package:config("full_filename") and "ON" or "OFF"))
  41. table.insert(configs, "-DENABLE_FATAL_SIGNALHANDLING=" .. (package:config("fatal_signal_handling") and "ON" or "OFF"))
  42. if package:is_plat("windows") then
  43. table.insert(configs, "-DG3_SHARED_RUNTIME=" .. (package:config("vs_runtime"):startswith("MD") and "ON" or "OFF"))
  44. table.insert(configs, "-DENABLE_VECTORED_EXCEPTIONHANDLING=" .. (package:config("vectored_exception_handling") and "ON" or "OFF"))
  45. table.insert(configs, "-DDEBUG_BREAK_AT_FATAL_SIGNAL=" .. (package:is_debug() and "ON" or "OFF"))
  46. end
  47. import("package.tools.cmake").install(package, configs)
  48. end)
  49. on_test(function (package)
  50. assert(package:check_cxxsnippets({test = [[
  51. #include <g3log/g3log.hpp>
  52. void test() {
  53. LOGF(INFO, "Hi log %d", 123);
  54. LOG_IF(INFO, (1 < 2)) << "If true this message will be logged";
  55. }
  56. ]]}, {configs = {languages = "c++14"}}))
  57. end)