blob: 46c4b28d0eedbdb038145ed47c73d2618b532a75 [file] [log] [blame]
Dan Sinclair257b25c2018-09-24 16:35:44 -04001# Copyright (C) 2018 Google, Inc.
2#
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11#
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.
16#
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.
20#
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.
33
34import("//build_overrides/glslang.gni")
35
David Turnera3f0da52019-10-23 16:07:19 +020036# 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.
41if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
42 _configs_to_remove = [ "//build/config:default_warnings" ]
43 _configs_to_add = []
44} else {
45 _configs_to_remove = [ "//build/config/compiler:chromium_code" ]
46 _configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
47}
48
Dan Sinclair257b25c2018-09-24 16:35:44 -040049spirv_tools_dir = glslang_spirv_tools_dir
50
51config("glslang_public") {
52 include_dirs = [ "." ]
Shahbaz Youssefia55029d2020-07-05 16:48:34 -040053}
Corentin Wallez9757da42019-08-26 14:13:54 +020054
Shahbaz Youssefia55029d2020-07-05 16:48:34 -040055config("glslang_hlsl") {
56 defines = [ "ENABLE_HLSL=1" ]
Dan Sinclair257b25c2018-09-24 16:35:44 -040057}
58
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -040059template("glslang_sources_common") {
60 source_set(target_name) {
61 public_configs = [ ":glslang_public" ]
Corentin Wallez6857c232018-10-03 13:15:23 -040062
Shahbaz Youssefia55029d2020-07-05 16:48:34 -040063 if (invoker.enable_hlsl) {
64 public_configs += [ ":glslang_hlsl" ]
65 }
66
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -040067 sources = [
68 "OGLCompilersDLL/InitializeDll.cpp",
69 "OGLCompilersDLL/InitializeDll.h",
70 "SPIRV/GLSL.ext.AMD.h",
71 "SPIRV/GLSL.ext.EXT.h",
72 "SPIRV/GLSL.ext.KHR.h",
73 "SPIRV/GLSL.ext.NV.h",
74 "SPIRV/GLSL.std.450.h",
75 "SPIRV/GlslangToSpv.cpp",
76 "SPIRV/GlslangToSpv.h",
77 "SPIRV/InReadableOrder.cpp",
78 "SPIRV/Logger.cpp",
79 "SPIRV/Logger.h",
80 "SPIRV/NonSemanticDebugPrintf.h",
81 "SPIRV/SPVRemapper.cpp",
82 "SPIRV/SPVRemapper.h",
83 "SPIRV/SpvBuilder.cpp",
84 "SPIRV/SpvBuilder.h",
85 "SPIRV/SpvPostProcess.cpp",
86 "SPIRV/SpvTools.cpp",
87 "SPIRV/SpvTools.h",
88 "SPIRV/bitutils.h",
89 "SPIRV/disassemble.cpp",
90 "SPIRV/disassemble.h",
91 "SPIRV/doc.cpp",
92 "SPIRV/doc.h",
93 "SPIRV/hex_float.h",
94 "SPIRV/spirv.hpp",
95 "SPIRV/spvIR.h",
96 "glslang/GenericCodeGen/CodeGen.cpp",
97 "glslang/GenericCodeGen/Link.cpp",
98 "glslang/Include/BaseTypes.h",
99 "glslang/Include/Common.h",
100 "glslang/Include/ConstantUnion.h",
101 "glslang/Include/InfoSink.h",
102 "glslang/Include/InitializeGlobals.h",
103 "glslang/Include/PoolAlloc.h",
104 "glslang/Include/ResourceLimits.h",
105 "glslang/Include/ShHandle.h",
106 "glslang/Include/Types.h",
107 "glslang/Include/arrays.h",
108 "glslang/Include/intermediate.h",
109 "glslang/Include/revision.h",
110 "glslang/MachineIndependent/Constant.cpp",
111 "glslang/MachineIndependent/InfoSink.cpp",
112 "glslang/MachineIndependent/Initialize.cpp",
113 "glslang/MachineIndependent/Initialize.h",
114 "glslang/MachineIndependent/IntermTraverse.cpp",
115 "glslang/MachineIndependent/Intermediate.cpp",
116 "glslang/MachineIndependent/LiveTraverser.h",
117 "glslang/MachineIndependent/ParseContextBase.cpp",
118 "glslang/MachineIndependent/ParseHelper.cpp",
119 "glslang/MachineIndependent/ParseHelper.h",
120 "glslang/MachineIndependent/PoolAlloc.cpp",
121 "glslang/MachineIndependent/RemoveTree.cpp",
122 "glslang/MachineIndependent/RemoveTree.h",
123 "glslang/MachineIndependent/Scan.cpp",
124 "glslang/MachineIndependent/Scan.h",
125 "glslang/MachineIndependent/ScanContext.h",
126 "glslang/MachineIndependent/ShaderLang.cpp",
127 "glslang/MachineIndependent/SymbolTable.cpp",
128 "glslang/MachineIndependent/SymbolTable.h",
129 "glslang/MachineIndependent/Versions.cpp",
130 "glslang/MachineIndependent/Versions.h",
131 "glslang/MachineIndependent/attribute.cpp",
132 "glslang/MachineIndependent/attribute.h",
133 "glslang/MachineIndependent/gl_types.h",
134 "glslang/MachineIndependent/glslang_tab.cpp",
135 "glslang/MachineIndependent/glslang_tab.cpp.h",
136 "glslang/MachineIndependent/intermOut.cpp",
137 "glslang/MachineIndependent/iomapper.cpp",
138 "glslang/MachineIndependent/iomapper.h",
139 "glslang/MachineIndependent/limits.cpp",
140 "glslang/MachineIndependent/linkValidate.cpp",
141 "glslang/MachineIndependent/localintermediate.h",
142 "glslang/MachineIndependent/parseConst.cpp",
143 "glslang/MachineIndependent/parseVersions.h",
144 "glslang/MachineIndependent/preprocessor/Pp.cpp",
145 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
146 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
147 "glslang/MachineIndependent/preprocessor/PpContext.h",
148 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
149 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
150 "glslang/MachineIndependent/preprocessor/PpTokens.h",
151 "glslang/MachineIndependent/propagateNoContraction.cpp",
152 "glslang/MachineIndependent/propagateNoContraction.h",
153 "glslang/MachineIndependent/reflection.cpp",
154 "glslang/MachineIndependent/reflection.h",
155 "glslang/OSDependent/osinclude.h",
156 "glslang/Public/ShaderLang.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400157 ]
Dan Sinclair257b25c2018-09-24 16:35:44 -0400158
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400159 # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
160 # defined.
161 sources += [
162 "glslang/HLSL/hlslParseHelper.h",
163 "glslang/HLSL/hlslParseables.h",
164 "glslang/HLSL/hlslScanContext.h",
165 "glslang/HLSL/hlslTokens.h",
166 ]
167
168 if (invoker.enable_hlsl) {
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400169 sources += [
170 "glslang/HLSL/hlslAttributes.cpp",
171 "glslang/HLSL/hlslAttributes.h",
172 "glslang/HLSL/hlslGrammar.cpp",
173 "glslang/HLSL/hlslGrammar.h",
174 "glslang/HLSL/hlslOpMap.cpp",
175 "glslang/HLSL/hlslOpMap.h",
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400176 "glslang/HLSL/hlslParseHelper.cpp",
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400177 "glslang/HLSL/hlslParseables.cpp",
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400178 "glslang/HLSL/hlslScanContext.cpp",
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400179 "glslang/HLSL/hlslTokenStream.cpp",
180 "glslang/HLSL/hlslTokenStream.h",
181 ]
182 }
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400183
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400184 defines = []
185 if (invoker.enable_opt) {
186 defines += [ "ENABLE_OPT=1" ]
187 }
188
189 if (is_win) {
190 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
191 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
192 } else {
193 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
194 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
195 }
196
197 if (is_clang) {
198 cflags = [
199 "-Wno-extra-semi",
200 "-Wno-ignored-qualifiers",
201 "-Wno-implicit-fallthrough",
202 "-Wno-inconsistent-missing-override",
203 "-Wno-sign-compare",
204 "-Wno-unused-variable",
205 "-Wno-missing-field-initializers",
206 "-Wno-newline-eof",
207 ]
208 }
209 if (is_win && !is_clang) {
210 cflags = [
211 "/wd4018", # signed/unsigned mismatch
212 "/wd4189", # local variable is initialized but not referenced
213 ]
214 }
215
216 if (invoker.enable_opt) {
217 deps = [
218 "${spirv_tools_dir}:spvtools_opt",
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400219 "${spirv_tools_dir}:spvtools_val",
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400220 ]
221 }
222
223 configs -= _configs_to_remove
224 configs += _configs_to_add
225 }
226}
227
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400228glslang_sources_common("glslang_lib_sources") {
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400229 enable_opt = !glslang_angle
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400230 enable_hlsl = !glslang_angle
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400231}
232
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400233glslang_sources_common("glslang_sources") {
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400234 enable_opt = true
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400235 enable_hlsl = true
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400236}
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500237
238source_set("glslang_default_resource_limits_sources") {
239 sources = [
240 "StandAlone/ResourceLimits.cpp",
241 "StandAlone/ResourceLimits.h",
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400242 "glslang/Include/ResourceLimits.h",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500243 ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500244 public_configs = [ ":glslang_public" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400245
David Turnera3f0da52019-10-23 16:07:19 +0200246 configs -= _configs_to_remove
247 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500248}
249
Jamie Madille880e962019-03-11 15:45:31 -0400250executable("glslang_validator") {
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500251 sources = [
252 "StandAlone/DirStackFileIncluder.h",
253 "StandAlone/StandAlone.cpp",
254 ]
255 if (!is_win) {
256 cflags = [ "-Woverflow" ]
257 }
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400258 defines = [ "ENABLE_OPT=1" ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500259 deps = [
260 ":glslang_default_resource_limits_sources",
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400261 ":glslang_sources",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500262 ]
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400263 public_configs = [ ":glslang_hlsl" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400264
David Turnera3f0da52019-10-23 16:07:19 +0200265 configs -= _configs_to_remove
266 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500267}
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200268
269executable("spirv-remap") {
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400270 sources = [ "StandAlone/spirv-remap.cpp" ]
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200271 defines = [ "ENABLE_OPT=1" ]
Shahbaz Youssefia55029d2020-07-05 16:48:34 -0400272 deps = [ ":glslang_sources" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400273
David Turnera3f0da52019-10-23 16:07:19 +0200274 configs -= _configs_to_remove
275 configs += _configs_to_add
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200276}