xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package("gperftools")
  2. set_homepage("https://github.com/gperftools/gperftools")
  3. set_description("gperftools is a collection of a high-performance multi-threaded malloc() implementation, plus some pretty nifty performance analysis tools.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/gperftools/gperftools/archive/refs/tags/gperftools-$(version).tar.gz")
  6. add_versions("2.10", "b0dcfe3aca1a8355955f4b415ede43530e3bb91953b6ffdd75c45891070fe0f1")
  7. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = is_plat("windows")})
  8. if is_plat("linux") then
  9. add_configs("unwind", {description = "Enable libunwind support.", default = false, type = "boolean"})
  10. end
  11. add_deps("cmake")
  12. on_load("linux", function (package)
  13. if package:config("unwind") then
  14. package:add("deps", "libunwind")
  15. end
  16. end)
  17. on_install("windows", "macosx", "linux", function (package)
  18. local configs = {"-DBUILD_TESTING=OFF", "-Dgperftools_build_benchmark=OFF"}
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DGPERFTOOLS_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  21. if package:is_plat("linux") then
  22. table.insert(configs, "-Dgperftools_enable_libunwind=" .. (package:config("unwind") and "ON" or "OFF"))
  23. end
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:has_cfuncs("tc_version", {includes = "gperftools/tcmalloc.h"}))
  28. end)