1 # Copyright (C) 2018 Google, 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 Google 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.
34 import("//build_overrides/glslang.gni")
36 # Both Chromium and Fuchsia use by default a set of warning errors
37 # that is far too strict to compile this project. These are also
38 # typically appended after |cflags|, overriding target-specific
39 # definitions. To work around this, determine which configs to
40 # add and remove in order to succesfully build the project.
41 if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
42 _configs_to_remove = [ "//build/config:default_warnings" ]
45 _configs_to_remove = [ "//build/config/compiler:chromium_code" ]
46 _configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
49 action("glslang_build_info") {
50 script = "build_info.py"
53 changes_file = "CHANGES.md"
54 template_file = "build_info.h.tmpl"
55 out_file = "${target_gen_dir}/include/glslang/build_info.h"
62 outputs = [ out_file ]
64 rebase_path(src_dir, root_build_dir),
66 rebase_path(template_file, root_build_dir),
68 rebase_path(out_file, root_build_dir),
72 spirv_tools_dir = glslang_spirv_tools_dir
73 if (!defined(glslang_angle)) {
77 config("glslang_public") {
78 include_dirs = [ "." ]
79 if (!is_win || is_clang) {
80 cflags = [ "-Wno-conversion" ]
84 config("glslang_hlsl") {
85 defines = [ "ENABLE_HLSL=1" ]
88 template("glslang_sources_common") {
89 source_set(target_name) {
90 public_configs = [ ":glslang_public" ]
92 if (invoker.enable_hlsl) {
93 public_configs += [ ":glslang_hlsl" ]
97 "OGLCompilersDLL/InitializeDll.cpp",
98 "OGLCompilersDLL/InitializeDll.h",
99 "SPIRV/GLSL.ext.AMD.h",
100 "SPIRV/GLSL.ext.EXT.h",
101 "SPIRV/GLSL.ext.KHR.h",
102 "SPIRV/GLSL.ext.NV.h",
103 "SPIRV/GLSL.std.450.h",
104 "SPIRV/GlslangToSpv.cpp",
105 "SPIRV/GlslangToSpv.h",
106 "SPIRV/InReadableOrder.cpp",
109 "SPIRV/NonSemanticDebugPrintf.h",
110 "SPIRV/SPVRemapper.cpp",
111 "SPIRV/SPVRemapper.h",
112 "SPIRV/SpvBuilder.cpp",
113 "SPIRV/SpvBuilder.h",
114 "SPIRV/SpvPostProcess.cpp",
117 "SPIRV/disassemble.cpp",
118 "SPIRV/disassemble.h",
124 "glslang/GenericCodeGen/CodeGen.cpp",
125 "glslang/GenericCodeGen/Link.cpp",
126 "glslang/Include/BaseTypes.h",
127 "glslang/Include/Common.h",
128 "glslang/Include/ConstantUnion.h",
129 "glslang/Include/InfoSink.h",
130 "glslang/Include/InitializeGlobals.h",
131 "glslang/Include/PoolAlloc.h",
132 "glslang/Include/ResourceLimits.h",
133 "glslang/Include/ShHandle.h",
134 "glslang/Include/Types.h",
135 "glslang/Include/arrays.h",
136 "glslang/Include/intermediate.h",
137 "glslang/MachineIndependent/Constant.cpp",
138 "glslang/MachineIndependent/InfoSink.cpp",
139 "glslang/MachineIndependent/Initialize.cpp",
140 "glslang/MachineIndependent/Initialize.h",
141 "glslang/MachineIndependent/IntermTraverse.cpp",
142 "glslang/MachineIndependent/Intermediate.cpp",
143 "glslang/MachineIndependent/LiveTraverser.h",
144 "glslang/MachineIndependent/ParseContextBase.cpp",
145 "glslang/MachineIndependent/ParseHelper.cpp",
146 "glslang/MachineIndependent/ParseHelper.h",
147 "glslang/MachineIndependent/PoolAlloc.cpp",
148 "glslang/MachineIndependent/RemoveTree.cpp",
149 "glslang/MachineIndependent/RemoveTree.h",
150 "glslang/MachineIndependent/Scan.cpp",
151 "glslang/MachineIndependent/Scan.h",
152 "glslang/MachineIndependent/ScanContext.h",
153 "glslang/MachineIndependent/ShaderLang.cpp",
154 "glslang/MachineIndependent/SymbolTable.cpp",
155 "glslang/MachineIndependent/SymbolTable.h",
156 "glslang/MachineIndependent/Versions.cpp",
157 "glslang/MachineIndependent/Versions.h",
158 "glslang/MachineIndependent/attribute.cpp",
159 "glslang/MachineIndependent/attribute.h",
160 "glslang/MachineIndependent/gl_types.h",
161 "glslang/MachineIndependent/glslang_tab.cpp",
162 "glslang/MachineIndependent/glslang_tab.cpp.h",
163 "glslang/MachineIndependent/intermOut.cpp",
164 "glslang/MachineIndependent/iomapper.cpp",
165 "glslang/MachineIndependent/iomapper.h",
166 "glslang/MachineIndependent/limits.cpp",
167 "glslang/MachineIndependent/linkValidate.cpp",
168 "glslang/MachineIndependent/localintermediate.h",
169 "glslang/MachineIndependent/parseConst.cpp",
170 "glslang/MachineIndependent/parseVersions.h",
171 "glslang/MachineIndependent/preprocessor/Pp.cpp",
172 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
173 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
174 "glslang/MachineIndependent/preprocessor/PpContext.h",
175 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
176 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
177 "glslang/MachineIndependent/preprocessor/PpTokens.h",
178 "glslang/MachineIndependent/propagateNoContraction.cpp",
179 "glslang/MachineIndependent/propagateNoContraction.h",
180 "glslang/MachineIndependent/reflection.cpp",
181 "glslang/MachineIndependent/reflection.h",
182 "glslang/OSDependent/osinclude.h",
183 "glslang/Public/ShaderLang.h",
186 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
189 "glslang/HLSL/hlslParseHelper.h",
190 "glslang/HLSL/hlslParseables.h",
191 "glslang/HLSL/hlslScanContext.h",
192 "glslang/HLSL/hlslTokens.h",
195 if (invoker.enable_hlsl) {
197 "glslang/HLSL/hlslAttributes.cpp",
198 "glslang/HLSL/hlslAttributes.h",
199 "glslang/HLSL/hlslGrammar.cpp",
200 "glslang/HLSL/hlslGrammar.h",
201 "glslang/HLSL/hlslOpMap.cpp",
202 "glslang/HLSL/hlslOpMap.h",
203 "glslang/HLSL/hlslParseHelper.cpp",
204 "glslang/HLSL/hlslParseables.cpp",
205 "glslang/HLSL/hlslScanContext.cpp",
206 "glslang/HLSL/hlslTokenStream.cpp",
207 "glslang/HLSL/hlslTokenStream.h",
212 if (invoker.enable_opt) {
213 sources += [ "SPIRV/SpvTools.cpp" ]
214 defines += [ "ENABLE_OPT=1" ]
216 if (invoker.is_angle) {
217 defines += [ "GLSLANG_ANGLE" ]
221 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
222 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
224 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
225 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
231 "-Wno-ignored-qualifiers",
232 "-Wno-implicit-fallthrough",
233 "-Wno-inconsistent-missing-override",
234 "-Wno-missing-field-initializers",
237 "-Wno-suggest-destructor-override",
238 "-Wno-suggest-override",
239 "-Wno-unused-variable",
242 if (is_win && !is_clang) {
244 "/wd4018", # signed/unsigned mismatch
245 "/wd4189", # local variable is initialized but not referenced
249 include_dirs = [ "${target_gen_dir}/include" ]
251 deps = [ ":glslang_build_info" ]
253 if (invoker.enable_opt) {
255 "${spirv_tools_dir}:spvtools_opt",
256 "${spirv_tools_dir}:spvtools_val",
258 include_dirs += [ "${spirv_tools_dir}/include" ]
261 configs -= _configs_to_remove
262 configs += _configs_to_add
266 glslang_sources_common("glslang_lib_sources") {
267 enable_opt = !glslang_angle
268 enable_hlsl = !glslang_angle
269 is_angle = glslang_angle
272 glslang_sources_common("glslang_sources") {
278 source_set("glslang_default_resource_limits_sources") {
280 "StandAlone/ResourceLimits.cpp",
281 "StandAlone/ResourceLimits.h",
282 "glslang/Include/ResourceLimits.h",
284 public_configs = [ ":glslang_public" ]
286 configs -= _configs_to_remove
287 configs += _configs_to_add
290 executable("glslang_validator") {
292 "StandAlone/DirStackFileIncluder.h",
293 "StandAlone/StandAlone.cpp",
296 cflags = [ "-Woverflow" ]
298 defines = [ "ENABLE_OPT=1" ]
300 ":glslang_build_info",
301 ":glslang_default_resource_limits_sources",
304 public_configs = [ ":glslang_hlsl" ]
307 "${target_gen_dir}/include",
308 "${spirv_tools_dir}/include",
311 configs -= _configs_to_remove
312 configs += _configs_to_add
315 executable("spirv-remap") {
316 sources = [ "StandAlone/spirv-remap.cpp" ]
317 defines = [ "ENABLE_OPT=1" ]
318 deps = [ ":glslang_sources" ]
320 include_dirs = [ "${spirv_tools_dir}/include" ]
322 configs -= _configs_to_remove
323 configs += _configs_to_add