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 action("glslang_extension_headers") {
73 script = "gen_extension_headers.py"
75 out_file = "${target_gen_dir}/include/glslang/glsl_intrinsic_header.h"
80 outputs = [ out_file ]
83 rebase_path("glslang/ExtensionHeaders", root_build_dir),
85 rebase_path(out_file, root_build_dir),
89 spirv_tools_dir = glslang_spirv_tools_dir
90 if (!defined(glslang_angle)) {
94 config("glslang_public") {
95 include_dirs = [ "." ]
96 if (!is_win || is_clang) {
97 cflags = [ "-Wno-conversion" ]
101 config("glslang_hlsl") {
102 defines = [ "ENABLE_HLSL=1" ]
105 template("glslang_sources_common") {
106 source_set(target_name) {
107 public_configs = [ ":glslang_public" ]
109 if (invoker.enable_hlsl) {
110 public_configs += [ ":glslang_hlsl" ]
114 "OGLCompilersDLL/InitializeDll.cpp",
115 "OGLCompilersDLL/InitializeDll.h",
116 "SPIRV/GLSL.ext.AMD.h",
117 "SPIRV/GLSL.ext.EXT.h",
118 "SPIRV/GLSL.ext.KHR.h",
119 "SPIRV/GLSL.ext.NV.h",
120 "SPIRV/GLSL.std.450.h",
121 "SPIRV/GlslangToSpv.cpp",
122 "SPIRV/GlslangToSpv.h",
123 "SPIRV/InReadableOrder.cpp",
126 "SPIRV/NonSemanticDebugPrintf.h",
127 "SPIRV/SPVRemapper.cpp",
128 "SPIRV/SPVRemapper.h",
129 "SPIRV/SpvBuilder.cpp",
130 "SPIRV/SpvBuilder.h",
131 "SPIRV/SpvPostProcess.cpp",
134 "SPIRV/disassemble.cpp",
135 "SPIRV/disassemble.h",
141 "glslang/GenericCodeGen/CodeGen.cpp",
142 "glslang/GenericCodeGen/Link.cpp",
143 "glslang/Include/BaseTypes.h",
144 "glslang/Include/Common.h",
145 "glslang/Include/ConstantUnion.h",
146 "glslang/Include/InfoSink.h",
147 "glslang/Include/InitializeGlobals.h",
148 "glslang/Include/PoolAlloc.h",
149 "glslang/Include/ResourceLimits.h",
150 "glslang/Include/ShHandle.h",
151 "glslang/Include/SpirvIntrinsics.h",
152 "glslang/Include/Types.h",
153 "glslang/Include/arrays.h",
154 "glslang/Include/intermediate.h",
155 "glslang/MachineIndependent/Constant.cpp",
156 "glslang/MachineIndependent/InfoSink.cpp",
157 "glslang/MachineIndependent/Initialize.cpp",
158 "glslang/MachineIndependent/Initialize.h",
159 "glslang/MachineIndependent/IntermTraverse.cpp",
160 "glslang/MachineIndependent/Intermediate.cpp",
161 "glslang/MachineIndependent/LiveTraverser.h",
162 "glslang/MachineIndependent/ParseContextBase.cpp",
163 "glslang/MachineIndependent/ParseHelper.cpp",
164 "glslang/MachineIndependent/ParseHelper.h",
165 "glslang/MachineIndependent/PoolAlloc.cpp",
166 "glslang/MachineIndependent/RemoveTree.cpp",
167 "glslang/MachineIndependent/RemoveTree.h",
168 "glslang/MachineIndependent/Scan.cpp",
169 "glslang/MachineIndependent/Scan.h",
170 "glslang/MachineIndependent/ScanContext.h",
171 "glslang/MachineIndependent/ShaderLang.cpp",
172 "glslang/MachineIndependent/SpirvIntrinsics.cpp",
173 "glslang/MachineIndependent/SymbolTable.cpp",
174 "glslang/MachineIndependent/SymbolTable.h",
175 "glslang/MachineIndependent/Versions.cpp",
176 "glslang/MachineIndependent/Versions.h",
177 "glslang/MachineIndependent/attribute.cpp",
178 "glslang/MachineIndependent/attribute.h",
179 "glslang/MachineIndependent/gl_types.h",
180 "glslang/MachineIndependent/glslang_tab.cpp",
181 "glslang/MachineIndependent/glslang_tab.cpp.h",
182 "glslang/MachineIndependent/intermOut.cpp",
183 "glslang/MachineIndependent/iomapper.cpp",
184 "glslang/MachineIndependent/iomapper.h",
185 "glslang/MachineIndependent/limits.cpp",
186 "glslang/MachineIndependent/linkValidate.cpp",
187 "glslang/MachineIndependent/localintermediate.h",
188 "glslang/MachineIndependent/parseConst.cpp",
189 "glslang/MachineIndependent/parseVersions.h",
190 "glslang/MachineIndependent/preprocessor/Pp.cpp",
191 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
192 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
193 "glslang/MachineIndependent/preprocessor/PpContext.h",
194 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
195 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
196 "glslang/MachineIndependent/preprocessor/PpTokens.h",
197 "glslang/MachineIndependent/propagateNoContraction.cpp",
198 "glslang/MachineIndependent/propagateNoContraction.h",
199 "glslang/MachineIndependent/reflection.cpp",
200 "glslang/MachineIndependent/reflection.h",
201 "glslang/OSDependent/osinclude.h",
202 "glslang/Public/ShaderLang.h",
205 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
208 "glslang/HLSL/hlslParseHelper.h",
209 "glslang/HLSL/hlslParseables.h",
210 "glslang/HLSL/hlslScanContext.h",
211 "glslang/HLSL/hlslTokens.h",
214 if (invoker.enable_hlsl) {
216 "glslang/HLSL/hlslAttributes.cpp",
217 "glslang/HLSL/hlslAttributes.h",
218 "glslang/HLSL/hlslGrammar.cpp",
219 "glslang/HLSL/hlslGrammar.h",
220 "glslang/HLSL/hlslOpMap.cpp",
221 "glslang/HLSL/hlslOpMap.h",
222 "glslang/HLSL/hlslParseHelper.cpp",
223 "glslang/HLSL/hlslParseables.cpp",
224 "glslang/HLSL/hlslScanContext.cpp",
225 "glslang/HLSL/hlslTokenStream.cpp",
226 "glslang/HLSL/hlslTokenStream.h",
231 if (invoker.enable_opt) {
232 sources += [ "SPIRV/SpvTools.cpp" ]
233 defines += [ "ENABLE_OPT=1" ]
235 if (invoker.is_angle) {
236 defines += [ "GLSLANG_ANGLE" ]
240 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
241 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
243 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
244 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
250 "-Wno-ignored-qualifiers",
251 "-Wno-implicit-fallthrough",
252 "-Wno-inconsistent-missing-override",
253 "-Wno-missing-field-initializers",
256 "-Wno-suggest-destructor-override",
257 "-Wno-suggest-override",
258 "-Wno-unused-variable",
261 if (is_win && !is_clang) {
263 "/wd4018", # signed/unsigned mismatch
264 "/wd4189", # local variable is initialized but not referenced
268 include_dirs = [ "${target_gen_dir}/include" ]
270 deps = [ ":glslang_build_info" ]
272 if (invoker.enable_opt) {
274 "${spirv_tools_dir}:spvtools_opt",
275 "${spirv_tools_dir}:spvtools_val",
277 include_dirs += [ "${spirv_tools_dir}/include" ]
280 configs -= _configs_to_remove
281 configs += _configs_to_add
285 glslang_sources_common("glslang_lib_sources") {
286 enable_opt = !glslang_angle
287 enable_hlsl = !glslang_angle
288 is_angle = glslang_angle
291 glslang_sources_common("glslang_sources") {
297 source_set("glslang_default_resource_limits_sources") {
299 "StandAlone/ResourceLimits.cpp",
300 "StandAlone/ResourceLimits.h",
301 "glslang/Include/ResourceLimits.h",
303 public_configs = [ ":glslang_public" ]
305 configs -= _configs_to_remove
306 configs += _configs_to_add
309 executable("glslang_validator") {
311 "StandAlone/DirStackFileIncluder.h",
312 "StandAlone/StandAlone.cpp",
315 cflags = [ "-Woverflow" ]
317 defines = [ "ENABLE_OPT=1" ]
319 ":glslang_build_info",
320 ":glslang_default_resource_limits_sources",
322 ":glslang_extension_headers",
324 public_configs = [ ":glslang_hlsl" ]
327 "${target_gen_dir}/include",
328 "${spirv_tools_dir}/include",
331 configs -= _configs_to_remove
332 configs += _configs_to_add
335 executable("spirv-remap") {
336 sources = [ "StandAlone/spirv-remap.cpp" ]
337 defines = [ "ENABLE_OPT=1" ]
338 deps = [ ":glslang_sources" ]
340 include_dirs = [ "${spirv_tools_dir}/include" ]
342 configs -= _configs_to_remove
343 configs += _configs_to_add