xmake.lua 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.6", "afd3d3d8de29825de408e1227be72f3bef8a01c2c0180c46271b4da9bb4fa509")
  8. add_versions("2.4", "a240673f6dda17a8d4d5768b6741534e6863e6c4d786c3678e4fe687eb115902")
  9. add_versions("2.3", "a27dc3ff0d962cc6e0b4e60890b4904e664b0df16393d27e14c878d7de09b505")
  10. add_configs("ios", {description = "iOS version of library.", default = false, type = "boolean", readonly = true})
  11. 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"})
  12. add_configs("debug_to_dbug", {description = "Use DBUG logging level instead of DEBUG. By default DEBUG is the debugging level", default = false, type = "boolean"})
  13. add_configs("funcsig", {description = "Windows __FUNCSIG__ to expand `Function` location of the LOG call instead of the default __FUNCTION__", default = false, type = "boolean"})
  14. 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"})
  15. add_configs("dynamic_memory", {description = "Use dynamic memory for message buffer during log capturing", default = false, type = "boolean"})
  16. add_configs("full_filename", {description = "Log full filename", default = false, type = "boolean"})
  17. add_configs("fatal_signal_handling", {description = "Vectored exception / crash handling with improved stack trace", default = true, type = "boolean"})
  18. if is_plat("windows") then
  19. add_configs("vectored_exception_handling", {description = "Vectored exception / crash handling with improved stack trace", default = true, type = "boolean"})
  20. end
  21. if is_plat("linux") then
  22. add_syslinks("pthread")
  23. end
  24. add_deps("cmake")
  25. on_install("windows", "linux", "macosx", "iphoneos", function (package)
  26. local configs =
  27. {
  28. "-DADD_FATAL_EXAMPLE=OFF",
  29. "-DADD_G3LOG_PERFORMANCE=OFF",
  30. "-DADD_G3LOG_UNIT_TEST=OFF",
  31. "-DINSTALL_G3LOG =ON",
  32. }
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DG3_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  35. table.insert(configs, "-DG3_IOS_LIB=" .. (package:config("ios") and "ON" or "OFF"))
  36. table.insert(configs, "-DUSE_DYNAMIC_LOGGING_LEVELS=" .. (package:config("log_level") and "ON" or "OFF"))
  37. table.insert(configs, "-DCHANGE_G3LOG_DEBUG_TO_DBUG=" .. (package:config("debug_to_dbug") and "ON" or "OFF"))
  38. table.insert(configs, "-DWINDOWS_FUNCSIG=" .. (package:config("funcsig") and "ON" or "OFF"))
  39. table.insert(configs, "-DPRETTY_FUNCTION=" .. (package:config("pretty_function") and "ON" or "OFF"))
  40. table.insert(configs, "-DUSE_G3_DYNAMIC_MAX_MESSAGE_SIZE=" .. (package:config("dynamic_memory") and "ON" or "OFF"))
  41. table.insert(configs, "-DG3_LOG_FULL_FILENAME=" .. (package:config("full_filename") and "ON" or "OFF"))
  42. table.insert(configs, "-DENABLE_FATAL_SIGNALHANDLING=" .. (package:config("fatal_signal_handling") and "ON" or "OFF"))
  43. if package:is_plat("windows") then
  44. table.insert(configs, "-DG3_SHARED_RUNTIME=" .. (package:config("vs_runtime"):startswith("MD") and "ON" or "OFF"))
  45. table.insert(configs, "-DENABLE_VECTORED_EXCEPTIONHANDLING=" .. (package:config("vectored_exception_handling") and "ON" or "OFF"))
  46. table.insert(configs, "-DDEBUG_BREAK_AT_FATAL_SIGNAL=" .. (package:is_debug() and "ON" or "OFF"))
  47. end
  48. import("package.tools.cmake").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. assert(package:check_cxxsnippets({test = [[
  52. #include <g3log/g3log.hpp>
  53. void test() {
  54. LOGF(INFO, "Hi log %d", 123);
  55. LOG_IF(INFO, (1 < 2)) << "If true this message will be logged";
  56. }
  57. ]]}, {configs = {languages = "c++14"}}))
  58. end)