xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("reckless")
  2. set_homepage("https://github.com/mattiasflodin/reckless")
  3. set_description("Reckless logging. Low-latency, high-throughput, asynchronous logging library for C++.")
  4. add_urls("https://github.com/mattiasflodin/reckless/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/mattiasflodin/reckless.git")
  6. add_versions("v3.0.3", "522656ded4aa72d2c465e48d43b9378c66108339fe3be4324ea0e601bf0537f9")
  7. add_deps("cmake")
  8. if is_plat("windows") then
  9. add_syslinks("synchronization")
  10. elseif is_plat("linux") then
  11. add_syslinks("pthread")
  12. end
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. on_install("linux|!arm*", "windows|!arm*", function (package)
  15. io.replace("CMakeLists.txt", "add_library(reckless STATIC ${SRC_LIST})", "add_library(reckless STATIC ${SRC_LIST}) \n install(TARGETS reckless DESTINATION lib) \n install(DIRECTORY reckless/include/ DESTINATION include)", {plain = true})
  16. local configs = {}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include <reckless/severity_log.hpp>
  23. #include <reckless/file_writer.hpp>
  24. using log_t = reckless::severity_log<
  25. reckless::indent<4>,
  26. ' ',
  27. reckless::severity_field,
  28. reckless::timestamp_field
  29. >;
  30. reckless::file_writer writer("log.txt");
  31. log_t g_log(&writer);
  32. void test()
  33. {
  34. std::string s("Hello World!");
  35. g_log.debug("Pointer: %p", s.c_str());
  36. g_log.info("Info line: %s", s);
  37. for(int i=0; i!=4; ++i) {
  38. reckless::scoped_indent indent;
  39. g_log.warn("Warning: %d", i);
  40. }
  41. g_log.error("Error: %f", 3.14);
  42. }
  43. ]]}, {configs = {languages = "cxx11"}}))
  44. end)