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",
58 outs = ["glslang/build_info.h"],
59 cmd = "$(location build_info) $$(dirname $(location CHANGES.md)) -i $(location build_info.h.tmpl) -o $(location glslang/build_info.h)",
60 tools = [":build_info"],
63 COMMON_COPTS = select({
64 "@bazel_tools//src/conditions:windows": [""],
65 "//conditions:default": [
69 "-Wunused-local-typedefs",
75 "-fvisibility=hidden",
76 "-fvisibility-inlines-hidden",
86 "glslang/GenericCodeGen/*.cpp",
88 "glslang/MachineIndependent/*.cpp",
89 "glslang/MachineIndependent/preprocessor/*.cpp",
93 "glslang/MachineIndependent/pch.h",
96 "OGLCompilersDLL/InitializeDll.cpp",
98 "@bazel_tools//src/conditions:windows": ["glslang/OSDependent/Windows/ossource.cpp"],
99 "//conditions:default": ["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": [
131 name = "export_spirv_headers",
133 "SPIRV/GLSL.ext.AMD.h",
134 "SPIRV/GLSL.ext.EXT.h",
135 "SPIRV/GLSL.ext.KHR.h",
136 "SPIRV/GLSL.ext.NV.h",
137 "SPIRV/GLSL.std.450.h",
138 "SPIRV/NonSemanticDebugPrintf.h",
142 "include/SPIRV/GLSL.ext.AMD.h",
143 "include/SPIRV/GLSL.ext.EXT.h",
144 "include/SPIRV/GLSL.ext.KHR.h",
145 "include/SPIRV/GLSL.ext.NV.h",
146 "include/SPIRV/GLSL.std.450.h",
147 "include/SPIRV/NonSemanticDebugPrintf.h",
148 "include/SPIRV/spirv.hpp",
150 cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
154 name = "SPIRV_headers",
155 hdrs = [":export_spirv_headers"],
156 copts = COMMON_COPTS,
169 "SPIRV/SpvTools.cpp",
173 "SPIRV/GlslangToSpv.h",
175 "SPIRV/SPVRemapper.h",
176 "SPIRV/SpvBuilder.h",
179 "SPIRV/disassemble.h",
184 copts = COMMON_COPTS,
185 includes = ["SPIRV"],
187 "@bazel_tools//src/conditions:windows": [""],
188 "//conditions:default": ["-lm"],
198 name = "glslang-default-resource-limits",
199 srcs = ["StandAlone/ResourceLimits.cpp"],
200 hdrs = ["StandAlone/ResourceLimits.h"],
201 copts = COMMON_COPTS,
207 name = "glslangValidator",
209 "StandAlone/StandAlone.cpp",
210 "StandAlone/Worklist.h",
212 copts = COMMON_COPTS,
216 ":glslang-default-resource-limits",
221 name = "spirv-remap",
222 srcs = ["StandAlone/spirv-remap.cpp"],
223 copts = COMMON_COPTS,
227 ":glslang-default-resource-limits",
232 name = "glslang_test_lib",
235 "gtests/HexFloat.cpp",
236 "gtests/Initializer.h",
237 "gtests/Settings.cpp",
239 "gtests/TestFixture.cpp",
240 "gtests/TestFixture.h",
243 copts = COMMON_COPTS,
245 "GLSLANG_TEST_DIRECTORY='\"USE_FLAG_INSTEAD\"'",
251 ":glslang-default-resource-limits",
252 "@com_google_googletest//:gtest",
256 GLSLANG_TESTS = glob(
257 ["gtests/*.FromFile.cpp"],
258 # Since we are not building the SPIRV-Tools dependency, the following tests
259 # cannot be performed.
261 "gtests/Hlsl.FromFile.cpp",
262 "gtests/Spv.FromFile.cpp",
267 name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test",
273 copts = COMMON_COPTS,
282 ) for test_file in GLSLANG_TESTS]