xmake.lua 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package("tracy")
  2. set_homepage("https://github.com/wolfpld/tracy")
  3. set_description("C++ frame profiler")
  4. add_urls("https://github.com/wolfpld/tracy/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/wolfpld/tracy.git")
  6. add_versions("v0.11.0", "b591ef2820c5575ccbf17e2e7a1dc1f6b9a2708f65bfd00f4ebefad2a1ccf830")
  7. add_versions("v0.10", "a76017d928f3f2727540fb950edd3b736caa97b12dbb4e5edce66542cbea6600")
  8. add_versions("v0.9.1", "c2de9f35ab2a516a9689ff18f5b62a55b73b93b66514bd09ba013d7957993cd7")
  9. add_versions("v0.9", "93a91544e3d88f3bc4c405bad3dbc916ba951cdaadd5fcec1139af6fa56e6bfc")
  10. add_versions("v0.8.2", "4784eddd89c17a5fa030d408392992b3da3c503c872800e9d3746d985cfcc92a")
  11. add_configs("on_demand", { default = false, type = "boolean", description = "On-demand profiling"})
  12. add_configs("enforce_callstack", { default = false, type = "boolean", description = "Enforce callstack collection for tracy regions"})
  13. add_configs("callstack", { default = true, type = "boolean", description = "Enable all callstack related functionality"})
  14. add_configs("callstack_inlines", { default = true, type = "boolean", description = "Enables the inline functions in callstacks"})
  15. add_configs("only_localhost", { default = false, type = "boolean", description = "Only listen on the localhost interface"})
  16. add_configs("broadcast", { default = true, type = "boolean", description = "Enable client discovery by broadcast to local network"})
  17. add_configs("only_ipv4", { default = false, type = "boolean", description = "Tracy will only accept connections on IPv4 addresses (disable IPv6)"})
  18. add_configs("code_transfer", { default = true, type = "boolean", description = "Enable collection of source code"})
  19. add_configs("context_switch", { default = true, type = "boolean", description = "Enable capture of context switches"})
  20. add_configs("exit", { default = true, type = "boolean", description = "Enable executable does not exit until all profile data is sent to server"})
  21. add_configs("sampling", { default = true, type = "boolean", description = "Enable call stack sampling"})
  22. add_configs("verify", { default = true, type = "boolean", description = "Enable zone validation for C API"})
  23. add_configs("vsync_capture", { default = true, type = "boolean", description = "Enable capture of hardware Vsync events"})
  24. add_configs("frame_image", { default = true, type = "boolean", description = "Enable the frame image support and its thread"})
  25. add_configs("system_tracing", { default = true, type = "boolean", description = "Enable systrace sampling"})
  26. add_configs("patchable_nopsleds", { default = false, type = "boolean", description = "Enable nopsleds for efficient patching by system-level tools (e.g. rr)"})
  27. add_configs("delayed_init", { default = false, type = "boolean", description = "Enable delayed initialization of the library (init on first call)"})
  28. add_configs("manual_lifetime", { default = false, type = "boolean", description = "Enable the manual lifetime management of the profile"})
  29. add_configs("fibers", { default = false, type = "boolean", description = "Enable fibers support"})
  30. add_configs("crash_handler", { default = true, type = "boolean", description = "Enable crash handling"})
  31. add_configs("timer_fallback", { default = false, type = "boolean", description = "Use lower resolution timers"})
  32. add_configs("libunwind_backtrace", { default = false, type = "boolean", description = "Use libunwind backtracing where supported"})
  33. add_configs("symbol_offline_resolve", { default = false, type = "boolean", description = "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution"})
  34. add_configs("libbacktrace_elf_dynload_support", { default = false, type = "boolean", description = "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation"})
  35. add_deps("cmake")
  36. on_install("windows|x64", "macosx", "linux|x86_64", function (package)
  37. local configs = {}
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  40. table.insert(configs, "-DTRACY_ON_DEMAND=" .. (package:config("on_demand") and "ON" or "OFF"))
  41. table.insert(configs, "-DTRACY_CALLSTACK=" .. (package:config("enforce_callstack") and "ON" or "OFF"))
  42. table.insert(configs, "-DTRACY_NO_CALLSTACK=" .. (package:config("callstack") and "OFF" or "ON"))
  43. table.insert(configs, "-DTRACY_NO_CALLSTACK_INLINES=" .. (package:config("callstack_inlines") and "OFF" or "ON"))
  44. table.insert(configs, "-DTRACY_ONLY_LOCALHOST=" .. (package:config("only_localhost") and "ON" or "OFF"))
  45. table.insert(configs, "-DTRACY_NO_BROADCAST=" .. (package:config("broadcast") and "OFF" or "ON"))
  46. table.insert(configs, "-DTRACY_ONLY_IPV4=" .. (package:config("only_ipv4") and "ON" or "OFF"))
  47. table.insert(configs, "-DTRACY_NO_CODE_TRANSFER=" .. (package:config("code_transfer") and "OFF" or "ON"))
  48. table.insert(configs, "-DTRACY_NO_CONTEXT_SWITCH=" .. (package:config("context_switch") and "OFF" or "ON"))
  49. table.insert(configs, "-DTRACY_NO_EXIT=" .. (package:config("exit") and "OFF" or "ON"))
  50. table.insert(configs, "-DTRACY_NO_SAMPLING=" .. (package:config("sampling") and "OFF" or "ON"))
  51. table.insert(configs, "-DTRACY_NO_VERIFY=" .. (package:config("verify") and "OFF" or "ON"))
  52. table.insert(configs, "-DTRACY_NO_VSYNC_CAPTURE=" .. (package:config("vsync_capture") and "OFF" or "ON"))
  53. table.insert(configs, "-DTRACY_NO_FRAME_IMAGE=" .. (package:config("frame_image") and "OFF" or "ON"))
  54. table.insert(configs, "-DTRACY_NO_SYSTEM_TRACING=" .. (package:config("system_tracing") and "OFF" or "ON"))
  55. table.insert(configs, "-DTRACY_PATCHABLE_NOPSLEDS=" .. (package:config("patchable_nopsleds") and "ON" or "OFF"))
  56. table.insert(configs, "-DTRACY_DELAYED_INIT=" .. (package:config("delayed_init") and "ON" or "OFF"))
  57. table.insert(configs, "-DTRACY_MANUAL_LIFETIME=" .. (package:config("manual_lifetime") and "ON" or "OFF"))
  58. table.insert(configs, "-DTRACY_FIBERS=" .. (package:config("fibers") and "ON" or "OFF"))
  59. table.insert(configs, "-DTRACY_NO_CRASH_HANDLER=" .. (package:config("crash_handler") and "OFF" or "ON"))
  60. table.insert(configs, "-DTRACY_TIMER_FALLBACK=" .. (package:config("timer_fallback") and "ON" or "OFF"))
  61. table.insert(configs, "-DTRACY_LIBUNWIND_BACKTRACE=" .. (package:config("libunwind_backtrace") and "ON" or "OFF"))
  62. table.insert(configs, "-DTRACY_SYMBOL_OFFLINE_RESOLVE=" .. (package:config("symbol_offline_resolve") and "ON" or "OFF"))
  63. table.insert(configs, "-DTRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT=" .. (package:config("libbacktrace_elf_dynload_support") and "ON" or "OFF"))
  64. -- collect tracy defines from cmake configs
  65. for _, config in ipairs(configs) do
  66. local define, value = config:match("-D(TRACY_%S+)=(.*)")
  67. if define and value and value == "ON" then
  68. package:add("defines", define)
  69. end
  70. end
  71. import("package.tools.cmake").install(package, configs)
  72. end)
  73. on_test(function (package)
  74. assert(package:check_cxxsnippets({test = [[
  75. static void test() {
  76. FrameMarkStart("Test start");
  77. FrameMarkEnd("Test end");
  78. }
  79. ]]}, {configs = {languages = "c++17"}, includes = {"tracy/Tracy.hpp"}}))
  80. end)