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