Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 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 | |
David Turner | a3f0da5 | 2019-10-23 16:07:19 +0200 | [diff] [blame] | 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 | |
Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 49 | spirv_tools_dir = glslang_spirv_tools_dir |
Ryan Harrison | eab46cf | 2020-07-07 11:45:02 -0400 | [diff] [blame^] | 50 | if (!defined(glslang_angle)) { |
| 51 | glslang_angle = false |
| 52 | } |
Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 53 | |
| 54 | config("glslang_public") { |
| 55 | include_dirs = [ "." ] |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 56 | } |
Corentin Wallez | 9757da4 | 2019-08-26 14:13:54 +0200 | [diff] [blame] | 57 | |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 58 | config("glslang_hlsl") { |
| 59 | defines = [ "ENABLE_HLSL=1" ] |
Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 60 | } |
| 61 | |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 62 | template("glslang_sources_common") { |
| 63 | source_set(target_name) { |
| 64 | public_configs = [ ":glslang_public" ] |
Corentin Wallez | 6857c23 | 2018-10-03 13:15:23 -0400 | [diff] [blame] | 65 | |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 66 | if (invoker.enable_hlsl) { |
| 67 | public_configs += [ ":glslang_hlsl" ] |
| 68 | } |
| 69 | |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 70 | sources = [ |
| 71 | "OGLCompilersDLL/InitializeDll.cpp", |
| 72 | "OGLCompilersDLL/InitializeDll.h", |
| 73 | "SPIRV/GLSL.ext.AMD.h", |
| 74 | "SPIRV/GLSL.ext.EXT.h", |
| 75 | "SPIRV/GLSL.ext.KHR.h", |
| 76 | "SPIRV/GLSL.ext.NV.h", |
| 77 | "SPIRV/GLSL.std.450.h", |
| 78 | "SPIRV/GlslangToSpv.cpp", |
| 79 | "SPIRV/GlslangToSpv.h", |
| 80 | "SPIRV/InReadableOrder.cpp", |
| 81 | "SPIRV/Logger.cpp", |
| 82 | "SPIRV/Logger.h", |
| 83 | "SPIRV/NonSemanticDebugPrintf.h", |
| 84 | "SPIRV/SPVRemapper.cpp", |
| 85 | "SPIRV/SPVRemapper.h", |
| 86 | "SPIRV/SpvBuilder.cpp", |
| 87 | "SPIRV/SpvBuilder.h", |
| 88 | "SPIRV/SpvPostProcess.cpp", |
| 89 | "SPIRV/SpvTools.cpp", |
| 90 | "SPIRV/SpvTools.h", |
| 91 | "SPIRV/bitutils.h", |
| 92 | "SPIRV/disassemble.cpp", |
| 93 | "SPIRV/disassemble.h", |
| 94 | "SPIRV/doc.cpp", |
| 95 | "SPIRV/doc.h", |
| 96 | "SPIRV/hex_float.h", |
| 97 | "SPIRV/spirv.hpp", |
| 98 | "SPIRV/spvIR.h", |
| 99 | "glslang/GenericCodeGen/CodeGen.cpp", |
| 100 | "glslang/GenericCodeGen/Link.cpp", |
| 101 | "glslang/Include/BaseTypes.h", |
| 102 | "glslang/Include/Common.h", |
| 103 | "glslang/Include/ConstantUnion.h", |
| 104 | "glslang/Include/InfoSink.h", |
| 105 | "glslang/Include/InitializeGlobals.h", |
| 106 | "glslang/Include/PoolAlloc.h", |
| 107 | "glslang/Include/ResourceLimits.h", |
| 108 | "glslang/Include/ShHandle.h", |
| 109 | "glslang/Include/Types.h", |
| 110 | "glslang/Include/arrays.h", |
| 111 | "glslang/Include/intermediate.h", |
| 112 | "glslang/Include/revision.h", |
| 113 | "glslang/MachineIndependent/Constant.cpp", |
| 114 | "glslang/MachineIndependent/InfoSink.cpp", |
| 115 | "glslang/MachineIndependent/Initialize.cpp", |
| 116 | "glslang/MachineIndependent/Initialize.h", |
| 117 | "glslang/MachineIndependent/IntermTraverse.cpp", |
| 118 | "glslang/MachineIndependent/Intermediate.cpp", |
| 119 | "glslang/MachineIndependent/LiveTraverser.h", |
| 120 | "glslang/MachineIndependent/ParseContextBase.cpp", |
| 121 | "glslang/MachineIndependent/ParseHelper.cpp", |
| 122 | "glslang/MachineIndependent/ParseHelper.h", |
| 123 | "glslang/MachineIndependent/PoolAlloc.cpp", |
| 124 | "glslang/MachineIndependent/RemoveTree.cpp", |
| 125 | "glslang/MachineIndependent/RemoveTree.h", |
| 126 | "glslang/MachineIndependent/Scan.cpp", |
| 127 | "glslang/MachineIndependent/Scan.h", |
| 128 | "glslang/MachineIndependent/ScanContext.h", |
| 129 | "glslang/MachineIndependent/ShaderLang.cpp", |
| 130 | "glslang/MachineIndependent/SymbolTable.cpp", |
| 131 | "glslang/MachineIndependent/SymbolTable.h", |
| 132 | "glslang/MachineIndependent/Versions.cpp", |
| 133 | "glslang/MachineIndependent/Versions.h", |
| 134 | "glslang/MachineIndependent/attribute.cpp", |
| 135 | "glslang/MachineIndependent/attribute.h", |
| 136 | "glslang/MachineIndependent/gl_types.h", |
| 137 | "glslang/MachineIndependent/glslang_tab.cpp", |
| 138 | "glslang/MachineIndependent/glslang_tab.cpp.h", |
| 139 | "glslang/MachineIndependent/intermOut.cpp", |
| 140 | "glslang/MachineIndependent/iomapper.cpp", |
| 141 | "glslang/MachineIndependent/iomapper.h", |
| 142 | "glslang/MachineIndependent/limits.cpp", |
| 143 | "glslang/MachineIndependent/linkValidate.cpp", |
| 144 | "glslang/MachineIndependent/localintermediate.h", |
| 145 | "glslang/MachineIndependent/parseConst.cpp", |
| 146 | "glslang/MachineIndependent/parseVersions.h", |
| 147 | "glslang/MachineIndependent/preprocessor/Pp.cpp", |
| 148 | "glslang/MachineIndependent/preprocessor/PpAtom.cpp", |
| 149 | "glslang/MachineIndependent/preprocessor/PpContext.cpp", |
| 150 | "glslang/MachineIndependent/preprocessor/PpContext.h", |
| 151 | "glslang/MachineIndependent/preprocessor/PpScanner.cpp", |
| 152 | "glslang/MachineIndependent/preprocessor/PpTokens.cpp", |
| 153 | "glslang/MachineIndependent/preprocessor/PpTokens.h", |
| 154 | "glslang/MachineIndependent/propagateNoContraction.cpp", |
| 155 | "glslang/MachineIndependent/propagateNoContraction.h", |
| 156 | "glslang/MachineIndependent/reflection.cpp", |
| 157 | "glslang/MachineIndependent/reflection.h", |
| 158 | "glslang/OSDependent/osinclude.h", |
| 159 | "glslang/Public/ShaderLang.h", |
Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 160 | ] |
Dan Sinclair | 257b25c | 2018-09-24 16:35:44 -0400 | [diff] [blame] | 161 | |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 162 | # Workaround gn issue complaining about these not being allowed even though GLSLANG_HLSL is not |
| 163 | # defined. |
| 164 | sources += [ |
| 165 | "glslang/HLSL/hlslParseHelper.h", |
| 166 | "glslang/HLSL/hlslParseables.h", |
| 167 | "glslang/HLSL/hlslScanContext.h", |
| 168 | "glslang/HLSL/hlslTokens.h", |
| 169 | ] |
| 170 | |
| 171 | if (invoker.enable_hlsl) { |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 172 | sources += [ |
| 173 | "glslang/HLSL/hlslAttributes.cpp", |
| 174 | "glslang/HLSL/hlslAttributes.h", |
| 175 | "glslang/HLSL/hlslGrammar.cpp", |
| 176 | "glslang/HLSL/hlslGrammar.h", |
| 177 | "glslang/HLSL/hlslOpMap.cpp", |
| 178 | "glslang/HLSL/hlslOpMap.h", |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 179 | "glslang/HLSL/hlslParseHelper.cpp", |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 180 | "glslang/HLSL/hlslParseables.cpp", |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 181 | "glslang/HLSL/hlslScanContext.cpp", |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 182 | "glslang/HLSL/hlslTokenStream.cpp", |
| 183 | "glslang/HLSL/hlslTokenStream.h", |
| 184 | ] |
| 185 | } |
Ryan Harrison | 1aeceae | 2019-10-15 11:17:53 -0400 | [diff] [blame] | 186 | |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 187 | defines = [] |
| 188 | if (invoker.enable_opt) { |
| 189 | defines += [ "ENABLE_OPT=1" ] |
| 190 | } |
| 191 | |
| 192 | if (is_win) { |
| 193 | sources += [ "glslang/OSDependent/Windows/ossource.cpp" ] |
| 194 | defines += [ "GLSLANG_OSINCLUDE_WIN32" ] |
| 195 | } else { |
| 196 | sources += [ "glslang/OSDependent/Unix/ossource.cpp" ] |
| 197 | defines += [ "GLSLANG_OSINCLUDE_UNIX" ] |
| 198 | } |
| 199 | |
| 200 | if (is_clang) { |
| 201 | cflags = [ |
| 202 | "-Wno-extra-semi", |
| 203 | "-Wno-ignored-qualifiers", |
| 204 | "-Wno-implicit-fallthrough", |
| 205 | "-Wno-inconsistent-missing-override", |
| 206 | "-Wno-sign-compare", |
| 207 | "-Wno-unused-variable", |
| 208 | "-Wno-missing-field-initializers", |
| 209 | "-Wno-newline-eof", |
| 210 | ] |
| 211 | } |
| 212 | if (is_win && !is_clang) { |
| 213 | cflags = [ |
| 214 | "/wd4018", # signed/unsigned mismatch |
| 215 | "/wd4189", # local variable is initialized but not referenced |
| 216 | ] |
| 217 | } |
| 218 | |
| 219 | if (invoker.enable_opt) { |
| 220 | deps = [ |
| 221 | "${spirv_tools_dir}:spvtools_opt", |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 222 | "${spirv_tools_dir}:spvtools_val", |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 223 | ] |
| 224 | } |
| 225 | |
| 226 | configs -= _configs_to_remove |
| 227 | configs += _configs_to_add |
| 228 | } |
| 229 | } |
| 230 | |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 231 | glslang_sources_common("glslang_lib_sources") { |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 232 | enable_opt = !glslang_angle |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 233 | enable_hlsl = !glslang_angle |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 234 | } |
| 235 | |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 236 | glslang_sources_common("glslang_sources") { |
Shahbaz Youssefi | 8f8f1bc | 2020-07-03 12:34:06 -0400 | [diff] [blame] | 237 | enable_opt = true |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 238 | enable_hlsl = true |
Dan Sinclair | b29c58e | 2018-09-24 18:40:38 -0400 | [diff] [blame] | 239 | } |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 240 | |
| 241 | source_set("glslang_default_resource_limits_sources") { |
| 242 | sources = [ |
| 243 | "StandAlone/ResourceLimits.cpp", |
| 244 | "StandAlone/ResourceLimits.h", |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 245 | "glslang/Include/ResourceLimits.h", |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 246 | ] |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 247 | public_configs = [ ":glslang_public" ] |
Ryan Harrison | 1aeceae | 2019-10-15 11:17:53 -0400 | [diff] [blame] | 248 | |
David Turner | a3f0da5 | 2019-10-23 16:07:19 +0200 | [diff] [blame] | 249 | configs -= _configs_to_remove |
| 250 | configs += _configs_to_add |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 251 | } |
| 252 | |
Jamie Madill | e880e96 | 2019-03-11 15:45:31 -0400 | [diff] [blame] | 253 | executable("glslang_validator") { |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 254 | sources = [ |
| 255 | "StandAlone/DirStackFileIncluder.h", |
| 256 | "StandAlone/StandAlone.cpp", |
| 257 | ] |
| 258 | if (!is_win) { |
| 259 | cflags = [ "-Woverflow" ] |
| 260 | } |
Shahbaz Youssefi | 741fc4a | 2019-05-16 23:53:15 -0400 | [diff] [blame] | 261 | defines = [ "ENABLE_OPT=1" ] |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 262 | deps = [ |
| 263 | ":glslang_default_resource_limits_sources", |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 264 | ":glslang_sources", |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 265 | ] |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 266 | public_configs = [ ":glslang_hlsl" ] |
Ryan Harrison | 1aeceae | 2019-10-15 11:17:53 -0400 | [diff] [blame] | 267 | |
David Turner | a3f0da5 | 2019-10-23 16:07:19 +0200 | [diff] [blame] | 268 | configs -= _configs_to_remove |
| 269 | configs += _configs_to_add |
Jamie Madill | 0ceaebc | 2019-01-18 14:53:31 -0500 | [diff] [blame] | 270 | } |
David 'Digit' Turner | 1f5799c | 2019-06-21 14:58:30 +0200 | [diff] [blame] | 271 | |
| 272 | executable("spirv-remap") { |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 273 | sources = [ "StandAlone/spirv-remap.cpp" ] |
David 'Digit' Turner | 1f5799c | 2019-06-21 14:58:30 +0200 | [diff] [blame] | 274 | defines = [ "ENABLE_OPT=1" ] |
Shahbaz Youssefi | a55029d | 2020-07-05 16:48:34 -0400 | [diff] [blame] | 275 | deps = [ ":glslang_sources" ] |
Ryan Harrison | 1aeceae | 2019-10-15 11:17:53 -0400 | [diff] [blame] | 276 | |
David Turner | a3f0da5 | 2019-10-23 16:07:19 +0200 | [diff] [blame] | 277 | configs -= _configs_to_remove |
| 278 | configs += _configs_to_add |
David 'Digit' Turner | 1f5799c | 2019-06-21 14:58:30 +0200 | [diff] [blame] | 279 | } |