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_build_info_h",
54 srcs = ["CHANGES.md", "build_info.h.tmpl"],
55 outs = ["glslang/build_info.h"],
56 cmd_bash = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
57 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)",
58 tools = [":build_info"],
61 COMMON_COPTS = select({
62 "@bazel_tools//src/conditions:windows": [""],
63 "//conditions:default": [
67 "-Wunused-local-typedefs",
73 "-fvisibility=hidden",
74 "-fvisibility-inlines-hidden",
84 "glslang/GenericCodeGen/*.cpp",
86 "glslang/MachineIndependent/*.cpp",
87 "glslang/MachineIndependent/preprocessor/*.cpp",
91 "glslang/MachineIndependent/pch.h",
94 "OGLCompilersDLL/InitializeDll.cpp",
96 "@bazel_tools//src/conditions:windows":
97 ["glslang/OSDependent/Windows/ossource.cpp"],
98 "//conditions:default":
99 ["glslang/OSDependent/Unix/ossource.cpp"],
103 "glslang/Include/*.h",
104 "glslang/MachineIndependent/*.h",
105 "glslang/MachineIndependent/preprocessor/*.h",
107 "OGLCompilersDLL/InitializeDll.h",
108 "StandAlone/DirStackFileIncluder.h",
109 "glslang/OSDependent/osinclude.h",
110 "glslang/Public/ShaderLang.h",
113 copts = COMMON_COPTS,
121 "@bazel_tools//src/conditions:windows": [""],
122 "//conditions:default": ["-lm", "-lpthread"],
128 name = "export_spirv_headers",
130 "SPIRV/GLSL.ext.AMD.h",
131 "SPIRV/GLSL.ext.EXT.h",
132 "SPIRV/GLSL.ext.KHR.h",
133 "SPIRV/GLSL.ext.NV.h",
134 "SPIRV/GLSL.std.450.h",
135 "SPIRV/NonSemanticDebugPrintf.h",
139 "include/SPIRV/GLSL.ext.AMD.h",
140 "include/SPIRV/GLSL.ext.EXT.h",
141 "include/SPIRV/GLSL.ext.KHR.h",
142 "include/SPIRV/GLSL.ext.NV.h",
143 "include/SPIRV/GLSL.std.450.h",
144 "include/SPIRV/NonSemanticDebugPrintf.h",
145 "include/SPIRV/spirv.hpp",
147 cmd_bash = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
148 cmd_bat = "(if not exist $(@D)\\include\\SPIRV mkdir $(@D)\\include\\SPIRV) && (for %S in ($(SRCS)) do @xcopy /q %S $(@D)\\include\\SPIRV\\ >NUL)",
152 name = "SPIRV_headers",
153 hdrs = [":export_spirv_headers"],
154 copts = COMMON_COPTS,
167 "SPIRV/SpvTools.cpp",
171 "SPIRV/GlslangToSpv.h",
173 "SPIRV/SPVRemapper.h",
174 "SPIRV/SpvBuilder.h",
177 "SPIRV/disassemble.h",
182 copts = COMMON_COPTS,
183 includes = ["SPIRV"],
185 "@bazel_tools//src/conditions:windows": [""],
186 "//conditions:default": ["-lm"],
196 name = "glslang-default-resource-limits",
197 srcs = ["StandAlone/ResourceLimits.cpp"],
198 hdrs = ["StandAlone/ResourceLimits.h"],
199 copts = COMMON_COPTS,
205 name = "glslangValidator",
207 "StandAlone/StandAlone.cpp",
208 "StandAlone/Worklist.h",
210 copts = COMMON_COPTS,
214 ":glslang-default-resource-limits",
219 name = "spirv-remap",
220 srcs = ["StandAlone/spirv-remap.cpp"],
221 copts = COMMON_COPTS,
225 ":glslang-default-resource-limits",
235 "Test/glslangValidator",
242 name = "glslang_test_lib",
245 "gtests/HexFloat.cpp",
246 "gtests/Initializer.h",
247 "gtests/Settings.cpp",
249 "gtests/TestFixture.cpp",
250 "gtests/TestFixture.h",
253 copts = COMMON_COPTS,
254 data = [":test_files"],
256 # Unfortunately we can't use $(location) in cc_library at the moment.
257 # See https://github.com/bazelbuild/bazel/issues/1023
258 # So we'll specify the path manually.
259 "@bazel_tools//src/conditions:windows":
260 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
261 "//conditions:default":
262 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
268 ":glslang-default-resource-limits",
269 "@com_google_googletest//:gtest",
273 GLSLANG_TESTS = glob(
274 ["gtests/*.FromFile.cpp"],
275 # Since we are not building the SPIRV-Tools dependency, the following tests
276 # cannot be performed.
278 "gtests/Hlsl.FromFile.cpp",
279 "gtests/Spv.FromFile.cpp",
284 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
286 copts = COMMON_COPTS,
295 ) for test_file in GLSLANG_TESTS]