xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("optick")
  2. set_homepage("https://optick.dev")
  3. set_description("C++ Profiler For Games (API)")
  4. add_urls("https://github.com/bombomby/optick/archive/refs/tags/$(version).0.tar.gz")
  5. add_versions("1.3.1", "3670f44219f4d99a6d630c8364c6757d26d7226b0cfd007ee589186397362cc9")
  6. add_configs("vulkan", {description = "Built-in support for Vulkan", default = false, type = "boolean"})
  7. add_configs("d3d12", {description = "Built-in support for DirectX 12", default = false, type = "boolean"})
  8. if is_plat("windows") then
  9. add_syslinks("Advapi32")
  10. end
  11. add_deps("cmake")
  12. on_install("windows", "linux", "android", function (package)
  13. local configs = {}
  14. table.insert(configs, "-DOPTICK_INSTALL_TARGETS=OFF")
  15. table.insert(configs, "-DOPTICK_BUILD_GUI_APP=OFF")
  16. table.insert(configs, "-DOPTICK_BUILD_CONSOLE_SAMPLE=OFF")
  17. table.insert(configs, "-DOPTICK_USE_VULKAN=" .. (package:config("vulkan") and "ON" or "OFF"))
  18. table.insert(configs, "-DOPTICK_USE_D3D12=" .. (package:config("d3d12") and "ON" or "OFF"))
  19. if not package:config("shared") then
  20. io.replace("CMakeLists.txt", "SHARED", "STATIC")
  21. end
  22. import("package.tools.cmake").install(package, configs, {buildir = "build"})
  23. os.trycp("build/libOptickCore." .. (package:config("shared") and "so" or "a"), path.join(package:installdir(), "lib"))
  24. os.trycp("build/OptickCore." .. (package:config("shared") and "dll" or "lib"), path.join(package:installdir(), "lib"))
  25. os.rm("src/*.cpp")
  26. os.cp("src", path.join(package:installdir(), "include"), {rootdir = "src"})
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test=[[
  30. void test(int args, char* argv[]) {
  31. float v = 6.0f;
  32. for (int i = 0;i < 5; i++) {
  33. OPTICK_FRAME("MainThread");
  34. v *= v * v + (float)i;
  35. }
  36. }
  37. ]]}, {includes = "optick.h"}))
  38. end)