Improve ResourceLimits interface to be more forward compatible
[platform/upstream/glslang.git] / BUILD.bazel
index 82c4f66..45efbd3 100644 (file)
@@ -49,17 +49,28 @@ py_binary(
     srcs = ["build_info.py"],
 )
 
+py_binary(
+    name = "gen_extension_headers",
+    srcs = ["gen_extension_headers.py"],
+)
+
 genrule(
     name = "gen_build_info_h",
-    srcs = [
-        "CHANGES.md",
-        "build_info.h.tmpl",
-    ],
+    srcs = ["CHANGES.md", "build_info.h.tmpl"],
     outs = ["glslang/build_info.h"],
-    cmd = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
+    cmd_bash = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
+    cmd_bat = "for %F in ($(location CHANGES.md)) do $(location build_info) %~dpF -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
     tools = [":build_info"],
 )
 
+genrule(
+    name = "gen_extension_headers_h",
+    srcs = ["glslang/ExtensionHeaders", "gen_extension_headers.py"],
+    outs = ["glslang/glsl_intrinsic_header.h"],
+    cmd_bash = "$(location gen_extension_headers) -i  $(location glslang/ExtensionHeaders) -o $(location glslang/glsl_intrinsic_header.h)",
+    tools = [":gen_extension_headers"],
+)
+
 COMMON_COPTS = select({
     "@bazel_tools//src/conditions:windows": [""],
     "//conditions:default": [
@@ -95,8 +106,10 @@ cc_library(
     ) + [
         "OGLCompilersDLL/InitializeDll.cpp",
     ] + select({
-        "@bazel_tools//src/conditions:windows": ["glslang/OSDependent/Windows/ossource.cpp"],
-        "//conditions:default": ["glslang/OSDependent/Unix/ossource.cpp"],
+        "@bazel_tools//src/conditions:windows":
+            ["glslang/OSDependent/Windows/ossource.cpp"],
+        "//conditions:default":
+            ["glslang/OSDependent/Unix/ossource.cpp"],
     }),
     hdrs = glob([
         "glslang/HLSL/*.h",
@@ -119,10 +132,7 @@ cc_library(
     ],
     linkopts = select({
         "@bazel_tools//src/conditions:windows": [""],
-        "//conditions:default": [
-            "-lm",
-            "-lpthread",
-        ],
+        "//conditions:default": ["-lm", "-lpthread"],
     }),
     linkstatic = 1,
 )
@@ -136,6 +146,7 @@ genrule(
         "SPIRV/GLSL.ext.NV.h",
         "SPIRV/GLSL.std.450.h",
         "SPIRV/NonSemanticDebugPrintf.h",
+        "SPIRV/NonSemanticShaderDebugInfo100.h",
         "SPIRV/spirv.hpp",
     ],
     outs = [
@@ -145,9 +156,11 @@ genrule(
         "include/SPIRV/GLSL.ext.NV.h",
         "include/SPIRV/GLSL.std.450.h",
         "include/SPIRV/NonSemanticDebugPrintf.h",
+        "include/SPIRV/NonSemanticShaderDebugInfo100.h",
         "include/SPIRV/spirv.hpp",
     ],
-    cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
+    cmd_bash = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
+    cmd_bat = "(if not exist $(@D)\\include\\SPIRV mkdir $(@D)\\include\\SPIRV) && (for %S in ($(SRCS)) do @xcopy /q %S $(@D)\\include\\SPIRV\\ >NUL)",
 )
 
 cc_library(
@@ -197,7 +210,7 @@ cc_library(
 cc_library(
     name = "glslang-default-resource-limits",
     srcs = ["StandAlone/ResourceLimits.cpp"],
-    hdrs = ["StandAlone/ResourceLimits.h"],
+    hdrs = ["glslang/Public/ResourceLimits.h"],
     copts = COMMON_COPTS,
     linkstatic = 1,
     deps = [":glslang"],
@@ -208,6 +221,7 @@ cc_binary(
     srcs = [
         "StandAlone/StandAlone.cpp",
         "StandAlone/Worklist.h",
+        ":glslang/glsl_intrinsic_header.h"
     ],
     copts = COMMON_COPTS,
     deps = [
@@ -228,6 +242,18 @@ cc_binary(
     ],
 )
 
+filegroup(
+    name = "test_files",
+    srcs = glob(
+        ["Test/**"],
+        exclude = [
+            "Test/bump",
+            "Test/glslangValidator",
+            "Test/runtests",
+        ],
+    ),
+)
+
 cc_library(
     name = "glslang_test_lib",
     testonly = 1,
@@ -241,9 +267,16 @@ cc_library(
         "gtests/main.cpp",
     ],
     copts = COMMON_COPTS,
-    defines = [
-        "GLSLANG_TEST_DIRECTORY='\"USE_FLAG_INSTEAD\"'",
-    ],
+    data = [":test_files"],
+    defines = select({
+        # Unfortunately we can't use $(location) in cc_library at the moment.
+        # See https://github.com/bazelbuild/bazel/issues/1023
+        # So we'll specify the path manually.
+        "@bazel_tools//src/conditions:windows":
+            ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
+        "//conditions:default":
+            ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
+    }),
     linkstatic = 1,
     deps = [
         ":SPIRV",
@@ -266,13 +299,9 @@ GLSLANG_TESTS = glob(
 [cc_test(
     name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
     srcs = [test_file],
-    args = [
-        "--test-root",
-        "$(rootpath Test)",
-    ],
     copts = COMMON_COPTS,
     data = [
-        "Test",
+        ":test_files",
     ],
     deps = [
         ":SPIRV",