Merge pull request #1933 from dj2/runtest
[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 spirv_tools_dir = glslang_spirv_tools_dir
37
38 config("glslang_public") {
39   include_dirs = [ "." ]
40
41   defines = [ "ENABLE_HLSL=1" ]
42 }
43
44 source_set("glslang_sources") {
45   public_configs = [ ":glslang_public" ]
46
47   sources = [
48     "OGLCompilersDLL/InitializeDll.cpp",
49     "OGLCompilersDLL/InitializeDll.h",
50     "SPIRV/GLSL.ext.EXT.h",
51     "SPIRV/GLSL.ext.KHR.h",
52     "SPIRV/GLSL.std.450.h",
53     "SPIRV/GlslangToSpv.cpp",
54     "SPIRV/GlslangToSpv.h",
55     "SPIRV/InReadableOrder.cpp",
56     "SPIRV/Logger.cpp",
57     "SPIRV/Logger.h",
58     "SPIRV/SPVRemapper.cpp",
59     "SPIRV/SPVRemapper.h",
60     "SPIRV/SpvBuilder.cpp",
61     "SPIRV/SpvBuilder.h",
62     "SPIRV/SpvPostProcess.cpp",
63     "SPIRV/SpvTools.cpp",
64     "SPIRV/SpvTools.h",
65     "SPIRV/bitutils.h",
66     "SPIRV/disassemble.cpp",
67     "SPIRV/disassemble.h",
68     "SPIRV/doc.cpp",
69     "SPIRV/doc.h",
70     "SPIRV/hex_float.h",
71     "SPIRV/spirv.hpp",
72     "SPIRV/spvIR.h",
73     "glslang/GenericCodeGen/CodeGen.cpp",
74     "glslang/GenericCodeGen/Link.cpp",
75     "glslang/Include/BaseTypes.h",
76     "glslang/Include/Common.h",
77     "glslang/Include/ConstantUnion.h",
78     "glslang/Include/InfoSink.h",
79     "glslang/Include/InitializeGlobals.h",
80     "glslang/Include/PoolAlloc.h",
81     "glslang/Include/ResourceLimits.h",
82     "glslang/Include/ShHandle.h",
83     "glslang/Include/Types.h",
84     "glslang/Include/arrays.h",
85     "glslang/Include/intermediate.h",
86     "glslang/Include/revision.h",
87     "glslang/MachineIndependent/Constant.cpp",
88     "glslang/MachineIndependent/InfoSink.cpp",
89     "glslang/MachineIndependent/Initialize.cpp",
90     "glslang/MachineIndependent/Initialize.h",
91     "glslang/MachineIndependent/IntermTraverse.cpp",
92     "glslang/MachineIndependent/Intermediate.cpp",
93     "glslang/MachineIndependent/LiveTraverser.h",
94     "glslang/MachineIndependent/ParseContextBase.cpp",
95     "glslang/MachineIndependent/ParseHelper.cpp",
96     "glslang/MachineIndependent/ParseHelper.h",
97     "glslang/MachineIndependent/PoolAlloc.cpp",
98     "glslang/MachineIndependent/RemoveTree.cpp",
99     "glslang/MachineIndependent/RemoveTree.h",
100     "glslang/MachineIndependent/Scan.cpp",
101     "glslang/MachineIndependent/Scan.h",
102     "glslang/MachineIndependent/ScanContext.h",
103     "glslang/MachineIndependent/ShaderLang.cpp",
104     "glslang/MachineIndependent/SymbolTable.cpp",
105     "glslang/MachineIndependent/SymbolTable.h",
106     "glslang/MachineIndependent/Versions.cpp",
107     "glslang/MachineIndependent/Versions.h",
108     "glslang/MachineIndependent/attribute.cpp",
109     "glslang/MachineIndependent/attribute.h",
110     "glslang/MachineIndependent/gl_types.h",
111     "glslang/MachineIndependent/glslang_tab.cpp",
112     "glslang/MachineIndependent/glslang_tab.cpp.h",
113     "glslang/MachineIndependent/intermOut.cpp",
114     "glslang/MachineIndependent/iomapper.cpp",
115     "glslang/MachineIndependent/iomapper.h",
116     "glslang/MachineIndependent/limits.cpp",
117     "glslang/MachineIndependent/linkValidate.cpp",
118     "glslang/MachineIndependent/localintermediate.h",
119     "glslang/MachineIndependent/parseConst.cpp",
120     "glslang/MachineIndependent/parseVersions.h",
121     "glslang/MachineIndependent/preprocessor/Pp.cpp",
122     "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
123     "glslang/MachineIndependent/preprocessor/PpContext.cpp",
124     "glslang/MachineIndependent/preprocessor/PpContext.h",
125     "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
126     "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
127     "glslang/MachineIndependent/preprocessor/PpTokens.h",
128     "glslang/MachineIndependent/propagateNoContraction.cpp",
129     "glslang/MachineIndependent/propagateNoContraction.h",
130     "glslang/MachineIndependent/reflection.cpp",
131     "glslang/MachineIndependent/reflection.h",
132     "glslang/OSDependent/osinclude.h",
133     "glslang/Public/ShaderLang.h",
134     "hlsl/hlslAttributes.cpp",
135     "hlsl/hlslAttributes.h",
136     "hlsl/hlslGrammar.cpp",
137     "hlsl/hlslGrammar.h",
138     "hlsl/hlslOpMap.cpp",
139     "hlsl/hlslOpMap.h",
140     "hlsl/hlslParseHelper.cpp",
141     "hlsl/hlslParseHelper.h",
142     "hlsl/hlslParseables.cpp",
143     "hlsl/hlslParseables.h",
144     "hlsl/hlslScanContext.cpp",
145     "hlsl/hlslScanContext.h",
146     "hlsl/hlslTokenStream.cpp",
147     "hlsl/hlslTokenStream.h",
148     "hlsl/hlslTokens.h",
149   ]
150
151   defines = [ "ENABLE_OPT=1" ]
152
153   if (is_win) {
154     sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
155     defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
156   } else {
157     sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
158     defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
159   }
160
161   if (is_clang) {
162     cflags = [
163       "-Wno-extra-semi",
164       "-Wno-ignored-qualifiers",
165       "-Wno-implicit-fallthrough",
166       "-Wno-inconsistent-missing-override",
167       "-Wno-sign-compare",
168       "-Wno-unused-variable",
169       "-Wno-missing-field-initializers",
170       "-Wno-newline-eof",
171     ]
172   }
173   if (is_win && !is_clang) {
174     cflags = [
175       "/wd4018",  # signed/unsigned mismatch
176       "/wd4189",  # local variable is initialized but not referenced
177     ]
178   }
179
180   deps = [
181     "${spirv_tools_dir}:spvtools_opt",
182     "${spirv_tools_dir}:spvtools_val",
183   ]
184
185   configs -= [ "//build/config/compiler:chromium_code" ]
186   configs += [ "//build/config/compiler:no_chromium_code" ]
187 }
188
189 source_set("glslang_default_resource_limits_sources") {
190   sources = [
191     "StandAlone/ResourceLimits.cpp",
192     "StandAlone/ResourceLimits.h",
193   ]
194   deps = [
195     ":glslang_sources",
196   ]
197   public_configs = [ ":glslang_public" ]
198
199   configs -= [ "//build/config/compiler:chromium_code" ]
200   configs += [ "//build/config/compiler:no_chromium_code" ]
201 }
202
203 executable("glslang_validator") {
204   sources = [
205     "StandAlone/DirStackFileIncluder.h",
206     "StandAlone/StandAlone.cpp",
207   ]
208   if (!is_win) {
209     cflags = [ "-Woverflow" ]
210   }
211   defines = [ "ENABLE_OPT=1" ]
212   deps = [
213     ":glslang_default_resource_limits_sources",
214     ":glslang_sources",
215   ]
216
217   configs -= [ "//build/config/compiler:chromium_code" ]
218   configs += [ "//build/config/compiler:no_chromium_code" ]
219 }
220
221 executable("spirv-remap") {
222   sources = [
223     "StandAlone/spirv-remap.cpp",
224   ]
225   defines = [ "ENABLE_OPT=1" ]
226   deps = [
227     ":glslang_sources",
228   ]
229
230   configs -= [ "//build/config/compiler:chromium_code" ]
231   configs += [ "//build/config/compiler:no_chromium_code" ]
232 }