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
100 config("glslang_public") {
101 include_dirs = [ "." ]
102 if (!is_win || is_clang) {
103 cflags = [ "-Wno-conversion" ]
107 config("glslang_hlsl") {
108 defines = [ "ENABLE_HLSL=1" ]
111 template("glslang_sources_common") {
112 source_set(target_name) {
113 public_configs = [ ":glslang_public" ]
115 if (invoker.enable_hlsl) {
116 public_configs += [ ":glslang_hlsl" ]
120 "OGLCompilersDLL/InitializeDll.cpp",
121 "OGLCompilersDLL/InitializeDll.h",
122 "SPIRV/GLSL.ext.AMD.h",
123 "SPIRV/GLSL.ext.EXT.h",
124 "SPIRV/GLSL.ext.KHR.h",
125 "SPIRV/GLSL.ext.NV.h",
126 "SPIRV/GLSL.std.450.h",
127 "SPIRV/GlslangToSpv.cpp",
128 "SPIRV/GlslangToSpv.h",
129 "SPIRV/InReadableOrder.cpp",
132 "SPIRV/NonSemanticDebugPrintf.h",
133 "SPIRV/NonSemanticShaderDebugInfo100.h",
134 "SPIRV/SPVRemapper.cpp",
135 "SPIRV/SPVRemapper.h",
136 "SPIRV/SpvBuilder.cpp",
137 "SPIRV/SpvBuilder.h",
138 "SPIRV/SpvPostProcess.cpp",
141 "SPIRV/disassemble.cpp",
142 "SPIRV/disassemble.h",
148 "glslang/GenericCodeGen/CodeGen.cpp",
149 "glslang/GenericCodeGen/Link.cpp",
150 "glslang/Include/BaseTypes.h",
151 "glslang/Include/Common.h",
152 "glslang/Include/ConstantUnion.h",
153 "glslang/Include/InfoSink.h",
154 "glslang/Include/InitializeGlobals.h",
155 "glslang/Include/PoolAlloc.h",
156 "glslang/Include/ResourceLimits.h",
157 "glslang/Include/ShHandle.h",
158 "glslang/Include/SpirvIntrinsics.h",
159 "glslang/Include/Types.h",
160 "glslang/Include/arrays.h",
161 "glslang/Include/intermediate.h",
162 "glslang/MachineIndependent/Constant.cpp",
163 "glslang/MachineIndependent/InfoSink.cpp",
164 "glslang/MachineIndependent/Initialize.cpp",
165 "glslang/MachineIndependent/Initialize.h",
166 "glslang/MachineIndependent/IntermTraverse.cpp",
167 "glslang/MachineIndependent/Intermediate.cpp",
168 "glslang/MachineIndependent/LiveTraverser.h",
169 "glslang/MachineIndependent/ParseContextBase.cpp",
170 "glslang/MachineIndependent/ParseHelper.cpp",
171 "glslang/MachineIndependent/ParseHelper.h",
172 "glslang/MachineIndependent/PoolAlloc.cpp",
173 "glslang/MachineIndependent/RemoveTree.cpp",
174 "glslang/MachineIndependent/RemoveTree.h",
175 "glslang/MachineIndependent/Scan.cpp",
176 "glslang/MachineIndependent/Scan.h",
177 "glslang/MachineIndependent/ScanContext.h",
178 "glslang/MachineIndependent/ShaderLang.cpp",
179 "glslang/MachineIndependent/SpirvIntrinsics.cpp",
180 "glslang/MachineIndependent/SymbolTable.cpp",
181 "glslang/MachineIndependent/SymbolTable.h",
182 "glslang/MachineIndependent/Versions.cpp",
183 "glslang/MachineIndependent/Versions.h",
184 "glslang/MachineIndependent/attribute.cpp",
185 "glslang/MachineIndependent/attribute.h",
186 "glslang/MachineIndependent/gl_types.h",
187 "glslang/MachineIndependent/glslang_tab.cpp",
188 "glslang/MachineIndependent/glslang_tab.cpp.h",
189 "glslang/MachineIndependent/intermOut.cpp",
190 "glslang/MachineIndependent/iomapper.cpp",
191 "glslang/MachineIndependent/iomapper.h",
192 "glslang/MachineIndependent/limits.cpp",
193 "glslang/MachineIndependent/linkValidate.cpp",
194 "glslang/MachineIndependent/localintermediate.h",
195 "glslang/MachineIndependent/parseConst.cpp",
196 "glslang/MachineIndependent/parseVersions.h",
197 "glslang/MachineIndependent/preprocessor/Pp.cpp",
198 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
199 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
200 "glslang/MachineIndependent/preprocessor/PpContext.h",
201 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
202 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
203 "glslang/MachineIndependent/preprocessor/PpTokens.h",
204 "glslang/MachineIndependent/propagateNoContraction.cpp",
205 "glslang/MachineIndependent/propagateNoContraction.h",
206 "glslang/MachineIndependent/reflection.cpp",
207 "glslang/MachineIndependent/reflection.h",
208 "glslang/OSDependent/osinclude.h",
209 "glslang/Public/ShaderLang.h",
212 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
215 "glslang/HLSL/hlslParseHelper.h",
216 "glslang/HLSL/hlslParseables.h",
217 "glslang/HLSL/hlslScanContext.h",
218 "glslang/HLSL/hlslTokens.h",
221 if (invoker.enable_hlsl) {
223 "glslang/HLSL/hlslAttributes.cpp",
224 "glslang/HLSL/hlslAttributes.h",
225 "glslang/HLSL/hlslGrammar.cpp",
226 "glslang/HLSL/hlslGrammar.h",
227 "glslang/HLSL/hlslOpMap.cpp",
228 "glslang/HLSL/hlslOpMap.h",
229 "glslang/HLSL/hlslParseHelper.cpp",
230 "glslang/HLSL/hlslParseables.cpp",
231 "glslang/HLSL/hlslScanContext.cpp",
232 "glslang/HLSL/hlslTokenStream.cpp",
233 "glslang/HLSL/hlslTokenStream.h",
238 if (invoker.enable_opt) {
239 sources += [ "SPIRV/SpvTools.cpp" ]
240 defines += [ "ENABLE_OPT=1" ]
244 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
245 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
247 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
248 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
254 "-Wno-ignored-qualifiers",
255 "-Wno-implicit-fallthrough",
256 "-Wno-inconsistent-missing-override",
257 "-Wno-missing-field-initializers",
260 "-Wno-suggest-destructor-override",
261 "-Wno-suggest-override",
262 "-Wno-unused-variable",
265 if (is_win && !is_clang) {
267 "/wd4018", # signed/unsigned mismatch
268 "/wd4189", # local variable is initialized but not referenced
272 include_dirs = [ "${target_gen_dir}/include" ]
274 deps = [ ":glslang_build_info" ]
276 if (invoker.enable_opt) {
278 "${spirv_tools_dir}:spvtools_opt",
279 "${spirv_tools_dir}:spvtools_val",
281 include_dirs += [ "${spirv_tools_dir}/include" ]
284 configs -= _configs_to_remove
285 configs += _configs_to_add
289 glslang_sources_common("glslang_lib_sources") {
294 glslang_sources_common("glslang_sources") {
299 source_set("glslang_default_resource_limits_sources") {
301 "StandAlone/ResourceLimits.cpp",
302 "glslang/Public/ResourceLimits.h",
303 "glslang/Include/ResourceLimits.h",
305 public_configs = [ ":glslang_public" ]
307 configs -= _configs_to_remove
308 configs += _configs_to_add
311 executable("glslang_validator") {
313 "StandAlone/DirStackFileIncluder.h",
314 "StandAlone/StandAlone.cpp",
317 cflags = [ "-Woverflow" ]
319 defines = [ "ENABLE_OPT=1" ]
321 ":glslang_build_info",
322 ":glslang_default_resource_limits_sources",
324 ":glslang_extension_headers",
326 public_configs = [ ":glslang_hlsl" ]
329 "${target_gen_dir}/include",
330 "${spirv_tools_dir}/include",
333 configs -= _configs_to_remove
334 configs += _configs_to_add
337 executable("spirv-remap") {
338 sources = [ "StandAlone/spirv-remap.cpp" ]
339 defines = [ "ENABLE_OPT=1" ]
340 deps = [ ":glslang_sources" ]
342 include_dirs = [ "${spirv_tools_dir}/include" ]
344 configs -= _configs_to_remove
345 configs += _configs_to_add