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"
66 rebase_path(src_dir, root_build_dir),
67 "-i", rebase_path(template_file, root_build_dir),
68 "-o", 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 = [ "." ]
81 config("glslang_hlsl") {
82 defines = [ "ENABLE_HLSL=1" ]
85 template("glslang_sources_common") {
86 source_set(target_name) {
87 public_configs = [ ":glslang_public" ]
89 if (invoker.enable_hlsl) {
90 public_configs += [ ":glslang_hlsl" ]
94 "OGLCompilersDLL/InitializeDll.cpp",
95 "OGLCompilersDLL/InitializeDll.h",
96 "SPIRV/GLSL.ext.AMD.h",
97 "SPIRV/GLSL.ext.EXT.h",
98 "SPIRV/GLSL.ext.KHR.h",
99 "SPIRV/GLSL.ext.NV.h",
100 "SPIRV/GLSL.std.450.h",
101 "SPIRV/GlslangToSpv.cpp",
102 "SPIRV/GlslangToSpv.h",
103 "SPIRV/InReadableOrder.cpp",
106 "SPIRV/NonSemanticDebugPrintf.h",
107 "SPIRV/SPVRemapper.cpp",
108 "SPIRV/SPVRemapper.h",
109 "SPIRV/SpvBuilder.cpp",
110 "SPIRV/SpvBuilder.h",
111 "SPIRV/SpvPostProcess.cpp",
112 "SPIRV/SpvTools.cpp",
115 "SPIRV/disassemble.cpp",
116 "SPIRV/disassemble.h",
122 "glslang/GenericCodeGen/CodeGen.cpp",
123 "glslang/GenericCodeGen/Link.cpp",
124 "glslang/Include/BaseTypes.h",
125 "glslang/Include/Common.h",
126 "glslang/Include/ConstantUnion.h",
127 "glslang/Include/InfoSink.h",
128 "glslang/Include/InitializeGlobals.h",
129 "glslang/Include/PoolAlloc.h",
130 "glslang/Include/ResourceLimits.h",
131 "glslang/Include/ShHandle.h",
132 "glslang/Include/Types.h",
133 "glslang/Include/arrays.h",
134 "glslang/Include/intermediate.h",
135 "glslang/MachineIndependent/Constant.cpp",
136 "glslang/MachineIndependent/InfoSink.cpp",
137 "glslang/MachineIndependent/Initialize.cpp",
138 "glslang/MachineIndependent/Initialize.h",
139 "glslang/MachineIndependent/IntermTraverse.cpp",
140 "glslang/MachineIndependent/Intermediate.cpp",
141 "glslang/MachineIndependent/LiveTraverser.h",
142 "glslang/MachineIndependent/ParseContextBase.cpp",
143 "glslang/MachineIndependent/ParseHelper.cpp",
144 "glslang/MachineIndependent/ParseHelper.h",
145 "glslang/MachineIndependent/PoolAlloc.cpp",
146 "glslang/MachineIndependent/RemoveTree.cpp",
147 "glslang/MachineIndependent/RemoveTree.h",
148 "glslang/MachineIndependent/Scan.cpp",
149 "glslang/MachineIndependent/Scan.h",
150 "glslang/MachineIndependent/ScanContext.h",
151 "glslang/MachineIndependent/ShaderLang.cpp",
152 "glslang/MachineIndependent/SymbolTable.cpp",
153 "glslang/MachineIndependent/SymbolTable.h",
154 "glslang/MachineIndependent/Versions.cpp",
155 "glslang/MachineIndependent/Versions.h",
156 "glslang/MachineIndependent/attribute.cpp",
157 "glslang/MachineIndependent/attribute.h",
158 "glslang/MachineIndependent/gl_types.h",
159 "glslang/MachineIndependent/glslang_tab.cpp",
160 "glslang/MachineIndependent/glslang_tab.cpp.h",
161 "glslang/MachineIndependent/intermOut.cpp",
162 "glslang/MachineIndependent/iomapper.cpp",
163 "glslang/MachineIndependent/iomapper.h",
164 "glslang/MachineIndependent/limits.cpp",
165 "glslang/MachineIndependent/linkValidate.cpp",
166 "glslang/MachineIndependent/localintermediate.h",
167 "glslang/MachineIndependent/parseConst.cpp",
168 "glslang/MachineIndependent/parseVersions.h",
169 "glslang/MachineIndependent/preprocessor/Pp.cpp",
170 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
171 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
172 "glslang/MachineIndependent/preprocessor/PpContext.h",
173 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
174 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
175 "glslang/MachineIndependent/preprocessor/PpTokens.h",
176 "glslang/MachineIndependent/propagateNoContraction.cpp",
177 "glslang/MachineIndependent/propagateNoContraction.h",
178 "glslang/MachineIndependent/reflection.cpp",
179 "glslang/MachineIndependent/reflection.h",
180 "glslang/OSDependent/osinclude.h",
181 "glslang/Public/ShaderLang.h",
184 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
187 "glslang/HLSL/hlslParseHelper.h",
188 "glslang/HLSL/hlslParseables.h",
189 "glslang/HLSL/hlslScanContext.h",
190 "glslang/HLSL/hlslTokens.h",
193 if (invoker.enable_hlsl) {
195 "glslang/HLSL/hlslAttributes.cpp",
196 "glslang/HLSL/hlslAttributes.h",
197 "glslang/HLSL/hlslGrammar.cpp",
198 "glslang/HLSL/hlslGrammar.h",
199 "glslang/HLSL/hlslOpMap.cpp",
200 "glslang/HLSL/hlslOpMap.h",
201 "glslang/HLSL/hlslParseHelper.cpp",
202 "glslang/HLSL/hlslParseables.cpp",
203 "glslang/HLSL/hlslScanContext.cpp",
204 "glslang/HLSL/hlslTokenStream.cpp",
205 "glslang/HLSL/hlslTokenStream.h",
210 if (invoker.enable_opt) {
211 defines += [ "ENABLE_OPT=1" ]
215 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
216 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
218 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
219 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
225 "-Wno-ignored-qualifiers",
226 "-Wno-implicit-fallthrough",
227 "-Wno-inconsistent-missing-override",
229 "-Wno-unused-variable",
230 "-Wno-missing-field-initializers",
234 if (is_win && !is_clang) {
236 "/wd4018", # signed/unsigned mismatch
237 "/wd4189", # local variable is initialized but not referenced
241 deps = [ ":glslang_build_info" ]
243 if (invoker.enable_opt) {
245 "${spirv_tools_dir}:spvtools_opt",
246 "${spirv_tools_dir}:spvtools_val",
250 include_dirs = [ "${target_gen_dir}/include" ]
252 configs -= _configs_to_remove
253 configs += _configs_to_add
257 glslang_sources_common("glslang_lib_sources") {
258 enable_opt = !glslang_angle
259 enable_hlsl = !glslang_angle
262 glslang_sources_common("glslang_sources") {
267 source_set("glslang_default_resource_limits_sources") {
269 "StandAlone/ResourceLimits.cpp",
270 "StandAlone/ResourceLimits.h",
271 "glslang/Include/ResourceLimits.h",
273 public_configs = [ ":glslang_public" ]
275 configs -= _configs_to_remove
276 configs += _configs_to_add
279 executable("glslang_validator") {
281 "StandAlone/DirStackFileIncluder.h",
282 "StandAlone/StandAlone.cpp",
285 cflags = [ "-Woverflow" ]
287 defines = [ "ENABLE_OPT=1" ]
289 ":glslang_default_resource_limits_sources",
291 ":glslang_build_info",
293 public_configs = [ ":glslang_hlsl" ]
295 include_dirs = [ "${target_gen_dir}/include" ]
297 configs -= _configs_to_remove
298 configs += _configs_to_add
301 executable("spirv-remap") {
302 sources = [ "StandAlone/spirv-remap.cpp" ]
303 defines = [ "ENABLE_OPT=1" ]
304 deps = [ ":glslang_sources" ]
306 configs -= _configs_to_remove
307 configs += _configs_to_add