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 # Build information generation script
49 srcs = ["build_info.py"],
53 name = "gen_extension_headers",
54 srcs = ["gen_extension_headers.py"],
58 name = "gen_build_info_h",
59 srcs = ["CHANGES.md", "build_info.h.tmpl"],
60 outs = ["glslang/build_info.h"],
61 cmd_bash = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
62 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)",
63 tools = [":build_info"],
67 name = "gen_extension_headers_h",
68 srcs = ["glslang/ExtensionHeaders", "gen_extension_headers.py"],
69 outs = ["glslang/glsl_intrinsic_header.h"],
70 cmd_bash = "$(location gen_extension_headers) -i $(location glslang/ExtensionHeaders) -o $(location glslang/glsl_intrinsic_header.h)",
71 tools = [":gen_extension_headers"],
74 COMMON_COPTS = select({
75 "@bazel_tools//src/conditions:windows": [""],
76 "//conditions:default": [
80 "-Wunused-local-typedefs",
86 "-fvisibility=hidden",
87 "-fvisibility-inlines-hidden",
97 "glslang/GenericCodeGen/*.cpp",
99 "glslang/MachineIndependent/*.cpp",
100 "glslang/MachineIndependent/preprocessor/*.cpp",
103 "glslang/HLSL/pch.h",
104 "glslang/MachineIndependent/pch.h",
107 "OGLCompilersDLL/InitializeDll.cpp",
109 "@bazel_tools//src/conditions:windows":
110 ["glslang/OSDependent/Windows/ossource.cpp"],
111 "//conditions:default":
112 ["glslang/OSDependent/Unix/ossource.cpp"],
116 "glslang/Include/*.h",
117 "glslang/MachineIndependent/*.h",
118 "glslang/MachineIndependent/preprocessor/*.h",
120 "OGLCompilersDLL/InitializeDll.h",
121 "StandAlone/DirStackFileIncluder.h",
122 "glslang/OSDependent/osinclude.h",
123 "glslang/Public/ShaderLang.h",
126 copts = COMMON_COPTS,
134 "@bazel_tools//src/conditions:windows": [""],
135 "//conditions:default": ["-lm", "-lpthread"],
141 name = "export_spirv_headers",
143 "SPIRV/GLSL.ext.AMD.h",
144 "SPIRV/GLSL.ext.EXT.h",
145 "SPIRV/GLSL.ext.KHR.h",
146 "SPIRV/GLSL.ext.NV.h",
147 "SPIRV/GLSL.ext.ARM.h",
148 "SPIRV/GLSL.std.450.h",
149 "SPIRV/NonSemanticDebugPrintf.h",
150 "SPIRV/NonSemanticShaderDebugInfo100.h",
154 "include/SPIRV/GLSL.ext.AMD.h",
155 "include/SPIRV/GLSL.ext.EXT.h",
156 "include/SPIRV/GLSL.ext.KHR.h",
157 "include/SPIRV/GLSL.ext.NV.h",
158 "include/SPIRV/GLSL.ext.ARM.h",
159 "include/SPIRV/GLSL.std.450.h",
160 "include/SPIRV/NonSemanticDebugPrintf.h",
161 "include/SPIRV/NonSemanticShaderDebugInfo100.h",
162 "include/SPIRV/spirv.hpp",
164 cmd_bash = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
165 cmd_bat = "(if not exist $(@D)\\include\\SPIRV mkdir $(@D)\\include\\SPIRV) && (for %S in ($(SRCS)) do @xcopy /q %S $(@D)\\include\\SPIRV\\ >NUL)",
169 name = "SPIRV_headers",
170 hdrs = [":export_spirv_headers"],
171 copts = COMMON_COPTS,
184 "SPIRV/SpvTools.cpp",
188 "SPIRV/GlslangToSpv.h",
190 "SPIRV/SPVRemapper.h",
191 "SPIRV/SpvBuilder.h",
194 "SPIRV/disassemble.h",
199 copts = COMMON_COPTS,
200 includes = ["SPIRV"],
202 "@bazel_tools//src/conditions:windows": [""],
203 "//conditions:default": ["-lm"],
213 name = "glslang-default-resource-limits",
214 srcs = ["StandAlone/ResourceLimits.cpp"],
215 hdrs = ["glslang/Public/ResourceLimits.h"],
216 copts = COMMON_COPTS,
222 name = "glslangValidator",
224 "StandAlone/StandAlone.cpp",
225 "StandAlone/Worklist.h",
226 ":glslang/glsl_intrinsic_header.h"
228 copts = COMMON_COPTS,
232 ":glslang-default-resource-limits",
237 name = "spirv-remap",
238 srcs = ["StandAlone/spirv-remap.cpp"],
239 copts = COMMON_COPTS,
243 ":glslang-default-resource-limits",
253 "Test/glslangValidator",
260 name = "glslang_test_lib",
263 "gtests/HexFloat.cpp",
264 "gtests/Initializer.h",
265 "gtests/Settings.cpp",
267 "gtests/TestFixture.cpp",
268 "gtests/TestFixture.h",
271 copts = COMMON_COPTS,
272 data = [":test_files"],
274 # Unfortunately we can't use $(location) in cc_library at the moment.
275 # See https://github.com/bazelbuild/bazel/issues/1023
276 # So we'll specify the path manually.
277 "@bazel_tools//src/conditions:windows":
278 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
279 "//conditions:default":
280 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
286 ":glslang-default-resource-limits",
287 "@com_google_googletest//:gtest",
291 GLSLANG_TESTS = glob(
292 ["gtests/*.FromFile.cpp"],
293 # Since we are not building the SPIRV-Tools dependency, the following tests
294 # cannot be performed.
296 "gtests/Hlsl.FromFile.cpp",
297 "gtests/Spv.FromFile.cpp",
302 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
304 copts = COMMON_COPTS,
313 ) for test_file in GLSLANG_TESTS]