xmake.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package("spirv-tools")
  2. set_homepage("https://github.com/KhronosGroup/SPIRV-Tools/")
  3. set_description("SPIR-V Tools")
  4. set_license("Apache-2.0")
  5. -- when adding a new sdk version, please ensure vulkan-headers, vulkan-hpp, vulkan-loader, vulkan-tools, vulkan-validationlayers, vulkan-utility-libraries, spirv-headers, spirv-reflect, spirv-tools, glslang and volk packages are updated simultaneously
  6. add_urls("https://github.com/KhronosGroup/SPIRV-Tools.git")
  7. add_versions("1.2.154+1", "sdk-1.2.154.1")
  8. add_versions("1.2.162+0", "sdk-1.2.162.0")
  9. add_versions("1.2.189+1", "sdk-1.2.189.1")
  10. add_versions("1.3.211+0", "sdk-1.3.211.0")
  11. add_versions("1.3.231+1", "sdk-1.3.231.1")
  12. add_versions("1.3.236+0", "sdk-1.3.236.0")
  13. add_versions("1.3.239+0", "sdk-1.3.239.0")
  14. add_versions("1.3.246+1", "sdk-1.3.246.1")
  15. add_versions("1.3.250+1", "sdk-1.3.250.1")
  16. add_versions("1.3.261+1", "sdk-1.3.261.1")
  17. add_versions("1.3.268+0", "vulkan-sdk-1.3.268.0")
  18. add_versions("1.3.275+0", "vulkan-sdk-1.3.275.0")
  19. add_versions("1.3.280+0", "vulkan-sdk-1.3.280.0")
  20. add_versions("1.3.283+0", "vulkan-sdk-1.3.283.0")
  21. add_versions("1.3.290+0", "vulkan-sdk-1.3.290.0")
  22. add_versions("1.4.309+0", "vulkan-sdk-1.4.309.0")
  23. add_versions("1.4.335+0", "vulkan-sdk-1.4.335.0")
  24. add_deps("cmake >=3.17.2")
  25. add_deps("python 3.x", {kind = "binary"})
  26. if is_plat("linux") then
  27. add_extsources("apt::spirv-tools", "pacman::spirv-tools")
  28. end
  29. on_load(function (package)
  30. local sdkver = package:version():split("%+")[1]
  31. package:add("deps", "spirv-headers " .. sdkver)
  32. end)
  33. on_fetch("macosx", function (package, opt)
  34. if opt.system then
  35. -- fix missing includedirs when the system library is found on macOS
  36. local result = package:find_package("spirv-tools")
  37. if result and not result.includedirs then
  38. for _, linkdir in ipairs(result.linkdirs) do
  39. if linkdir:startswith("/usr") then
  40. local includedir = path.join(path.directory(linkdir), "include", "spirv-tools")
  41. if os.isdir(includedir) then
  42. includedir = path.directory(includedir)
  43. result.includedirs = result.includedirs or {}
  44. table.insert(result.includedirs, includedir)
  45. end
  46. end
  47. end
  48. end
  49. return result
  50. end
  51. end)
  52. on_install(function (package)
  53. package:addenv("PATH", "bin")
  54. local configs = {"-DSPIRV_SKIP_TESTS=ON", "-DSPIRV_WERROR=OFF"}
  55. -- walkaround for potential conflict with parallel build & debug pdb generation
  56. if package:debug() then
  57. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  58. end
  59. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  60. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  61. local spirv = package:dep("spirv-headers")
  62. table.insert(configs, "-DSPIRV-Headers_SOURCE_DIR=" .. spirv:installdir():gsub("\\", "/"))
  63. if package:is_plat("windows") then
  64. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  65. else
  66. import("package.tools.cmake").install(package, configs)
  67. end
  68. package:add("links", "SPIRV-Tools-link", "SPIRV-Tools-reduce", "SPIRV-Tools-opt")
  69. if package:config("shared") then
  70. package:add("links", "SPIRV-Tools-shared")
  71. else
  72. package:add("links", "SPIRV-Tools")
  73. end
  74. end)
  75. on_test(function (package)
  76. if not package:is_cross() then
  77. os.runv("spirv-as --help")
  78. os.runv("spirv-opt --help")
  79. end
  80. assert(package:has_cxxfuncs("spvContextCreate", {configs = {languages = "c++17"}, includes = "spirv-tools/libspirv.hpp"}))
  81. end)