blob: 098d7de663b96917434356a420500db4541ff03e [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",
73 "SPIRV/SPVRemapper.cpp",
74 "SPIRV/SPVRemapper.h",
75 "SPIRV/SpvBuilder.cpp",
76 "SPIRV/SpvBuilder.h",
Corentin Wallez873734d2018-09-26 14:51:19 -070077 "SPIRV/SpvPostProcess.cpp",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -040078 "SPIRV/SpvTools.cpp",
79 "SPIRV/SpvTools.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040080 "SPIRV/bitutils.h",
81 "SPIRV/disassemble.cpp",
82 "SPIRV/disassemble.h",
83 "SPIRV/doc.cpp",
84 "SPIRV/doc.h",
85 "SPIRV/hex_float.h",
86 "SPIRV/spirv.hpp",
87 "SPIRV/spvIR.h",
88 "glslang/GenericCodeGen/CodeGen.cpp",
89 "glslang/GenericCodeGen/Link.cpp",
90 "glslang/Include/BaseTypes.h",
91 "glslang/Include/Common.h",
92 "glslang/Include/ConstantUnion.h",
93 "glslang/Include/InfoSink.h",
94 "glslang/Include/InitializeGlobals.h",
95 "glslang/Include/PoolAlloc.h",
96 "glslang/Include/ResourceLimits.h",
97 "glslang/Include/ShHandle.h",
98 "glslang/Include/Types.h",
99 "glslang/Include/arrays.h",
100 "glslang/Include/intermediate.h",
101 "glslang/Include/revision.h",
102 "glslang/MachineIndependent/Constant.cpp",
103 "glslang/MachineIndependent/InfoSink.cpp",
104 "glslang/MachineIndependent/Initialize.cpp",
105 "glslang/MachineIndependent/Initialize.h",
106 "glslang/MachineIndependent/IntermTraverse.cpp",
107 "glslang/MachineIndependent/Intermediate.cpp",
108 "glslang/MachineIndependent/LiveTraverser.h",
109 "glslang/MachineIndependent/ParseContextBase.cpp",
110 "glslang/MachineIndependent/ParseHelper.cpp",
111 "glslang/MachineIndependent/ParseHelper.h",
112 "glslang/MachineIndependent/PoolAlloc.cpp",
113 "glslang/MachineIndependent/RemoveTree.cpp",
114 "glslang/MachineIndependent/RemoveTree.h",
115 "glslang/MachineIndependent/Scan.cpp",
116 "glslang/MachineIndependent/Scan.h",
117 "glslang/MachineIndependent/ScanContext.h",
118 "glslang/MachineIndependent/ShaderLang.cpp",
119 "glslang/MachineIndependent/SymbolTable.cpp",
120 "glslang/MachineIndependent/SymbolTable.h",
121 "glslang/MachineIndependent/Versions.cpp",
122 "glslang/MachineIndependent/Versions.h",
123 "glslang/MachineIndependent/attribute.cpp",
124 "glslang/MachineIndependent/attribute.h",
125 "glslang/MachineIndependent/gl_types.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400126 "glslang/MachineIndependent/glslang_tab.cpp",
127 "glslang/MachineIndependent/glslang_tab.cpp.h",
128 "glslang/MachineIndependent/intermOut.cpp",
129 "glslang/MachineIndependent/iomapper.cpp",
130 "glslang/MachineIndependent/iomapper.h",
131 "glslang/MachineIndependent/limits.cpp",
132 "glslang/MachineIndependent/linkValidate.cpp",
133 "glslang/MachineIndependent/localintermediate.h",
134 "glslang/MachineIndependent/parseConst.cpp",
135 "glslang/MachineIndependent/parseVersions.h",
136 "glslang/MachineIndependent/preprocessor/Pp.cpp",
137 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
138 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
139 "glslang/MachineIndependent/preprocessor/PpContext.h",
140 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
141 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
142 "glslang/MachineIndependent/preprocessor/PpTokens.h",
143 "glslang/MachineIndependent/propagateNoContraction.cpp",
144 "glslang/MachineIndependent/propagateNoContraction.h",
145 "glslang/MachineIndependent/reflection.cpp",
146 "glslang/MachineIndependent/reflection.h",
147 "glslang/OSDependent/osinclude.h",
148 "glslang/Public/ShaderLang.h",
Corentin Wallez5442b4f2019-08-27 15:24:31 +0200149 "hlsl/hlslAttributes.cpp",
150 "hlsl/hlslAttributes.h",
151 "hlsl/hlslGrammar.cpp",
152 "hlsl/hlslGrammar.h",
153 "hlsl/hlslOpMap.cpp",
154 "hlsl/hlslOpMap.h",
155 "hlsl/hlslParseHelper.cpp",
156 "hlsl/hlslParseHelper.h",
157 "hlsl/hlslParseables.cpp",
158 "hlsl/hlslParseables.h",
159 "hlsl/hlslScanContext.cpp",
160 "hlsl/hlslScanContext.h",
161 "hlsl/hlslTokenStream.cpp",
162 "hlsl/hlslTokenStream.h",
163 "hlsl/hlslTokens.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400164 ]
165
Corentin Wallez9757da42019-08-26 14:13:54 +0200166 defines = [ "ENABLE_OPT=1" ]
David Neto96bec342019-08-23 14:34:29 -0400167
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400168 if (is_win) {
169 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
170 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
171 } else {
172 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
173 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
174 }
175
Dan Sinclair257b25c2018-09-24 16:35:44 -0400176 if (is_clang) {
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400177 cflags = [
Jamie Madill1a1651c2019-01-30 11:37:15 -0500178 "-Wno-extra-semi",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400179 "-Wno-ignored-qualifiers",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500180 "-Wno-implicit-fallthrough",
Jamie Madill97061062019-01-23 18:56:43 -0500181 "-Wno-inconsistent-missing-override",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500182 "-Wno-sign-compare",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400183 "-Wno-unused-variable",
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200184 "-Wno-missing-field-initializers",
David 'Digit' Turner9d43c7f2019-09-16 19:13:16 +0200185 "-Wno-newline-eof",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400186 ]
187 }
Jamie Madill08fe88a2019-01-24 10:55:41 -0500188 if (is_win && !is_clang) {
189 cflags = [
Corentin Wallez9757da42019-08-26 14:13:54 +0200190 "/wd4018", # signed/unsigned mismatch
191 "/wd4189", # local variable is initialized but not referenced
Jamie Madill08fe88a2019-01-24 10:55:41 -0500192 ]
193 }
Dan Sinclair257b25c2018-09-24 16:35:44 -0400194
195 deps = [
196 "${spirv_tools_dir}:spvtools_opt",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400197 "${spirv_tools_dir}:spvtools_val",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400198 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400199
David Turnera3f0da52019-10-23 16:07:19 +0200200 configs -= _configs_to_remove
201 configs += _configs_to_add
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400202}
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500203
204source_set("glslang_default_resource_limits_sources") {
205 sources = [
206 "StandAlone/ResourceLimits.cpp",
207 "StandAlone/ResourceLimits.h",
208 ]
Corentin Wallez9757da42019-08-26 14:13:54 +0200209 deps = [
210 ":glslang_sources",
211 ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500212 public_configs = [ ":glslang_public" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400213
David Turnera3f0da52019-10-23 16:07:19 +0200214 configs -= _configs_to_remove
215 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500216}
217
Jamie Madille880e962019-03-11 15:45:31 -0400218executable("glslang_validator") {
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500219 sources = [
220 "StandAlone/DirStackFileIncluder.h",
221 "StandAlone/StandAlone.cpp",
222 ]
223 if (!is_win) {
224 cflags = [ "-Woverflow" ]
225 }
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400226 defines = [ "ENABLE_OPT=1" ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500227 deps = [
228 ":glslang_default_resource_limits_sources",
229 ":glslang_sources",
230 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400231
David Turnera3f0da52019-10-23 16:07:19 +0200232 configs -= _configs_to_remove
233 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500234}
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200235
236executable("spirv-remap") {
237 sources = [
238 "StandAlone/spirv-remap.cpp",
239 ]
240 defines = [ "ENABLE_OPT=1" ]
241 deps = [
242 ":glslang_sources",
243 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400244
David Turnera3f0da52019-10-23 16:07:19 +0200245 configs -= _configs_to_remove
246 configs += _configs_to_add
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200247}