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/SpirvIntrinsics.h",
135 "glslang/Include/Types.h",
136 "glslang/Include/arrays.h",
137 "glslang/Include/intermediate.h",
138 "glslang/MachineIndependent/Constant.cpp",
139 "glslang/MachineIndependent/InfoSink.cpp",
140 "glslang/MachineIndependent/Initialize.cpp",
141 "glslang/MachineIndependent/Initialize.h",
142 "glslang/MachineIndependent/IntermTraverse.cpp",
143 "glslang/MachineIndependent/Intermediate.cpp",
144 "glslang/MachineIndependent/LiveTraverser.h",
145 "glslang/MachineIndependent/ParseContextBase.cpp",
146 "glslang/MachineIndependent/ParseHelper.cpp",
147 "glslang/MachineIndependent/ParseHelper.h",
148 "glslang/MachineIndependent/PoolAlloc.cpp",
149 "glslang/MachineIndependent/RemoveTree.cpp",
150 "glslang/MachineIndependent/RemoveTree.h",
151 "glslang/MachineIndependent/Scan.cpp",
152 "glslang/MachineIndependent/Scan.h",
153 "glslang/MachineIndependent/ScanContext.h",
154 "glslang/MachineIndependent/ShaderLang.cpp",
155 "glslang/MachineIndependent/SpirvIntrinsics.cpp",
156 "glslang/MachineIndependent/SymbolTable.cpp",
157 "glslang/MachineIndependent/SymbolTable.h",
158 "glslang/MachineIndependent/Versions.cpp",
159 "glslang/MachineIndependent/Versions.h",
160 "glslang/MachineIndependent/attribute.cpp",
161 "glslang/MachineIndependent/attribute.h",
162 "glslang/MachineIndependent/gl_types.h",
163 "glslang/MachineIndependent/glslang_tab.cpp",
164 "glslang/MachineIndependent/glslang_tab.cpp.h",
165 "glslang/MachineIndependent/intermOut.cpp",
166 "glslang/MachineIndependent/iomapper.cpp",
167 "glslang/MachineIndependent/iomapper.h",
168 "glslang/MachineIndependent/limits.cpp",
169 "glslang/MachineIndependent/linkValidate.cpp",
170 "glslang/MachineIndependent/localintermediate.h",
171 "glslang/MachineIndependent/parseConst.cpp",
172 "glslang/MachineIndependent/parseVersions.h",
173 "glslang/MachineIndependent/preprocessor/Pp.cpp",
174 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
175 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
176 "glslang/MachineIndependent/preprocessor/PpContext.h",
177 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
178 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
179 "glslang/MachineIndependent/preprocessor/PpTokens.h",
180 "glslang/MachineIndependent/propagateNoContraction.cpp",
181 "glslang/MachineIndependent/propagateNoContraction.h",
182 "glslang/MachineIndependent/reflection.cpp",
183 "glslang/MachineIndependent/reflection.h",
184 "glslang/OSDependent/osinclude.h",
185 "glslang/Public/ShaderLang.h",
188 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
191 "glslang/HLSL/hlslParseHelper.h",
192 "glslang/HLSL/hlslParseables.h",
193 "glslang/HLSL/hlslScanContext.h",
194 "glslang/HLSL/hlslTokens.h",
197 if (invoker.enable_hlsl) {
199 "glslang/HLSL/hlslAttributes.cpp",
200 "glslang/HLSL/hlslAttributes.h",
201 "glslang/HLSL/hlslGrammar.cpp",
202 "glslang/HLSL/hlslGrammar.h",
203 "glslang/HLSL/hlslOpMap.cpp",
204 "glslang/HLSL/hlslOpMap.h",
205 "glslang/HLSL/hlslParseHelper.cpp",
206 "glslang/HLSL/hlslParseables.cpp",
207 "glslang/HLSL/hlslScanContext.cpp",
208 "glslang/HLSL/hlslTokenStream.cpp",
209 "glslang/HLSL/hlslTokenStream.h",
214 if (invoker.enable_opt) {
215 sources += [ "SPIRV/SpvTools.cpp" ]
216 defines += [ "ENABLE_OPT=1" ]
218 if (invoker.is_angle) {
219 defines += [ "GLSLANG_ANGLE" ]
223 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
224 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
226 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
227 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
233 "-Wno-ignored-qualifiers",
234 "-Wno-implicit-fallthrough",
235 "-Wno-inconsistent-missing-override",
236 "-Wno-missing-field-initializers",
239 "-Wno-suggest-destructor-override",
240 "-Wno-suggest-override",
241 "-Wno-unused-variable",
244 if (is_win && !is_clang) {
246 "/wd4018", # signed/unsigned mismatch
247 "/wd4189", # local variable is initialized but not referenced
251 include_dirs = [ "${target_gen_dir}/include" ]
253 deps = [ ":glslang_build_info" ]
255 if (invoker.enable_opt) {
257 "${spirv_tools_dir}:spvtools_opt",
258 "${spirv_tools_dir}:spvtools_val",
260 include_dirs += [ "${spirv_tools_dir}/include" ]
263 configs -= _configs_to_remove
264 configs += _configs_to_add
268 glslang_sources_common("glslang_lib_sources") {
269 enable_opt = !glslang_angle
270 enable_hlsl = !glslang_angle
271 is_angle = glslang_angle
274 glslang_sources_common("glslang_sources") {
280 source_set("glslang_default_resource_limits_sources") {
282 "StandAlone/ResourceLimits.cpp",
283 "StandAlone/ResourceLimits.h",
284 "glslang/Include/ResourceLimits.h",
286 public_configs = [ ":glslang_public" ]
288 configs -= _configs_to_remove
289 configs += _configs_to_add
292 executable("glslang_validator") {
294 "StandAlone/DirStackFileIncluder.h",
295 "StandAlone/StandAlone.cpp",
298 cflags = [ "-Woverflow" ]
300 defines = [ "ENABLE_OPT=1" ]
302 ":glslang_build_info",
303 ":glslang_default_resource_limits_sources",
306 public_configs = [ ":glslang_hlsl" ]
309 "${target_gen_dir}/include",
310 "${spirv_tools_dir}/include",
313 configs -= _configs_to_remove
314 configs += _configs_to_add
317 executable("spirv-remap") {
318 sources = [ "StandAlone/spirv-remap.cpp" ]
319 defines = [ "ENABLE_OPT=1" ]
320 deps = [ ":glslang_sources" ]
322 include_dirs = [ "${spirv_tools_dir}/include" ]
324 configs -= _configs_to_remove
325 configs += _configs_to_add