Merge pull request #2139 from neslimsah/master
[platform/upstream/glslang.git] / BUILD.gn
1 # 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
34 import("//build_overrides/glslang.gni")
35
36 # 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.
41 if (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
49 spirv_tools_dir = glslang_spirv_tools_dir
50
51 config("glslang_public") {
52   include_dirs = [ "." ]
53
54   defines = [ "ENABLE_HLSL=1" ]
55 }
56
57 source_set("glslang_sources") {
58   public_configs = [ ":glslang_public" ]
59
60   sources = [
61     "OGLCompilersDLL/InitializeDll.cpp",
62     "OGLCompilersDLL/InitializeDll.h",
63     "SPIRV/GLSL.ext.AMD.h",
64     "SPIRV/GLSL.ext.EXT.h",
65     "SPIRV/GLSL.ext.KHR.h",
66     "SPIRV/GLSL.ext.NV.h",
67     "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/NonSemanticDebugPrintf.h",
74     "SPIRV/SPVRemapper.cpp",
75     "SPIRV/SPVRemapper.h",
76     "SPIRV/SpvBuilder.cpp",
77     "SPIRV/SpvBuilder.h",
78     "SPIRV/SpvPostProcess.cpp",
79     "SPIRV/SpvTools.cpp",
80     "SPIRV/SpvTools.h",
81     "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",
91     "glslang/Include/BaseTypes.h",
92     "glslang/Include/Common.h",
93     "glslang/Include/ConstantUnion.h",
94     "glslang/Include/InfoSink.h",
95     "glslang/Include/InitializeGlobals.h",
96     "glslang/Include/PoolAlloc.h",
97     "glslang/Include/ResourceLimits.h",
98     "glslang/Include/ShHandle.h",
99     "glslang/Include/Types.h",
100     "glslang/Include/arrays.h",
101     "glslang/Include/intermediate.h",
102     "glslang/Include/revision.h",
103     "glslang/MachineIndependent/Constant.cpp",
104     "glslang/MachineIndependent/InfoSink.cpp",
105     "glslang/MachineIndependent/Initialize.cpp",
106     "glslang/MachineIndependent/Initialize.h",
107     "glslang/MachineIndependent/IntermTraverse.cpp",
108     "glslang/MachineIndependent/Intermediate.cpp",
109     "glslang/MachineIndependent/LiveTraverser.h",
110     "glslang/MachineIndependent/ParseContextBase.cpp",
111     "glslang/MachineIndependent/ParseHelper.cpp",
112     "glslang/MachineIndependent/ParseHelper.h",
113     "glslang/MachineIndependent/PoolAlloc.cpp",
114     "glslang/MachineIndependent/RemoveTree.cpp",
115     "glslang/MachineIndependent/RemoveTree.h",
116     "glslang/MachineIndependent/Scan.cpp",
117     "glslang/MachineIndependent/Scan.h",
118     "glslang/MachineIndependent/ScanContext.h",
119     "glslang/MachineIndependent/ShaderLang.cpp",
120     "glslang/MachineIndependent/SymbolTable.cpp",
121     "glslang/MachineIndependent/SymbolTable.h",
122     "glslang/MachineIndependent/Versions.cpp",
123     "glslang/MachineIndependent/Versions.h",
124     "glslang/MachineIndependent/attribute.cpp",
125     "glslang/MachineIndependent/attribute.h",
126     "glslang/MachineIndependent/gl_types.h",
127     "glslang/MachineIndependent/glslang_tab.cpp",
128     "glslang/MachineIndependent/glslang_tab.cpp.h",
129     "glslang/MachineIndependent/intermOut.cpp",
130     "glslang/MachineIndependent/iomapper.cpp",
131     "glslang/MachineIndependent/iomapper.h",
132     "glslang/MachineIndependent/limits.cpp",
133     "glslang/MachineIndependent/linkValidate.cpp",
134     "glslang/MachineIndependent/localintermediate.h",
135     "glslang/MachineIndependent/parseConst.cpp",
136     "glslang/MachineIndependent/parseVersions.h",
137     "glslang/MachineIndependent/preprocessor/Pp.cpp",
138     "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
139     "glslang/MachineIndependent/preprocessor/PpContext.cpp",
140     "glslang/MachineIndependent/preprocessor/PpContext.h",
141     "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
142     "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
143     "glslang/MachineIndependent/preprocessor/PpTokens.h",
144     "glslang/MachineIndependent/propagateNoContraction.cpp",
145     "glslang/MachineIndependent/propagateNoContraction.h",
146     "glslang/MachineIndependent/reflection.cpp",
147     "glslang/MachineIndependent/reflection.h",
148     "glslang/OSDependent/osinclude.h",
149     "glslang/Public/ShaderLang.h",
150     "hlsl/hlslAttributes.cpp",
151     "hlsl/hlslAttributes.h",
152     "hlsl/hlslGrammar.cpp",
153     "hlsl/hlslGrammar.h",
154     "hlsl/hlslOpMap.cpp",
155     "hlsl/hlslOpMap.h",
156     "hlsl/hlslParseHelper.cpp",
157     "hlsl/hlslParseHelper.h",
158     "hlsl/hlslParseables.cpp",
159     "hlsl/hlslParseables.h",
160     "hlsl/hlslScanContext.cpp",
161     "hlsl/hlslScanContext.h",
162     "hlsl/hlslTokenStream.cpp",
163     "hlsl/hlslTokenStream.h",
164     "hlsl/hlslTokens.h",
165   ]
166
167   defines = [ "ENABLE_OPT=1" ]
168
169   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
177   if (is_clang) {
178     cflags = [
179       "-Wno-extra-semi",
180       "-Wno-ignored-qualifiers",
181       "-Wno-implicit-fallthrough",
182       "-Wno-inconsistent-missing-override",
183       "-Wno-sign-compare",
184       "-Wno-unused-variable",
185       "-Wno-missing-field-initializers",
186       "-Wno-newline-eof",
187     ]
188   }
189   if (is_win && !is_clang) {
190     cflags = [
191       "/wd4018",  # signed/unsigned mismatch
192       "/wd4189",  # local variable is initialized but not referenced
193     ]
194   }
195
196   deps = [
197     "${spirv_tools_dir}:spvtools_opt",
198     "${spirv_tools_dir}:spvtools_val",
199   ]
200
201   configs -= _configs_to_remove
202   configs += _configs_to_add
203 }
204
205 source_set("glslang_default_resource_limits_sources") {
206   sources = [
207     "StandAlone/ResourceLimits.cpp",
208     "StandAlone/ResourceLimits.h",
209   ]
210   deps = [
211     ":glslang_sources",
212   ]
213   public_configs = [ ":glslang_public" ]
214
215   configs -= _configs_to_remove
216   configs += _configs_to_add
217 }
218
219 executable("glslang_validator") {
220   sources = [
221     "StandAlone/DirStackFileIncluder.h",
222     "StandAlone/StandAlone.cpp",
223   ]
224   if (!is_win) {
225     cflags = [ "-Woverflow" ]
226   }
227   defines = [ "ENABLE_OPT=1" ]
228   deps = [
229     ":glslang_default_resource_limits_sources",
230     ":glslang_sources",
231   ]
232
233   configs -= _configs_to_remove
234   configs += _configs_to_add
235 }
236
237 executable("spirv-remap") {
238   sources = [
239     "StandAlone/spirv-remap.cpp",
240   ]
241   defines = [ "ENABLE_OPT=1" ]
242   deps = [
243     ":glslang_sources",
244   ]
245
246   configs -= _configs_to_remove
247   configs += _configs_to_add
248 }