xmake.lua 3.6 KB

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