xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("spirv-cross")
  2. set_homepage("https://github.com/KhronosGroup/SPIRV-Cross/")
  3. set_description("SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/KhronosGroup/SPIRV-Cross.git")
  6. add_versions("1.2.154+1", "e6f5ce6b8998f551f3400ad743b77be51bbe3019")
  7. add_versions("1.2.162+0", "6d10da0224bd3214c9a507832e62d9fb6ae9620d")
  8. add_versions("1.2.189+1", "0e2880ab990e79ce6cc8c79c219feda42d98b1e8")
  9. add_versions("1.3.231+1", "f09ba2777714871bddb70d049878af34b94fa54d")
  10. add_versions("1.3.268+0", "2de1265fca722929785d9acdec4ab728c47a0254")
  11. add_configs("exceptions", {description = "Enable exception handling", default = true, type = "boolean"})
  12. add_deps("cmake")
  13. if is_plat("windows") then
  14. set_policy("platform.longpaths", true)
  15. end
  16. on_load(function (package)
  17. local links = {"spirv-cross-c", "spirv-cross-cpp", "spirv-cross-reflect",
  18. "spirv-cross-msl", "spirv-cross-util", "spirv-cross-hlsl",
  19. "spirv-cross-glsl", "spirv-cross-core"}
  20. for _, link in ipairs(links) do
  21. if package:is_plat("windows") and package:is_debug() then
  22. link = link .. "d"
  23. end
  24. package:add("links", link)
  25. end
  26. end)
  27. on_install("windows", "linux", "macosx", "mingw", function (package)
  28. local configs = {"-DSPIRV_CROSS_ENABLE_TESTS=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. local cxflags
  31. if package:config("exceptions") then
  32. table.insert(configs, "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=OFF")
  33. if package:is_plat("windows") and package:has_tool("cxx", "cl", "clang_cl") then
  34. cxflags = {"/EHsc"}
  35. end
  36. else
  37. table.insert(configs, "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON")
  38. end
  39. if package:is_plat("windows") and package:is_debug() then
  40. cxflags = cxflags or {}
  41. table.insert(cxflags, "/FS")
  42. end
  43. if package:config("shared") then
  44. table.insert(configs, "-DSPIRV_CROSS_SHARED=ON")
  45. else
  46. table.insert(configs, "-DSPIRV_CROSS_SHARED=OFF")
  47. end
  48. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  49. package:addenv("PATH", "bin")
  50. end)
  51. on_test(function (package)
  52. if not package:is_cross() then
  53. os.vrun("spirv-cross --help")
  54. end
  55. assert(package:has_cfuncs("spvc_get_version", {includes = "spirv_cross/spirv_cross_c.h"}))
  56. end)