blob: 3351fd3ed061cb40649819d1c2181a1481534010 [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",
63 "SPIRV/GLSL.ext.EXT.h",
64 "SPIRV/GLSL.ext.KHR.h",
65 "SPIRV/GLSL.std.450.h",
66 "SPIRV/GlslangToSpv.cpp",
67 "SPIRV/GlslangToSpv.h",
68 "SPIRV/InReadableOrder.cpp",
69 "SPIRV/Logger.cpp",
70 "SPIRV/Logger.h",
71 "SPIRV/SPVRemapper.cpp",
72 "SPIRV/SPVRemapper.h",
73 "SPIRV/SpvBuilder.cpp",
74 "SPIRV/SpvBuilder.h",
Corentin Wallez873734d2018-09-26 14:51:19 -070075 "SPIRV/SpvPostProcess.cpp",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -040076 "SPIRV/SpvTools.cpp",
77 "SPIRV/SpvTools.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -040078 "SPIRV/bitutils.h",
79 "SPIRV/disassemble.cpp",
80 "SPIRV/disassemble.h",
81 "SPIRV/doc.cpp",
82 "SPIRV/doc.h",
83 "SPIRV/hex_float.h",
84 "SPIRV/spirv.hpp",
85 "SPIRV/spvIR.h",
86 "glslang/GenericCodeGen/CodeGen.cpp",
87 "glslang/GenericCodeGen/Link.cpp",
88 "glslang/Include/BaseTypes.h",
89 "glslang/Include/Common.h",
90 "glslang/Include/ConstantUnion.h",
91 "glslang/Include/InfoSink.h",
92 "glslang/Include/InitializeGlobals.h",
93 "glslang/Include/PoolAlloc.h",
94 "glslang/Include/ResourceLimits.h",
95 "glslang/Include/ShHandle.h",
96 "glslang/Include/Types.h",
97 "glslang/Include/arrays.h",
98 "glslang/Include/intermediate.h",
99 "glslang/Include/revision.h",
100 "glslang/MachineIndependent/Constant.cpp",
101 "glslang/MachineIndependent/InfoSink.cpp",
102 "glslang/MachineIndependent/Initialize.cpp",
103 "glslang/MachineIndependent/Initialize.h",
104 "glslang/MachineIndependent/IntermTraverse.cpp",
105 "glslang/MachineIndependent/Intermediate.cpp",
106 "glslang/MachineIndependent/LiveTraverser.h",
107 "glslang/MachineIndependent/ParseContextBase.cpp",
108 "glslang/MachineIndependent/ParseHelper.cpp",
109 "glslang/MachineIndependent/ParseHelper.h",
110 "glslang/MachineIndependent/PoolAlloc.cpp",
111 "glslang/MachineIndependent/RemoveTree.cpp",
112 "glslang/MachineIndependent/RemoveTree.h",
113 "glslang/MachineIndependent/Scan.cpp",
114 "glslang/MachineIndependent/Scan.h",
115 "glslang/MachineIndependent/ScanContext.h",
116 "glslang/MachineIndependent/ShaderLang.cpp",
117 "glslang/MachineIndependent/SymbolTable.cpp",
118 "glslang/MachineIndependent/SymbolTable.h",
119 "glslang/MachineIndependent/Versions.cpp",
120 "glslang/MachineIndependent/Versions.h",
121 "glslang/MachineIndependent/attribute.cpp",
122 "glslang/MachineIndependent/attribute.h",
123 "glslang/MachineIndependent/gl_types.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400124 "glslang/MachineIndependent/glslang_tab.cpp",
125 "glslang/MachineIndependent/glslang_tab.cpp.h",
126 "glslang/MachineIndependent/intermOut.cpp",
127 "glslang/MachineIndependent/iomapper.cpp",
128 "glslang/MachineIndependent/iomapper.h",
129 "glslang/MachineIndependent/limits.cpp",
130 "glslang/MachineIndependent/linkValidate.cpp",
131 "glslang/MachineIndependent/localintermediate.h",
132 "glslang/MachineIndependent/parseConst.cpp",
133 "glslang/MachineIndependent/parseVersions.h",
134 "glslang/MachineIndependent/preprocessor/Pp.cpp",
135 "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
136 "glslang/MachineIndependent/preprocessor/PpContext.cpp",
137 "glslang/MachineIndependent/preprocessor/PpContext.h",
138 "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
139 "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
140 "glslang/MachineIndependent/preprocessor/PpTokens.h",
141 "glslang/MachineIndependent/propagateNoContraction.cpp",
142 "glslang/MachineIndependent/propagateNoContraction.h",
143 "glslang/MachineIndependent/reflection.cpp",
144 "glslang/MachineIndependent/reflection.h",
145 "glslang/OSDependent/osinclude.h",
146 "glslang/Public/ShaderLang.h",
Corentin Wallez5442b4f2019-08-27 15:24:31 +0200147 "hlsl/hlslAttributes.cpp",
148 "hlsl/hlslAttributes.h",
149 "hlsl/hlslGrammar.cpp",
150 "hlsl/hlslGrammar.h",
151 "hlsl/hlslOpMap.cpp",
152 "hlsl/hlslOpMap.h",
153 "hlsl/hlslParseHelper.cpp",
154 "hlsl/hlslParseHelper.h",
155 "hlsl/hlslParseables.cpp",
156 "hlsl/hlslParseables.h",
157 "hlsl/hlslScanContext.cpp",
158 "hlsl/hlslScanContext.h",
159 "hlsl/hlslTokenStream.cpp",
160 "hlsl/hlslTokenStream.h",
161 "hlsl/hlslTokens.h",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400162 ]
163
Corentin Wallez9757da42019-08-26 14:13:54 +0200164 defines = [ "ENABLE_OPT=1" ]
David Neto96bec342019-08-23 14:34:29 -0400165
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400166 if (is_win) {
167 sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
168 defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
169 } else {
170 sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
171 defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
172 }
173
Dan Sinclair257b25c2018-09-24 16:35:44 -0400174 if (is_clang) {
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400175 cflags = [
Jamie Madill1a1651c2019-01-30 11:37:15 -0500176 "-Wno-extra-semi",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400177 "-Wno-ignored-qualifiers",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500178 "-Wno-implicit-fallthrough",
Jamie Madill97061062019-01-23 18:56:43 -0500179 "-Wno-inconsistent-missing-override",
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500180 "-Wno-sign-compare",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400181 "-Wno-unused-variable",
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200182 "-Wno-missing-field-initializers",
David 'Digit' Turner9d43c7f2019-09-16 19:13:16 +0200183 "-Wno-newline-eof",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400184 ]
185 }
Jamie Madill08fe88a2019-01-24 10:55:41 -0500186 if (is_win && !is_clang) {
187 cflags = [
Corentin Wallez9757da42019-08-26 14:13:54 +0200188 "/wd4018", # signed/unsigned mismatch
189 "/wd4189", # local variable is initialized but not referenced
Jamie Madill08fe88a2019-01-24 10:55:41 -0500190 ]
191 }
Dan Sinclair257b25c2018-09-24 16:35:44 -0400192
193 deps = [
194 "${spirv_tools_dir}:spvtools_opt",
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400195 "${spirv_tools_dir}:spvtools_val",
Dan Sinclair257b25c2018-09-24 16:35:44 -0400196 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400197
David Turnera3f0da52019-10-23 16:07:19 +0200198 configs -= _configs_to_remove
199 configs += _configs_to_add
Dan Sinclairb29c58e2018-09-24 18:40:38 -0400200}
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500201
202source_set("glslang_default_resource_limits_sources") {
203 sources = [
204 "StandAlone/ResourceLimits.cpp",
205 "StandAlone/ResourceLimits.h",
206 ]
Corentin Wallez9757da42019-08-26 14:13:54 +0200207 deps = [
208 ":glslang_sources",
209 ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500210 public_configs = [ ":glslang_public" ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400211
David Turnera3f0da52019-10-23 16:07:19 +0200212 configs -= _configs_to_remove
213 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500214}
215
Jamie Madille880e962019-03-11 15:45:31 -0400216executable("glslang_validator") {
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500217 sources = [
218 "StandAlone/DirStackFileIncluder.h",
219 "StandAlone/StandAlone.cpp",
220 ]
221 if (!is_win) {
222 cflags = [ "-Woverflow" ]
223 }
Shahbaz Youssefi741fc4a2019-05-16 23:53:15 -0400224 defines = [ "ENABLE_OPT=1" ]
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500225 deps = [
226 ":glslang_default_resource_limits_sources",
227 ":glslang_sources",
228 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400229
David Turnera3f0da52019-10-23 16:07:19 +0200230 configs -= _configs_to_remove
231 configs += _configs_to_add
Jamie Madill0ceaebc2019-01-18 14:53:31 -0500232}
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200233
234executable("spirv-remap") {
235 sources = [
236 "StandAlone/spirv-remap.cpp",
237 ]
238 defines = [ "ENABLE_OPT=1" ]
239 deps = [
240 ":glslang_sources",
241 ]
Ryan Harrison1aeceae2019-10-15 11:17:53 -0400242
David Turnera3f0da52019-10-23 16:07:19 +0200243 configs -= _configs_to_remove
244 configs += _configs_to_add
David 'Digit' Turner1f5799c2019-06-21 14:58:30 +0200245}