1 # Copyright (C) 2020 The Khronos Group Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
17 # Neither the name of The Khronos Group Inc. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
35 default_visibility = ["//visibility:public"],
40 # Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator.
44 exports_files(["LICENSE"])
46 COMMON_COPTS = select({
47 "@bazel_tools//src/conditions:windows": [""],
48 "//conditions:default": [
52 "-Wunused-local-typedefs",
58 "-fvisibility=hidden",
59 "-fvisibility-inlines-hidden",
69 "glslang/GenericCodeGen/*.cpp",
71 "glslang/MachineIndependent/*.cpp",
72 "glslang/MachineIndependent/preprocessor/*.cpp",
75 "glslang/HLSL/pch.cpp",
77 "glslang/MachineIndependent/pch.cpp",
78 "glslang/MachineIndependent/pch.h",
81 "OGLCompilersDLL/InitializeDll.cpp",
83 "@bazel_tools//src/conditions:windows":
84 ["glslang/OSDependent/Windows/ossource.cpp"],
85 "//conditions:default":
86 ["glslang/OSDependent/Unix/ossource.cpp"],
90 "glslang/Include/*.h",
91 "glslang/MachineIndependent/*.h",
92 "glslang/MachineIndependent/preprocessor/*.h",
94 "OGLCompilersDLL/InitializeDll.h",
95 "StandAlone/DirStackFileIncluder.h",
96 "glslang/OSDependent/osinclude.h",
97 "glslang/Public/ShaderLang.h",
107 "@bazel_tools//src/conditions:windows": [""],
108 "//conditions:default": ["-lm", "-lpthread"],
114 name = "export_spirv_headers",
116 "SPIRV/GLSL.ext.AMD.h",
117 "SPIRV/GLSL.ext.EXT.h",
118 "SPIRV/GLSL.ext.KHR.h",
119 "SPIRV/GLSL.ext.NV.h",
120 "SPIRV/GLSL.std.450.h",
121 "SPIRV/NonSemanticDebugPrintf.h",
125 "include/SPIRV/GLSL.ext.AMD.h",
126 "include/SPIRV/GLSL.ext.EXT.h",
127 "include/SPIRV/GLSL.ext.KHR.h",
128 "include/SPIRV/GLSL.ext.NV.h",
129 "include/SPIRV/GLSL.std.450.h",
130 "include/SPIRV/NonSemanticDebugPrintf.h",
131 "include/SPIRV/spirv.hpp",
133 cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
137 name = "SPIRV_headers",
138 hdrs = [":export_spirv_headers"],
139 copts = COMMON_COPTS,
152 "SPIRV/SpvTools.cpp",
156 "SPIRV/GlslangToSpv.h",
158 "SPIRV/SPVRemapper.h",
159 "SPIRV/SpvBuilder.h",
162 "SPIRV/disassemble.h",
167 copts = COMMON_COPTS,
168 includes = ["SPIRV"],
170 "@bazel_tools//src/conditions:windows": [""],
171 "//conditions:default": ["-lm"],
181 name = "glslang-default-resource-limits",
182 srcs = ["StandAlone/ResourceLimits.cpp"],
183 hdrs = ["StandAlone/ResourceLimits.h"],
184 copts = COMMON_COPTS,
190 name = "glslangValidator",
192 "StandAlone/StandAlone.cpp",
193 "StandAlone/Worklist.h",
195 copts = COMMON_COPTS,
199 ":glslang-default-resource-limits",
204 name = "spirv-remap",
205 srcs = ["StandAlone/spirv-remap.cpp"],
206 copts = COMMON_COPTS,
210 ":glslang-default-resource-limits",
220 "Test/glslangValidator",
227 name = "glslang_test_lib",
230 "gtests/HexFloat.cpp",
231 "gtests/Initializer.h",
232 "gtests/Settings.cpp",
234 "gtests/TestFixture.cpp",
235 "gtests/TestFixture.h",
238 copts = COMMON_COPTS,
239 data = [":test_files"],
241 # Unfortunately we can't use $(location) in cc_library at the moment.
242 # See https://github.com/bazelbuild/bazel/issues/1023
243 # So we'll specify the path manually.
244 "@bazel_tools//src/conditions:windows":
245 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
246 "//conditions:default":
247 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
253 ":glslang-default-resource-limits",
254 "@com_google_googletest//:gtest",
258 GLSLANG_TESTS = glob(
259 ["gtests/*.FromFile.cpp"],
260 # Since we are not building the SPIRV-Tools dependency, the following tests
261 # cannot be performed.
263 "gtests/Hlsl.FromFile.cpp",
264 "gtests/Spv.FromFile.cpp",
269 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
271 copts = COMMON_COPTS,
280 ) for test_file in GLSLANG_TESTS]