blob: f7a0441722e8c5f6259ab340495386eba00f37a4 [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 = [ "." ]
Corentin Wallez9757da42019-08-26 14:13:54 +020053
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -040054 if (!glslang_angle) {
55 defines = [ "ENABLE_HLSL=1" ]
56 }
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 Youssefi8f8f1bc2020-07-03 12:34:06 -040063 sources = [
64 "OGLCompilersDLL/InitializeDll.cpp",
65 "OGLCompilersDLL/InitializeDll.h",
66 "SPIRV/GLSL.ext.AMD.h",
67 "SPIRV/GLSL.ext.EXT.h",
68 "SPIRV/GLSL.ext.KHR.h",
69 "SPIRV/GLSL.ext.NV.h",
70 "SPIRV/GLSL.std.450.h",
71 "SPIRV/GlslangToSpv.cpp",
72 "SPIRV/GlslangToSpv.h",
73 "SPIRV/InReadableOrder.cpp",
74 "SPIRV/Logger.cpp",
75 "SPIRV/Logger.h",
76 "SPIRV/NonSemanticDebugPrintf.h",
77 "SPIRV/SPVRemapper.cpp",
78 "SPIRV/SPVRemapper.h",
79 "SPIRV/SpvBuilder.cpp",
80 "SPIRV/SpvBuilder.h",
81 "SPIRV/SpvPostProcess.cpp",
82 "SPIRV/SpvTools.cpp",
83 "SPIRV/SpvTools.h",
84 "SPIRV/bitutils.h",
85 "SPIRV/disassemble.cpp",
86 "SPIRV/disassemble.h",
87 "SPIRV/doc.cpp",
88 "SPIRV/doc.h",
89 "SPIRV/hex_float.h",
90 "SPIRV/spirv.hpp",
91 "SPIRV/spvIR.h",
92 "glslang/GenericCodeGen/CodeGen.cpp",
93 "glslang/GenericCodeGen/Link.cpp",
94 "glslang/Include/BaseTypes.h",
95 "glslang/Include/Common.h",
96 "glslang/Include/ConstantUnion.h",
97 "glslang/Include/InfoSink.h",
98 "glslang/Include/InitializeGlobals.h",
99 "glslang/Include/PoolAlloc.h",
100 "glslang/Include/ResourceLimits.h",
101 "glslang/Include/ShHandle.h",
102 "glslang/Include/Types.h",
103 "glslang/Include/arrays.h",
104 "glslang/Include/intermediate.h",
105 "glslang/Include/revision.h",
106 "glslang/MachineIndependent/Constant.cpp",
107 "glslang/MachineIndependent/InfoSink.cpp",
108 "glslang/MachineIndependent/Initialize.cpp",
109 "glslang/MachineIndependent/Initialize.h",
110 "glslang/MachineIndependent/IntermTraverse.cpp",
111 "glslang/MachineIndependent/Intermediate.cpp",
112 "glslang/MachineIndependent/LiveTraverser.h",
113 "glslang/MachineIndependent/ParseContextBase.cpp",
114 "glslang/MachineIndependent/ParseHelper.cpp",
115 "glslang/MachineIndependent/ParseHelper.h",
116 "glslang/MachineIndependent/PoolAlloc.cpp",
117 "glslang/MachineIndependent/RemoveTree.cpp",
118 "glslang/MachineIndependent/RemoveTree.h",
119 "glslang/MachineIndependent/Scan.cpp",
120 "glslang/MachineIndependent/Scan.h",
121 "glslang/MachineIndependent/ScanContext.h",
122 "glslang/MachineIndependent/ShaderLang.cpp",
123 "glslang/MachineIndependent/SymbolTable.cpp",
124 "glslang/MachineIndependent/SymbolTable.h",
125 "glslang/MachineIndependent/Versions.cpp",
126 "glslang/MachineIndependent/Versions.h",
127 "glslang/MachineIndependent/attribute.cpp",
128 "glslang/MachineIndependent/attribute.h",
129 "glslang/MachineIndependent/gl_types.h",
130 "glslang/MachineIndependent/glslang_tab.cpp",
131 "glslang/MachineIndependent/glslang_tab.cpp.h",
132 "glslang/MachineIndependent/intermOut.cpp",
133 "glslang/MachineIndependent/iomapper.cpp",
134 "glslang/MachineIndependent/iomapper.h",
135 "glslang/MachineIndependent/limits.cpp",
136 "glslang/MachineIndependent/linkValidate.cpp",
137 "glslang/MachineIndependent/localintermediate.h",
138 "glslang/MachineIndependent/parseConst.cpp",
139 "glslang/MachineIndependent/parseVersions.h",
140 "glslang/MachineIndependent/preprocessor/Pp.cpp",
141 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
142 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
143 "glslang/MachineIndependent/preprocessor/PpContext.h",
144 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
145 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
146 "glslang/MachineIndependent/preprocessor/PpTokens.h",
147 "glslang/MachineIndependent/propagateNoContraction.cpp",
148 "glslang/MachineIndependent/propagateNoContraction.h",
149 "glslang/MachineIndependent/reflection.cpp",
150 "glslang/MachineIndependent/reflection.h",
151 "glslang/OSDependent/osinclude.h",
152 "glslang/Public/ShaderLang.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400153 ]
Dan Sinclair257b25c2018-09-24 16:35:44 -0400154
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400155 if (!glslang_angle) {
156 sources += [
157 "glslang/HLSL/hlslAttributes.cpp",
158 "glslang/HLSL/hlslAttributes.h",
159 "glslang/HLSL/hlslGrammar.cpp",
160 "glslang/HLSL/hlslGrammar.h",
161 "glslang/HLSL/hlslOpMap.cpp",
162 "glslang/HLSL/hlslOpMap.h",
163 "glslang/HLSL/hlslParseables.cpp",
164 "glslang/HLSL/hlslParseables.h",
165 "glslang/HLSL/hlslParseHelper.cpp",
166 "glslang/HLSL/hlslParseHelper.h",
167 "glslang/HLSL/hlslScanContext.cpp",
168 "glslang/HLSL/hlslScanContext.h",
169 "glslang/HLSL/hlslTokens.h",
170 "glslang/HLSL/hlslTokenStream.cpp",
171 "glslang/HLSL/hlslTokenStream.h",
172 ]
173 }
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400174
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400175 defines = []
176 if (invoker.enable_opt) {
177 defines += [ "ENABLE_OPT=1" ]
178 }
179
180 if (is_win) {
181 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
182 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
183 } else {
184 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
185 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
186 }
187
188 if (is_clang) {
189 cflags = [
190 "-Wno-extra-semi",
191 "-Wno-ignored-qualifiers",
192 "-Wno-implicit-fallthrough",
193 "-Wno-inconsistent-missing-override",
194 "-Wno-sign-compare",
195 "-Wno-unused-variable",
196 "-Wno-missing-field-initializers",
197 "-Wno-newline-eof",
198 ]
199 }
200 if (is_win && !is_clang) {
201 cflags = [
202 "/wd4018", # signed/unsigned mismatch
203 "/wd4189", # local variable is initialized but not referenced
204 ]
205 }
206
207 if (invoker.enable_opt) {
208 deps = [
209 "${spirv_tools_dir}:spvtools_opt",
210 "${spirv_tools_dir}:spvtools_val"
211 ]
212 }
213
214 configs -= _configs_to_remove
215 configs += _configs_to_add
216 }
217}
218
219glslang_sources_common("glslang_sources") {
220 enable_opt = !glslang_angle
221}
222
223glslang_sources_common("glslang_standalone_sources") {
224 enable_opt = true
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400225}
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500226
227source_set("glslang_default_resource_limits_sources") {
228 sources = [
Shahbaz Youssefie2b79832020-07-05 06:26:04 -0400229 "glslang/Include/ResourceLimits.h",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500230 "StandAlone/ResourceLimits.cpp",
231 "StandAlone/ResourceLimits.h",
232 ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500233 public_configs = [ ":glslang_public" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400234
David Turnera3f0da52019-10-23 16:07:19 +0200235 configs -= _configs_to_remove
236 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500237}
238
Jamie Madille880e962019-03-11 15:45:31 -0400239executable("glslang_validator") {
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500240 sources = [
241 "StandAlone/DirStackFileIncluder.h",
242 "StandAlone/StandAlone.cpp",
243 ]
244 if (!is_win) {
245 cflags = [ "-Woverflow" ]
246 }
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400247 defines = [ "ENABLE_OPT=1" ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500248 deps = [
249 ":glslang_default_resource_limits_sources",
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400250 ":glslang_standalone_sources",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500251 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400252
David Turnera3f0da52019-10-23 16:07:19 +0200253 configs -= _configs_to_remove
254 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500255}
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200256
257executable("spirv-remap") {
258 sources = [
259 "StandAlone/spirv-remap.cpp",
260 ]
261 defines = [ "ENABLE_OPT=1" ]
262 deps = [
Shahbaz Youssefi8f8f1bc2020-07-03 12:34:06 -0400263 ":glslang_standalone_sources",
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200264 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400265
David Turnera3f0da52019-10-23 16:07:19 +0200266 configs -= _configs_to_remove
267 configs += _configs_to_add
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200268}