yum-mirror/glslang

git clone https://git.yummers.dev/yum-mirror/glslang

Matt TurnerCheck error message formats with the printf format attribute31b9aacf

main
11.6 KiB364 linesraw
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# The GN build for Glslang.
35# See the DEPS for usage instructions.
36
37import("gn_scripts/glslang_overrides_with_defaults.gni")
38
39# Both Chromium and Fuchsia use by default a set of warning errors
40# that is far too strict to compile this project. These are also
41# typically appended after |cflags|, overriding target-specific
42# definitions. To work around this, determine which configs to
43# add and remove in order to succesfully build the project.
44if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
45  _configs_to_remove = [ "//build/config:default_warnings" ]
46  _configs_to_add = []
47} else {
48  _configs_to_remove = [ "//build/config/compiler:chromium_code" ]
49  _configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
50}
51
52if (current_toolchain == default_toolchain) {
53  if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
54    import("//build/git/git_revisions.gni")
55  }
56
57  action("glslang_build_info") {
58    script = "build_info.py"
59
60    src_dir = "."
61    changes_file = "CHANGES.md"
62    template_file = "build_info.h.tmpl"
63    out_file = "${target_gen_dir}/include/glslang/build_info.h"
64
65    inputs = [
66      changes_file,
67      script,
68      template_file,
69    ]
70    if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
71      inputs += [ git_paths.glslang_head ]
72    }
73    outputs = [ out_file ]
74    args = [
75      rebase_path(src_dir, root_build_dir),
76      "-i",
77      rebase_path(template_file, root_build_dir),
78      "-o",
79      rebase_path(out_file, root_build_dir),
80    ]
81  }
82} else {
83  group("glslang_build_info") {
84    public_deps = [ ":glslang_build_info($default_toolchain)" ]
85  }
86}
87
88action("glslang_extension_headers") {
89  script = "gen_extension_headers.py"
90
91  out_file = "${target_gen_dir}/include/glslang/glsl_intrinsic_header.h"
92
93  # Fuchsia GN build rules require all GN actions to be hermetic and they
94  # should correctly and fully state their inputs and outpus (see
95  # https://fuchsia.dev/fuchsia-src/development/build/hermetic_actions
96  # for details). All input files of the script should be added to the
97  # |sources| list.
98  sources = [
99    "glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl",
100  ]
101
102  inputs = [
103    script
104  ]
105  outputs = [ out_file ]
106  args = [
107    "-i",
108    rebase_path("glslang/ExtensionHeaders", root_build_dir),
109    "-o",
110    rebase_path(out_file, root_build_dir),
111  ]
112}
113
114spirv_tools_dir = glslang_spirv_tools_dir
115
116config("glslang_public") {
117  include_dirs = [ "." ]
118  if (!is_win || is_clang) {
119    cflags = [ "-Wno-conversion" ]
120  }
121}
122
123config("glslang_hlsl") {
124  defines = [ "ENABLE_HLSL=1" ]
125}
126
127template("glslang_sources_common") {
128  source_set(target_name) {
129    public_configs = [ ":glslang_public" ]
130
131    if (invoker.enable_hlsl) {
132      public_configs += [ ":glslang_hlsl" ]
133    }
134
135    sources = [
136      "SPIRV/GLSL.ext.AMD.h",
137      "SPIRV/GLSL.ext.EXT.h",
138      "SPIRV/GLSL.ext.KHR.h",
139      "SPIRV/GLSL.ext.NV.h",
140      "SPIRV/GLSL.ext.ARM.h",
141      "SPIRV/GLSL.ext.QCOM.h",
142      "SPIRV/GLSL.std.450.h",
143      "SPIRV/GlslangToSpv.cpp",
144      "SPIRV/GlslangToSpv.h",
145      "SPIRV/InReadableOrder.cpp",
146      "SPIRV/Logger.cpp",
147      "SPIRV/Logger.h",
148      "SPIRV/NonSemanticDebugPrintf.h",
149      "SPIRV/NonSemanticShaderDebugInfo.h",
150      "SPIRV/SpvBuilder.cpp",
151      "SPIRV/SpvBuilder.h",
152      "SPIRV/SpvPostProcess.cpp",
153      "SPIRV/SpvTools.h",
154      "SPIRV/bitutils.h",
155      "SPIRV/disassemble.cpp",
156      "SPIRV/disassemble.h",
157      "SPIRV/doc.cpp",
158      "SPIRV/doc.h",
159      "SPIRV/hex_float.h",
160      "SPIRV/spirv.hpp11",
161      "SPIRV/spvIR.h",
162      "SPIRV/spvUtil.h",
163      "glslang/GenericCodeGen/CodeGen.cpp",
164      "glslang/GenericCodeGen/Link.cpp",
165      "glslang/Include/BaseTypes.h",
166      "glslang/Include/Common.h",
167      "glslang/Include/ConstantUnion.h",
168      "glslang/Include/InfoSink.h",
169      "glslang/Include/InitializeGlobals.h",
170      "glslang/Include/PoolAlloc.h",
171      "glslang/Include/ResourceLimits.h",
172      "glslang/Include/ShHandle.h",
173      "glslang/Include/SpirvIntrinsics.h",
174      "glslang/Include/Types.h",
175      "glslang/Include/arrays.h",
176      "glslang/Include/defer.h",
177      "glslang/Include/intermediate.h",
178      "glslang/Include/visibility.h",
179      "glslang/MachineIndependent/Constant.cpp",
180      "glslang/MachineIndependent/InfoSink.cpp",
181      "glslang/MachineIndependent/Initialize.cpp",
182      "glslang/MachineIndependent/Initialize.h",
183      "glslang/MachineIndependent/IntermTraverse.cpp",
184      "glslang/MachineIndependent/Intermediate.cpp",
185      "glslang/MachineIndependent/LiveTraverser.h",
186      "glslang/MachineIndependent/ParseContextBase.cpp",
187      "glslang/MachineIndependent/ParseHelper.cpp",
188      "glslang/MachineIndependent/ParseHelper.h",
189      "glslang/MachineIndependent/PoolAlloc.cpp",
190      "glslang/MachineIndependent/RemoveTree.cpp",
191      "glslang/MachineIndependent/RemoveTree.h",
192      "glslang/MachineIndependent/Scan.cpp",
193      "glslang/MachineIndependent/Scan.h",
194      "glslang/MachineIndependent/ScanContext.h",
195      "glslang/MachineIndependent/ShaderLang.cpp",
196      "glslang/MachineIndependent/SpirvIntrinsics.cpp",
197      "glslang/MachineIndependent/SymbolTable.cpp",
198      "glslang/MachineIndependent/SymbolTable.h",
199      "glslang/MachineIndependent/Versions.cpp",
200      "glslang/MachineIndependent/Versions.h",
201      "glslang/MachineIndependent/attribute.cpp",
202      "glslang/MachineIndependent/attribute.h",
203      "glslang/MachineIndependent/gl_types.h",
204      "glslang/MachineIndependent/glslang_tab.cpp",
205      "glslang/MachineIndependent/glslang_tab.cpp.h",
206      "glslang/MachineIndependent/intermOut.cpp",
207      "glslang/MachineIndependent/iomapper.cpp",
208      "glslang/MachineIndependent/iomapper.h",
209      "glslang/MachineIndependent/limits.cpp",
210      "glslang/MachineIndependent/linkValidate.cpp",
211      "glslang/MachineIndependent/localintermediate.h",
212      "glslang/MachineIndependent/parseConst.cpp",
213      "glslang/MachineIndependent/parseVersions.h",
214      "glslang/MachineIndependent/preprocessor/Pp.cpp",
215      "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
216      "glslang/MachineIndependent/preprocessor/PpContext.cpp",
217      "glslang/MachineIndependent/preprocessor/PpContext.h",
218      "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
219      "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
220      "glslang/MachineIndependent/preprocessor/PpTokens.h",
221      "glslang/MachineIndependent/propagateNoContraction.cpp",
222      "glslang/MachineIndependent/propagateNoContraction.h",
223      "glslang/MachineIndependent/reflection.cpp",
224      "glslang/MachineIndependent/reflection.h",
225      "glslang/OSDependent/osinclude.h",
226      "glslang/Public/ShaderLang.h",
227    ]
228
229    # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not
230    # defined.
231    sources += [
232      "glslang/HLSL/hlslParseHelper.h",
233      "glslang/HLSL/hlslParseables.h",
234      "glslang/HLSL/hlslScanContext.h",
235      "glslang/HLSL/hlslTokens.h",
236    ]
237
238    if (invoker.enable_hlsl) {
239      sources += [
240        "glslang/HLSL/hlslAttributes.cpp",
241        "glslang/HLSL/hlslAttributes.h",
242        "glslang/HLSL/hlslGrammar.cpp",
243        "glslang/HLSL/hlslGrammar.h",
244        "glslang/HLSL/hlslOpMap.cpp",
245        "glslang/HLSL/hlslOpMap.h",
246        "glslang/HLSL/hlslParseHelper.cpp",
247        "glslang/HLSL/hlslParseables.cpp",
248        "glslang/HLSL/hlslScanContext.cpp",
249        "glslang/HLSL/hlslTokenStream.cpp",
250        "glslang/HLSL/hlslTokenStream.h",
251      ]
252    }
253
254    defines = [ "ENABLE_SPIRV=1" ]
255    if (invoker.enable_opt) {
256      sources += [ "SPIRV/SpvTools.cpp" ]
257      defines += [ "ENABLE_OPT=1" ]
258    }
259
260    if (is_win) {
261      sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
262      defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
263    } else {
264      sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
265      defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
266    }
267
268    if (is_clang) {
269      cflags = [
270        "-Wno-extra-semi",
271        "-Wno-ignored-qualifiers",
272        "-Wno-implicit-fallthrough",
273        "-Wno-inconsistent-missing-override",
274        "-Wno-missing-field-initializers",
275        "-Wno-newline-eof",
276        "-Wno-sign-compare",
277        "-Wno-suggest-destructor-override",
278        "-Wno-suggest-override",
279        "-Wno-unused-variable",
280      ]
281    }
282    if (!is_win && !is_clang) {
283      # error() and friends take "" as the format when there is no extra info.
284      cflags = [ "-Wno-format-zero-length" ]
285    }
286    if (is_win && !is_clang) {
287      cflags = [
288        "/wd4018",  # signed/unsigned mismatch
289        "/wd4189",  # local variable is initialized but not referenced
290      ]
291    }
292
293    include_dirs = [ get_label_info(":glslang_build_info($default_toolchain)",
294                                    "target_gen_dir") + "/include" ]
295
296    deps = [ ":glslang_build_info" ]
297
298    if (invoker.enable_opt) {
299      deps += [
300        "${spirv_tools_dir}:spvtools_opt",
301        "${spirv_tools_dir}:spvtools_val",
302      ]
303      include_dirs += [ "${spirv_tools_dir}/include" ]
304    }
305
306    configs -= _configs_to_remove
307    configs += _configs_to_add
308  }
309}
310
311glslang_sources_common("glslang_lib_sources") {
312  enable_opt = true
313  enable_hlsl = glslang_enable_hlsl
314}
315
316glslang_sources_common("glslang_sources") {
317  enable_opt = true
318  enable_hlsl = glslang_enable_hlsl
319}
320
321source_set("glslang_default_resource_limits_sources") {
322  sources = [
323    "glslang/ResourceLimits/ResourceLimits.cpp",
324    "glslang/Public/ResourceLimits.h",
325    "glslang/Include/ResourceLimits.h",
326    "glslang/Include/visibility.h",
327  ]
328  public_configs = [ ":glslang_public" ]
329
330  configs -= _configs_to_remove
331  configs += _configs_to_add
332}
333
334executable("glslang_validator") {
335  sources = [
336    "StandAlone/DirStackFileIncluder.h",
337    "StandAlone/StandAlone.cpp",
338  ]
339  if (!is_win) {
340    cflags = [ "-Woverflow" ]
341  }
342  defines = [
343    "ENABLE_OPT=1",
344    "ENABLE_SPIRV=1",
345  ]
346  deps = [
347    ":glslang_build_info",
348    ":glslang_default_resource_limits_sources",
349    ":glslang_sources",
350    ":glslang_extension_headers",
351  ]
352  if (glslang_enable_hlsl) {
353    public_configs = [ ":glslang_hlsl" ]
354  }
355
356  include_dirs = [
357    get_label_info(":glslang_build_info($default_toolchain)",
358                   "target_gen_dir") + "/include",
359    "${spirv_tools_dir}/include",
360  ]
361
362  configs -= _configs_to_remove
363  configs += _configs_to_add
364}