Browse Source

Add mingw support to glslang, spirv-headers and spirv-tools (#791)

* Add mingw support to glslang, spirv-headers and spirv-tools

* Fix glslang and spirv-tools tests

* Add MinGW support to spirv-cross and spirv-reflect
Jérôme Leclercq 3 years ago
parent
commit
66eb03baa9

+ 4 - 4
packages/g/glslang/xmake.lua

@@ -29,7 +29,7 @@ package("glslang")
         end
     end)
 
-    on_install("linux", "windows", "macosx", function (package)
+    on_install("linux", "windows", "macosx", "mingw", function (package)
         package:addenv("PATH", "bin")
         io.replace("CMakeLists.txt", "ENABLE_OPT OFF", "ENABLE_OPT ON")
         io.replace("StandAlone/CMakeLists.txt", "target_link_libraries(glslangValidator ${LIBRARIES})", [[
@@ -52,10 +52,10 @@ package("glslang")
     end)
 
     on_test(function (package)
-        os.vrun("glslangValidator --version")
+        if not package:is_plat("mingw") or is_subhost("msys") then
+            os.vrun("glslangValidator --version")
+        end
         if not package:config("binaryonly") then
             assert(package:has_cxxfuncs("ShInitialize", {configs = {languages = "c++11"}, includes = "glslang/Public/ShaderLang.h"}))
         end
     end)
-
-

+ 4 - 2
packages/s/spirv-cross/xmake.lua

@@ -12,7 +12,7 @@ package("spirv-cross")
     add_deps("cmake")
     add_links("spirv-cross-c", "spirv-cross-cpp", "spirv-cross-reflect", "spirv-cross-msl", "spirv-cross-util", "spirv-cross-hlsl", "spirv-cross-glsl", "spirv-cross-core")
 
-    on_install("windows", "linux", "macosx", function (package)
+    on_install("windows", "linux", "macosx", "mingw", function (package)
         local configs = {"-DSPIRV_CROSS_ENABLE_TESTS=OFF"}
         if package:config("shared") then
             table.insert(configs, "-DSPIRV_CROSS_SHARED=ON")
@@ -24,6 +24,8 @@ package("spirv-cross")
     end)
 
     on_test(function (package)
-        os.vrun("spirv-cross --help")
+        if not package:is_plat("mingw") or is_subhost("msys") then
+            os.vrun("spirv-cross --help")
+        end
         assert(package:has_cfuncs("spvc_get_version", {includes = "spirv_cross/spirv_cross_c.h"}))
     end)

+ 1 - 1
packages/s/spirv-headers/xmake.lua

@@ -13,7 +13,7 @@ package("spirv-headers")
 
     add_deps("cmake")
 
-    on_install("linux", "windows", "macosx", function (package)
+    on_install(function (package)
         import("package.tools.cmake").install(package, {"-DSPIRV_HEADERS_SKIP_EXAMPLES=ON"})
     end)
 

+ 1 - 1
packages/s/spirv-reflect/xmake.lua

@@ -11,7 +11,7 @@ package("spirv-reflect")
 
     add_deps("spirv-headers")
 
-    on_install("windows", "linux", "macosx", function (package)
+    on_install("windows", "linux", "macosx", "mingw", function (package)
         io.gsub("spirv_reflect.h", "#include \"%.%/include%/spirv%/unified1%/spirv.h\"", "#include \"spirv/unified1/spirv.h\"")
         io.writefile("xmake.lua", [[
             add_rules("mode.debug", "mode.release")

+ 5 - 3
packages/s/spirv-tools/xmake.lua

@@ -38,7 +38,7 @@ package("spirv-tools")
         end
     end)
 
-    on_install("linux", "windows", "macosx", function (package)
+    on_install("linux", "windows", "macosx", "mingw", function (package)
         package:addenv("PATH", "bin")
         local configs = {"-DSPIRV_SKIP_TESTS=ON"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
@@ -59,7 +59,9 @@ package("spirv-tools")
     end)
 
     on_test(function (package)
-        os.runv("spirv-as --help")
-        os.runv("spirv-opt --help")
+        if not package:is_plat("mingw") or is_subhost("msys") then
+            os.runv("spirv-as --help")
+            os.runv("spirv-opt --help")
+        end
         assert(package:has_cxxfuncs("spvContextCreate", {configs = {languages = "c++11"}, includes = "spirv-tools/libspirv.hpp"}))
     end)