xmake.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package("diligenttools")
  2. set_homepage("https://github.com/DiligentGraphics/DiligentTools")
  3. set_description("Utilities built on top of core module")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/DiligentGraphics/DiligentTools/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/DiligentGraphics/DiligentTools.git", {submodules = false})
  7. add_versions("v2.5.6", "6f2a99c15491396463cebe4f7fd1087db677b1531906ddf1864ad43346d3c2fc")
  8. add_patches("v2.5.6", "patches/v2.5.6/assetloader-include-diligentcore.diff", "a7259d5b9f2e34e1c0632d10a350bc78888dd000b8a28ac478b8e70835aedffc")
  9. add_patches("v2.5.6", "patches/v2.5.6/debundle-cmakelists.diff", "43476c90d5448ff5b87115c7a054c378bf130ad759f18dd297fa16307350aa22")
  10. add_patches("v2.5.6", "patches/v2.5.6/debundle-thirdparty-cmakelist.diff", "570158e31b0953568cf9b91e559bce5b062e4eb1aae5a0289a8d61af6d38be74")
  11. add_patches("v2.5.6", "patches/v2.5.6/fix-top-cmakelist.diff", "8e50585f7f6cf49c883819f62a45dfaadbe16bbe162c63761e111aba64c2c70a")
  12. add_patches("v2.5.6", "patches/v2.5.6/imgui-include-diligentcore.diff", "aa388d93decc6cb6ebbbd8ea72f476eb13e4a0871a8a16a14f0285f4ef4b5f97")
  13. add_patches("v2.5.6", "patches/v2.5.6/imguizmo-modified-include-diligentcore.diff", "6075c2b985b8657571ce70c3231960e5e2c1f39b7f163d2bf5e1762b359e54ec")
  14. add_patches("v2.5.6", "patches/v2.5.6/nativeapp-include-diligentcore.diff", "1e3f89542b2588f4be42b2c7a56f79f1cf0b0f149ea8bb8b6d52cd3c11c49e69")
  15. add_patches("v2.5.6", "patches/v2.5.6/renderstatenotation-include-diligentcore.diff", "7095306c24ff1de9a2ae274cd0b4631a341d4c212a48345a4ba6aca7fe7f34a0")
  16. add_patches("v2.5.6", "patches/v2.5.6/renderstatepackager-include-diligentcore.diff", "52dedf7f529649ecd837791f8d9758678685699eba82020517e0ede687c0601d")
  17. add_patches("v2.5.6", "patches/v2.5.6/textureloader-include-diligentcore.diff", "0613d5dfb5d5ce33a1fc97cb81d8c9a0eca1341639698a0a449c88aa3407b07c")
  18. add_resources("v2.5.6", "DiligentCore_source", "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/v2.5.6.tar.gz", "abc190c05ee7e5ef2bba52fcbc5fdfe2256cce3435efba9cfe263a386653f671")
  19. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  20. add_configs("rsp", {description = "Enable Render State Packager", default = true, type = "boolean"})
  21. add_configs("rapidjson", {description = "Enable rapidjson", default = true, type = "boolean"})
  22. add_configs("draco", {description = "Enable draco", default = true, type = "boolean"})
  23. add_includedirs("include", "include/DiligentTools")
  24. add_deps("cmake", "pkgconf")
  25. add_deps("python 3.x", {kind = "binary"})
  26. add_deps("diligentcore", "libpng", "libtiff", "zlib", "libjpeg", "taywee_args", "nlohmann_json", "stb", "tinygltf")
  27. if is_plat("windows") then
  28. add_deps("imgui", {configs = {win32 = true}})
  29. elseif is_plat("linux") then
  30. add_deps("imgui 1.89", "libxcb", "libx11", "libxrandr", "libxrender", "libxinerama", "libxfixes", "libxcursor", "libxi", "libxext", "wayland")
  31. elseif is_plat("macosx") then
  32. add_deps("imgui 1.85", {configs = {osx = true}})
  33. end
  34. if is_plat("windows") then
  35. add_syslinks("comdlg32")
  36. elseif is_plat("macosx") then
  37. add_frameworks("Cocoa")
  38. end
  39. on_load(function (package)
  40. local diligentcore = package:dep("diligentcore")
  41. if diligentcore then
  42. if not diligentcore:is_system() then
  43. local diligentcore_fetchinfo = diligentcore:fetch()
  44. for _, define in ipairs(diligentcore_fetchinfo.defines) do
  45. package:add("defines", define)
  46. end
  47. end
  48. end
  49. if package:config("rapidjson") then
  50. package:add("deps", "rapidjson")
  51. end
  52. if package:config("draco") then
  53. package:add("deps", "draco")
  54. end
  55. end)
  56. on_install("windows", "linux", "macosx", function (package)
  57. local resourcedir = package:resourcedir("DiligentCore_source")
  58. if resourcedir then
  59. os.cp(
  60. path.join(resourcedir, "DiligentCore-2.5.6", "BuildTools", "CMake", "BuildUtils.cmake"),
  61. "BuildUtils.cmake"
  62. )
  63. end
  64. local configs = {"-DDILIGENT_INSTALL_TOOLS=ON"}
  65. local diligentcore = package:dep("diligentcore")
  66. if diligentcore then
  67. if not diligentcore:is_system() then
  68. local diligentcore_fetchinfo = diligentcore:fetch()
  69. for _, define in ipairs(diligentcore_fetchinfo.defines) do
  70. if define:find("PLATFORM") or define:find("_SUPPORTED") then
  71. table.insert(configs, "-D" .. define .. "=ON")
  72. end
  73. end
  74. end
  75. end
  76. table.insert(configs, "-DDILIGENT_NO_RENDER_STATE_PACKAGER=" .. (package:config("rsp") and "OFF" or "ON"))
  77. table.insert(configs, "-DDILIGENT_USE_RAPIDJSON=" .. (package:config("rapidjson") and "ON" or "OFF"))
  78. table.insert(configs, "-DDILIGENT_ENABLE_DRACO=" .. (package:config("draco") and "ON" or "OFF"))
  79. local packagedeps = {}
  80. if package:config("draco") then
  81. table.insert(packagedeps, "draco")
  82. end
  83. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  84. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  85. import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
  86. end)
  87. on_test(function (package)
  88. assert(package:check_cxxsnippets({test = [[
  89. #include <DiligentTools/AssetLoader/interface/GLTFLoader.hpp>
  90. void test() {
  91. Diligent::GLTF::Material material;
  92. auto count = material.GetNumActiveTextureAttribs();
  93. }
  94. ]]}, {configs = {languages = "c++17"}}))
  95. assert(package:check_cxxsnippets({test = [[
  96. #include <DiligentTools/Imgui/interface/ImGuiImplDiligent.hpp>
  97. void test() {
  98. Diligent::ImGuiDiligentCreateInfo info;
  99. Diligent::ImGuiImplDiligent impl(info);
  100. impl.InvalidateDeviceObjects();
  101. }
  102. ]]}, {configs = {languages = "c++17"}}))
  103. assert(package:check_cxxsnippets({test = [[
  104. #include <DiligentTools/RenderStateNotation/interface/RenderStateNotationLoader.h>
  105. void test() {
  106. Diligent::LoadPipelineStateInfo LoadInfo;
  107. Diligent::GraphicsPipelineStateCreateInfo PipelineCI{};
  108. LoadInfo.ModifyPipeline(PipelineCI, LoadInfo.pModifyPipelineData);
  109. }
  110. ]]}, {configs = {languages = "c++17"}}))
  111. assert(package:check_cxxsnippets({test = [[
  112. #include <DiligentTools/TextureLoader/interface/TextureUtilities.h>
  113. void test() {
  114. Diligent::PremultiplyAlphaAttribs Attribs;
  115. Diligent::PremultiplyAlpha(Attribs);
  116. }
  117. ]]}, {configs = {languages = "c++17"}}))
  118. end)