blob: cb44707c7041bb5e0ee2762a65dfc1542c9fa674 [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
54 defines = [ "ENABLE_HLSL=1" ]
Dan Sinclair257b25c2018-09-24 16:35:44 -040055}
56
Dan Sinclairb29c58e2018-09-24 18:40:38 -040057source_set("glslang_sources") {
Corentin Wallez6857c232018-10-03 13:15:23 -040058 public_configs = [ ":glslang_public" ]
59
Dan Sinclair257b25c2018-09-24 16:35:44 -040060 sources = [
61 "OGLCompilersDLL/InitializeDll.cpp",
62 "OGLCompilersDLL/InitializeDll.h",
Jamie Madill6fbc1af2019-11-02 09:56:09 -040063 "SPIRV/GLSL.ext.AMD.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040064 "SPIRV/GLSL.ext.EXT.h",
65 "SPIRV/GLSL.ext.KHR.h",
Jamie Madill6fbc1af2019-11-02 09:56:09 -040066 "SPIRV/GLSL.ext.NV.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040067 "SPIRV/GLSL.std.450.h",
68 "SPIRV/GlslangToSpv.cpp",
69 "SPIRV/GlslangToSpv.h",
70 "SPIRV/InReadableOrder.cpp",
71 "SPIRV/Logger.cpp",
72 "SPIRV/Logger.h",
Aaron Frankec8274e92020-03-21 03:20:25 -040073 "SPIRV/NonSemanticDebugPrintf.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040074 "SPIRV/SPVRemapper.cpp",
75 "SPIRV/SPVRemapper.h",
76 "SPIRV/SpvBuilder.cpp",
77 "SPIRV/SpvBuilder.h",
Corentin Wallez873734d2018-09-26 14:51:19 -070078 "SPIRV/SpvPostProcess.cpp",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -040079 "SPIRV/SpvTools.cpp",
80 "SPIRV/SpvTools.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040081 "SPIRV/bitutils.h",
82 "SPIRV/disassemble.cpp",
83 "SPIRV/disassemble.h",
84 "SPIRV/doc.cpp",
85 "SPIRV/doc.h",
86 "SPIRV/hex_float.h",
87 "SPIRV/spirv.hpp",
88 "SPIRV/spvIR.h",
89 "glslang/GenericCodeGen/CodeGen.cpp",
90 "glslang/GenericCodeGen/Link.cpp",
Ben Claytonf49820d2020-06-16 11:54:34 +010091 "glslang/HLSL/hlslAttributes.cpp",
92 "glslang/HLSL/hlslAttributes.h",
93 "glslang/HLSL/hlslGrammar.cpp",
94 "glslang/HLSL/hlslGrammar.h",
95 "glslang/HLSL/hlslOpMap.cpp",
96 "glslang/HLSL/hlslOpMap.h",
97 "glslang/HLSL/hlslParseables.cpp",
98 "glslang/HLSL/hlslParseables.h",
99 "glslang/HLSL/hlslParseHelper.cpp",
100 "glslang/HLSL/hlslParseHelper.h",
101 "glslang/HLSL/hlslScanContext.cpp",
102 "glslang/HLSL/hlslScanContext.h",
103 "glslang/HLSL/hlslTokens.h",
104 "glslang/HLSL/hlslTokenStream.cpp",
105 "glslang/HLSL/hlslTokenStream.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400106 "glslang/Include/BaseTypes.h",
107 "glslang/Include/Common.h",
108 "glslang/Include/ConstantUnion.h",
109 "glslang/Include/InfoSink.h",
110 "glslang/Include/InitializeGlobals.h",
111 "glslang/Include/PoolAlloc.h",
112 "glslang/Include/ResourceLimits.h",
113 "glslang/Include/ShHandle.h",
114 "glslang/Include/Types.h",
115 "glslang/Include/arrays.h",
116 "glslang/Include/intermediate.h",
117 "glslang/Include/revision.h",
118 "glslang/MachineIndependent/Constant.cpp",
119 "glslang/MachineIndependent/InfoSink.cpp",
120 "glslang/MachineIndependent/Initialize.cpp",
121 "glslang/MachineIndependent/Initialize.h",
122 "glslang/MachineIndependent/IntermTraverse.cpp",
123 "glslang/MachineIndependent/Intermediate.cpp",
124 "glslang/MachineIndependent/LiveTraverser.h",
125 "glslang/MachineIndependent/ParseContextBase.cpp",
126 "glslang/MachineIndependent/ParseHelper.cpp",
127 "glslang/MachineIndependent/ParseHelper.h",
128 "glslang/MachineIndependent/PoolAlloc.cpp",
129 "glslang/MachineIndependent/RemoveTree.cpp",
130 "glslang/MachineIndependent/RemoveTree.h",
131 "glslang/MachineIndependent/Scan.cpp",
132 "glslang/MachineIndependent/Scan.h",
133 "glslang/MachineIndependent/ScanContext.h",
134 "glslang/MachineIndependent/ShaderLang.cpp",
135 "glslang/MachineIndependent/SymbolTable.cpp",
136 "glslang/MachineIndependent/SymbolTable.h",
137 "glslang/MachineIndependent/Versions.cpp",
138 "glslang/MachineIndependent/Versions.h",
139 "glslang/MachineIndependent/attribute.cpp",
140 "glslang/MachineIndependent/attribute.h",
141 "glslang/MachineIndependent/gl_types.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400142 "glslang/MachineIndependent/glslang_tab.cpp",
143 "glslang/MachineIndependent/glslang_tab.cpp.h",
144 "glslang/MachineIndependent/intermOut.cpp",
145 "glslang/MachineIndependent/iomapper.cpp",
146 "glslang/MachineIndependent/iomapper.h",
147 "glslang/MachineIndependent/limits.cpp",
148 "glslang/MachineIndependent/linkValidate.cpp",
149 "glslang/MachineIndependent/localintermediate.h",
150 "glslang/MachineIndependent/parseConst.cpp",
151 "glslang/MachineIndependent/parseVersions.h",
152 "glslang/MachineIndependent/preprocessor/Pp.cpp",
153 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
154 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
155 "glslang/MachineIndependent/preprocessor/PpContext.h",
156 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
157 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
158 "glslang/MachineIndependent/preprocessor/PpTokens.h",
159 "glslang/MachineIndependent/propagateNoContraction.cpp",
160 "glslang/MachineIndependent/propagateNoContraction.h",
161 "glslang/MachineIndependent/reflection.cpp",
162 "glslang/MachineIndependent/reflection.h",
163 "glslang/OSDependent/osinclude.h",
164 "glslang/Public/ShaderLang.h",
165 ]
166
Corentin Wallez9757da42019-08-26 14:13:54 +0200167 defines = [ "ENABLE_OPT=1" ]
David Neto96bec342019-08-23 14:34:29 -0400168
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400169 if (is_win) {
170 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
171 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
172 } else {
173 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
174 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
175 }
176
Dan Sinclair257b25c2018-09-24 16:35:44 -0400177 if (is_clang) {
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400178 cflags = [
Jamie Madill1a1651c2019-01-30 11:37:15 -0500179 "-Wno-extra-semi",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400180 "-Wno-ignored-qualifiers",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500181 "-Wno-implicit-fallthrough",
Jamie Madill97061062019-01-23 18:56:43 -0500182 "-Wno-inconsistent-missing-override",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500183 "-Wno-sign-compare",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400184 "-Wno-unused-variable",
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200185 "-Wno-missing-field-initializers",
David 'Digit' Turner9d43c7f2019-09-16 19:13:16 +0200186 "-Wno-newline-eof",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400187 ]
188 }
Jamie Madill08fe88a2019-01-24 10:55:41 -0500189 if (is_win && !is_clang) {
190 cflags = [
Corentin Wallez9757da42019-08-26 14:13:54 +0200191 "/wd4018", # signed/unsigned mismatch
192 "/wd4189", # local variable is initialized but not referenced
Jamie Madill08fe88a2019-01-24 10:55:41 -0500193 ]
194 }
Dan Sinclair257b25c2018-09-24 16:35:44 -0400195
196 deps = [
197 "${spirv_tools_dir}:spvtools_opt",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400198 "${spirv_tools_dir}:spvtools_val",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400199 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400200
David Turnera3f0da52019-10-23 16:07:19 +0200201 configs -= _configs_to_remove
202 configs += _configs_to_add
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400203}
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500204
205source_set("glslang_default_resource_limits_sources") {
206 sources = [
207 "StandAlone/ResourceLimits.cpp",
208 "StandAlone/ResourceLimits.h",
209 ]
Corentin Wallez9757da42019-08-26 14:13:54 +0200210 deps = [
211 ":glslang_sources",
212 ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500213 public_configs = [ ":glslang_public" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400214
David Turnera3f0da52019-10-23 16:07:19 +0200215 configs -= _configs_to_remove
216 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500217}
218
Jamie Madille880e962019-03-11 15:45:31 -0400219executable("glslang_validator") {
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500220 sources = [
221 "StandAlone/DirStackFileIncluder.h",
222 "StandAlone/StandAlone.cpp",
223 ]
224 if (!is_win) {
225 cflags = [ "-Woverflow" ]
226 }
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400227 defines = [ "ENABLE_OPT=1" ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500228 deps = [
229 ":glslang_default_resource_limits_sources",
230 ":glslang_sources",
231 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400232
David Turnera3f0da52019-10-23 16:07:19 +0200233 configs -= _configs_to_remove
234 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500235}
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200236
237executable("spirv-remap") {
238 sources = [
239 "StandAlone/spirv-remap.cpp",
240 ]
241 defines = [ "ENABLE_OPT=1" ]
242 deps = [
243 ":glslang_sources",
244 ]
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
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200248}