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 = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
57 tools = [":build_info"],
60 COMMON_COPTS = select({
61 "@bazel_tools//src/conditions:windows": [""],
62 "//conditions:default": [
66 "-Wunused-local-typedefs",
72 "-fvisibility=hidden",
73 "-fvisibility-inlines-hidden",
83 "glslang/GenericCodeGen/*.cpp",
85 "glslang/MachineIndependent/*.cpp",
86 "glslang/MachineIndependent/preprocessor/*.cpp",
90 "glslang/MachineIndependent/pch.h",
93 "OGLCompilersDLL/InitializeDll.cpp",
95 "@bazel_tools//src/conditions:windows":
96 ["glslang/OSDependent/Windows/ossource.cpp"],
97 "//conditions:default":
98 ["glslang/OSDependent/Unix/ossource.cpp"],
102 "glslang/Include/*.h",
103 "glslang/MachineIndependent/*.h",
104 "glslang/MachineIndependent/preprocessor/*.h",
106 "OGLCompilersDLL/InitializeDll.h",
107 "StandAlone/DirStackFileIncluder.h",
108 "glslang/OSDependent/osinclude.h",
109 "glslang/Public/ShaderLang.h",
112 copts = COMMON_COPTS,
120 "@bazel_tools//src/conditions:windows": [""],
121 "//conditions:default": ["-lm", "-lpthread"],
127 name = "export_spirv_headers",
129 "SPIRV/GLSL.ext.AMD.h",
130 "SPIRV/GLSL.ext.EXT.h",
131 "SPIRV/GLSL.ext.KHR.h",
132 "SPIRV/GLSL.ext.NV.h",
133 "SPIRV/GLSL.std.450.h",
134 "SPIRV/NonSemanticDebugPrintf.h",
138 "include/SPIRV/GLSL.ext.AMD.h",
139 "include/SPIRV/GLSL.ext.EXT.h",
140 "include/SPIRV/GLSL.ext.KHR.h",
141 "include/SPIRV/GLSL.ext.NV.h",
142 "include/SPIRV/GLSL.std.450.h",
143 "include/SPIRV/NonSemanticDebugPrintf.h",
144 "include/SPIRV/spirv.hpp",
146 cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
150 name = "SPIRV_headers",
151 hdrs = [":export_spirv_headers"],
152 copts = COMMON_COPTS,
165 "SPIRV/SpvTools.cpp",
169 "SPIRV/GlslangToSpv.h",
171 "SPIRV/SPVRemapper.h",
172 "SPIRV/SpvBuilder.h",
175 "SPIRV/disassemble.h",
180 copts = COMMON_COPTS,
181 includes = ["SPIRV"],
183 "@bazel_tools//src/conditions:windows": [""],
184 "//conditions:default": ["-lm"],
194 name = "glslang-default-resource-limits",
195 srcs = ["StandAlone/ResourceLimits.cpp"],
196 hdrs = ["StandAlone/ResourceLimits.h"],
197 copts = COMMON_COPTS,
203 name = "glslangValidator",
205 "StandAlone/StandAlone.cpp",
206 "StandAlone/Worklist.h",
208 copts = COMMON_COPTS,
212 ":glslang-default-resource-limits",
217 name = "spirv-remap",
218 srcs = ["StandAlone/spirv-remap.cpp"],
219 copts = COMMON_COPTS,
223 ":glslang-default-resource-limits",
233 "Test/glslangValidator",
240 name = "glslang_test_lib",
243 "gtests/HexFloat.cpp",
244 "gtests/Initializer.h",
245 "gtests/Settings.cpp",
247 "gtests/TestFixture.cpp",
248 "gtests/TestFixture.h",
251 copts = COMMON_COPTS,
252 data = [":test_files"],
254 # Unfortunately we can't use $(location) in cc_library at the moment.
255 # See https://github.com/bazelbuild/bazel/issues/1023
256 # So we'll specify the path manually.
257 "@bazel_tools//src/conditions:windows":
258 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
259 "//conditions:default":
260 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
266 ":glslang-default-resource-limits",
267 "@com_google_googletest//:gtest",
271 GLSLANG_TESTS = glob(
272 ["gtests/*.FromFile.cpp"],
273 # Since we are not building the SPIRV-Tools dependency, the following tests
274 # cannot be performed.
276 "gtests/Hlsl.FromFile.cpp",
277 "gtests/Spv.FromFile.cpp",
282 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
284 copts = COMMON_COPTS,
293 ) for test_file in GLSLANG_TESTS]