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.std.450.h",
148 "SPIRV/NonSemanticDebugPrintf.h",
152 "include/SPIRV/GLSL.ext.AMD.h",
153 "include/SPIRV/GLSL.ext.EXT.h",
154 "include/SPIRV/GLSL.ext.KHR.h",
155 "include/SPIRV/GLSL.ext.NV.h",
156 "include/SPIRV/GLSL.std.450.h",
157 "include/SPIRV/NonSemanticDebugPrintf.h",
158 "include/SPIRV/spirv.hpp",
160 cmd_bash = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
161 cmd_bat = "(if not exist $(@D)\\include\\SPIRV mkdir $(@D)\\include\\SPIRV) && (for %S in ($(SRCS)) do @xcopy /q %S $(@D)\\include\\SPIRV\\ >NUL)",
165 name = "SPIRV_headers",
166 hdrs = [":export_spirv_headers"],
167 copts = COMMON_COPTS,
180 "SPIRV/SpvTools.cpp",
184 "SPIRV/GlslangToSpv.h",
186 "SPIRV/SPVRemapper.h",
187 "SPIRV/SpvBuilder.h",
190 "SPIRV/disassemble.h",
195 copts = COMMON_COPTS,
196 includes = ["SPIRV"],
198 "@bazel_tools//src/conditions:windows": [""],
199 "//conditions:default": ["-lm"],
209 name = "glslang-default-resource-limits",
210 srcs = ["StandAlone/ResourceLimits.cpp"],
211 hdrs = ["StandAlone/ResourceLimits.h"],
212 copts = COMMON_COPTS,
218 name = "glslangValidator",
220 "StandAlone/StandAlone.cpp",
221 "StandAlone/Worklist.h",
222 ":glslang/glsl_intrinsic_header.h"
224 copts = COMMON_COPTS,
228 ":glslang-default-resource-limits",
233 name = "spirv-remap",
234 srcs = ["StandAlone/spirv-remap.cpp"],
235 copts = COMMON_COPTS,
239 ":glslang-default-resource-limits",
249 "Test/glslangValidator",
256 name = "glslang_test_lib",
259 "gtests/HexFloat.cpp",
260 "gtests/Initializer.h",
261 "gtests/Settings.cpp",
263 "gtests/TestFixture.cpp",
264 "gtests/TestFixture.h",
267 copts = COMMON_COPTS,
268 data = [":test_files"],
270 # Unfortunately we can't use $(location) in cc_library at the moment.
271 # See https://github.com/bazelbuild/bazel/issues/1023
272 # So we'll specify the path manually.
273 "@bazel_tools//src/conditions:windows":
274 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
275 "//conditions:default":
276 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
282 ":glslang-default-resource-limits",
283 "@com_google_googletest//:gtest",
287 GLSLANG_TESTS = glob(
288 ["gtests/*.FromFile.cpp"],
289 # Since we are not building the SPIRV-Tools dependency, the following tests
290 # cannot be performed.
292 "gtests/Hlsl.FromFile.cpp",
293 "gtests/Spv.FromFile.cpp",
298 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
300 copts = COMMON_COPTS,
309 ) for test_file in GLSLANG_TESTS]