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"
77 # Fuchsia GN build rules require all GN actions to be hermetic and they
78 # should correctly and fully state their inputs and outpus (see
79 # https://fuchsia.dev/fuchsia-src/development/build/hermetic_actions
80 # for details). All input files of the script should be added to the
83 "glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl",
89 outputs = [ out_file ]
92 rebase_path("glslang/ExtensionHeaders", root_build_dir),
94 rebase_path(out_file, root_build_dir),
98 spirv_tools_dir = glslang_spirv_tools_dir
99 if (!defined(glslang_angle)) {
100 glslang_angle = false
103 config("glslang_public") {
104 include_dirs = [ "." ]
105 if (!is_win || is_clang) {
106 cflags = [ "-Wno-conversion" ]
110 config("glslang_hlsl") {
111 defines = [ "ENABLE_HLSL=1" ]
114 template("glslang_sources_common") {
115 source_set(target_name) {
116 public_configs = [ ":glslang_public" ]
118 if (invoker.enable_hlsl) {
119 public_configs += [ ":glslang_hlsl" ]
123 "OGLCompilersDLL/InitializeDll.cpp",
124 "OGLCompilersDLL/InitializeDll.h",
125 "SPIRV/GLSL.ext.AMD.h",
126 "SPIRV/GLSL.ext.EXT.h",
127 "SPIRV/GLSL.ext.KHR.h",
128 "SPIRV/GLSL.ext.NV.h",
129 "SPIRV/GLSL.std.450.h",
130 "SPIRV/GlslangToSpv.cpp",
131 "SPIRV/GlslangToSpv.h",
132 "SPIRV/InReadableOrder.cpp",
135 "SPIRV/NonSemanticDebugPrintf.h",
136 "SPIRV/NonSemanticShaderDebugInfo100.h",
137 "SPIRV/SPVRemapper.cpp",
138 "SPIRV/SPVRemapper.h",
139 "SPIRV/SpvBuilder.cpp",
140 "SPIRV/SpvBuilder.h",
141 "SPIRV/SpvPostProcess.cpp",
144 "SPIRV/disassemble.cpp",
145 "SPIRV/disassemble.h",
151 "glslang/GenericCodeGen/CodeGen.cpp",
152 "glslang/GenericCodeGen/Link.cpp",
153 "glslang/Include/BaseTypes.h",
154 "glslang/Include/Common.h",
155 "glslang/Include/ConstantUnion.h",
156 "glslang/Include/InfoSink.h",
157 "glslang/Include/InitializeGlobals.h",
158 "glslang/Include/PoolAlloc.h",
159 "glslang/Include/ResourceLimits.h",
160 "glslang/Include/ShHandle.h",
161 "glslang/Include/SpirvIntrinsics.h",
162 "glslang/Include/Types.h",
163 "glslang/Include/arrays.h",
164 "glslang/Include/intermediate.h",
165 "glslang/MachineIndependent/Constant.cpp",
166 "glslang/MachineIndependent/InfoSink.cpp",
167 "glslang/MachineIndependent/Initialize.cpp",
168 "glslang/MachineIndependent/Initialize.h",
169 "glslang/MachineIndependent/IntermTraverse.cpp",
170 "glslang/MachineIndependent/Intermediate.cpp",
171 "glslang/MachineIndependent/LiveTraverser.h",
172 "glslang/MachineIndependent/ParseContextBase.cpp",
173 "glslang/MachineIndependent/ParseHelper.cpp",
174 "glslang/MachineIndependent/ParseHelper.h",
175 "glslang/MachineIndependent/PoolAlloc.cpp",
176 "glslang/MachineIndependent/RemoveTree.cpp",
177 "glslang/MachineIndependent/RemoveTree.h",
178 "glslang/MachineIndependent/Scan.cpp",
179 "glslang/MachineIndependent/Scan.h",
180 "glslang/MachineIndependent/ScanContext.h",
181 "glslang/MachineIndependent/ShaderLang.cpp",
182 "glslang/MachineIndependent/SpirvIntrinsics.cpp",
183 "glslang/MachineIndependent/SymbolTable.cpp",
184 "glslang/MachineIndependent/SymbolTable.h",
185 "glslang/MachineIndependent/Versions.cpp",
186 "glslang/MachineIndependent/Versions.h",
187 "glslang/MachineIndependent/attribute.cpp",
188 "glslang/MachineIndependent/attribute.h",
189 "glslang/MachineIndependent/gl_types.h",
190 "glslang/MachineIndependent/glslang_tab.cpp",
191 "glslang/MachineIndependent/glslang_tab.cpp.h",
192 "glslang/MachineIndependent/intermOut.cpp",
193 "glslang/MachineIndependent/iomapper.cpp",
194 "glslang/MachineIndependent/iomapper.h",
195 "glslang/MachineIndependent/limits.cpp",
196 "glslang/MachineIndependent/linkValidate.cpp",
197 "glslang/MachineIndependent/localintermediate.h",
198 "glslang/MachineIndependent/parseConst.cpp",
199 "glslang/MachineIndependent/parseVersions.h",
200 "glslang/MachineIndependent/preprocessor/Pp.cpp",
201 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
202 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
203 "glslang/MachineIndependent/preprocessor/PpContext.h",
204 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
205 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
206 "glslang/MachineIndependent/preprocessor/PpTokens.h",
207 "glslang/MachineIndependent/propagateNoContraction.cpp",
208 "glslang/MachineIndependent/propagateNoContraction.h",
209 "glslang/MachineIndependent/reflection.cpp",
210 "glslang/MachineIndependent/reflection.h",
211 "glslang/OSDependent/osinclude.h",
212 "glslang/Public/ShaderLang.h",
215 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
218 "glslang/HLSL/hlslParseHelper.h",
219 "glslang/HLSL/hlslParseables.h",
220 "glslang/HLSL/hlslScanContext.h",
221 "glslang/HLSL/hlslTokens.h",
224 if (invoker.enable_hlsl) {
226 "glslang/HLSL/hlslAttributes.cpp",
227 "glslang/HLSL/hlslAttributes.h",
228 "glslang/HLSL/hlslGrammar.cpp",
229 "glslang/HLSL/hlslGrammar.h",
230 "glslang/HLSL/hlslOpMap.cpp",
231 "glslang/HLSL/hlslOpMap.h",
232 "glslang/HLSL/hlslParseHelper.cpp",
233 "glslang/HLSL/hlslParseables.cpp",
234 "glslang/HLSL/hlslScanContext.cpp",
235 "glslang/HLSL/hlslTokenStream.cpp",
236 "glslang/HLSL/hlslTokenStream.h",
241 if (invoker.enable_opt) {
242 sources += [ "SPIRV/SpvTools.cpp" ]
243 defines += [ "ENABLE_OPT=1" ]
245 if (invoker.is_angle) {
246 defines += [ "GLSLANG_ANGLE" ]
250 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
251 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
253 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
254 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
260 "-Wno-ignored-qualifiers",
261 "-Wno-implicit-fallthrough",
262 "-Wno-inconsistent-missing-override",
263 "-Wno-missing-field-initializers",
266 "-Wno-suggest-destructor-override",
267 "-Wno-suggest-override",
268 "-Wno-unused-variable",
271 if (is_win && !is_clang) {
273 "/wd4018", # signed/unsigned mismatch
274 "/wd4189", # local variable is initialized but not referenced
278 include_dirs = [ "${target_gen_dir}/include" ]
280 deps = [ ":glslang_build_info" ]
282 if (invoker.enable_opt) {
284 "${spirv_tools_dir}:spvtools_opt",
285 "${spirv_tools_dir}:spvtools_val",
287 include_dirs += [ "${spirv_tools_dir}/include" ]
290 configs -= _configs_to_remove
291 configs += _configs_to_add
295 glslang_sources_common("glslang_lib_sources") {
296 enable_opt = !glslang_angle
297 enable_hlsl = !glslang_angle
298 is_angle = glslang_angle
301 glslang_sources_common("glslang_sources") {
307 source_set("glslang_default_resource_limits_sources") {
309 "StandAlone/ResourceLimits.cpp",
310 "StandAlone/ResourceLimits.h",
311 "glslang/Include/ResourceLimits.h",
313 public_configs = [ ":glslang_public" ]
315 configs -= _configs_to_remove
316 configs += _configs_to_add
319 executable("glslang_validator") {
321 "StandAlone/DirStackFileIncluder.h",
322 "StandAlone/StandAlone.cpp",
325 cflags = [ "-Woverflow" ]
327 defines = [ "ENABLE_OPT=1" ]
329 ":glslang_build_info",
330 ":glslang_default_resource_limits_sources",
332 ":glslang_extension_headers",
334 public_configs = [ ":glslang_hlsl" ]
337 "${target_gen_dir}/include",
338 "${spirv_tools_dir}/include",
341 configs -= _configs_to_remove
342 configs += _configs_to_add
345 executable("spirv-remap") {
346 sources = [ "StandAlone/spirv-remap.cpp" ]
347 defines = [ "ENABLE_OPT=1" ]
348 deps = [ ":glslang_sources" ]
350 include_dirs = [ "${spirv_tools_dir}/include" ]
352 configs -= _configs_to_remove
353 configs += _configs_to_add