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 COMMON_COPTS = select({
47 "@bazel_tools//src/conditions:windows": [""],
48 "//conditions:default": [
52 "-Wunused-local-typedefs",
58 "-fvisibility=hidden",
59 "-fvisibility-inlines-hidden",
69 "glslang/GenericCodeGen/*.cpp",
71 "glslang/MachineIndependent/*.cpp",
72 "glslang/MachineIndependent/preprocessor/*.cpp",
76 "glslang/MachineIndependent/pch.h",
79 "OGLCompilersDLL/InitializeDll.cpp",
81 "@bazel_tools//src/conditions:windows":
82 ["glslang/OSDependent/Windows/ossource.cpp"],
83 "//conditions:default":
84 ["glslang/OSDependent/Unix/ossource.cpp"],
88 "glslang/Include/*.h",
89 "glslang/MachineIndependent/*.h",
90 "glslang/MachineIndependent/preprocessor/*.h",
92 "OGLCompilersDLL/InitializeDll.h",
93 "StandAlone/DirStackFileIncluder.h",
94 "glslang/OSDependent/osinclude.h",
95 "glslang/Public/ShaderLang.h",
105 "@bazel_tools//src/conditions:windows": [""],
106 "//conditions:default": ["-lm", "-lpthread"],
112 name = "export_spirv_headers",
114 "SPIRV/GLSL.ext.AMD.h",
115 "SPIRV/GLSL.ext.EXT.h",
116 "SPIRV/GLSL.ext.KHR.h",
117 "SPIRV/GLSL.ext.NV.h",
118 "SPIRV/GLSL.std.450.h",
119 "SPIRV/NonSemanticDebugPrintf.h",
123 "include/SPIRV/GLSL.ext.AMD.h",
124 "include/SPIRV/GLSL.ext.EXT.h",
125 "include/SPIRV/GLSL.ext.KHR.h",
126 "include/SPIRV/GLSL.ext.NV.h",
127 "include/SPIRV/GLSL.std.450.h",
128 "include/SPIRV/NonSemanticDebugPrintf.h",
129 "include/SPIRV/spirv.hpp",
131 cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
135 name = "SPIRV_headers",
136 hdrs = [":export_spirv_headers"],
137 copts = COMMON_COPTS,
150 "SPIRV/SpvTools.cpp",
154 "SPIRV/GlslangToSpv.h",
156 "SPIRV/SPVRemapper.h",
157 "SPIRV/SpvBuilder.h",
160 "SPIRV/disassemble.h",
165 copts = COMMON_COPTS,
166 includes = ["SPIRV"],
168 "@bazel_tools//src/conditions:windows": [""],
169 "//conditions:default": ["-lm"],
179 name = "glslang-default-resource-limits",
180 srcs = ["StandAlone/ResourceLimits.cpp"],
181 hdrs = ["StandAlone/ResourceLimits.h"],
182 copts = COMMON_COPTS,
188 name = "glslangValidator",
190 "StandAlone/StandAlone.cpp",
191 "StandAlone/Worklist.h",
193 copts = COMMON_COPTS,
197 ":glslang-default-resource-limits",
202 name = "spirv-remap",
203 srcs = ["StandAlone/spirv-remap.cpp"],
204 copts = COMMON_COPTS,
208 ":glslang-default-resource-limits",
218 "Test/glslangValidator",
225 name = "glslang_test_lib",
228 "gtests/HexFloat.cpp",
229 "gtests/Initializer.h",
230 "gtests/Settings.cpp",
232 "gtests/TestFixture.cpp",
233 "gtests/TestFixture.h",
236 copts = COMMON_COPTS,
237 data = [":test_files"],
239 # Unfortunately we can't use $(location) in cc_library at the moment.
240 # See https://github.com/bazelbuild/bazel/issues/1023
241 # So we'll specify the path manually.
242 "@bazel_tools//src/conditions:windows":
243 ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"],
244 "//conditions:default":
245 ["GLSLANG_TEST_DIRECTORY='\"Test\"'"],
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",
269 copts = COMMON_COPTS,
278 ) for test_file in GLSLANG_TESTS]