Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | # Copyright 2021 The Dawn & Tint Authors |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 2 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are met: |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 5 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | # 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | # list of conditions and the following disclaimer. |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 8 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | # this list of conditions and the following disclaimer in the documentation |
| 11 | # and/or other materials provided with the distribution. |
| 12 | # |
| 13 | # 3. Neither the name of the copyright holder nor the names of its |
| 14 | # contributors may be used to endorse or promote products derived from |
| 15 | # this software without specific prior written permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 27 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 28 | # GEN_BUILD:DO_NOT_GENERATE - Don't regenerate this file with `./tools run gen` |
| 29 | |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 30 | import("//build_overrides/build.gni") |
Dan Sinclair | 5ae03c2 | 2022-11-03 14:25:37 +0000 | [diff] [blame] | 31 | |
dan sinclair | 2fe7f19 | 2023-03-07 18:20:23 +0000 | [diff] [blame] | 32 | import("../../scripts/dawn_overrides_with_defaults.gni") |
Ben Clayton | 6663076 | 2023-08-18 08:29:51 +0000 | [diff] [blame] | 33 | import("../../scripts/tint_overrides_with_defaults.gni") |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 34 | |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 35 | if (tint_build_unittests) { |
| 36 | import("//testing/test.gni") |
| 37 | } |
| 38 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 39 | import("tint.gni") |
| 40 | |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 41 | ############################################################################### |
| 42 | # Common - Configs, etc. shared across targets |
| 43 | ############################################################################### |
| 44 | |
Ben Clayton | 44a29b5 | 2023-12-04 14:55:01 +0000 | [diff] [blame] | 45 | # tint_gen_dir is the relative path of tint_root_dir to '//', under root_gen_dir |
| 46 | tint_gen_dir = "${root_gen_dir}/" + rebase_path("${tint_root_dir}", "//") |
| 47 | |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 48 | config("tint_common_config") { |
| 49 | include_dirs = [ |
Ben Clayton | 44a29b5 | 2023-12-04 14:55:01 +0000 | [diff] [blame] | 50 | "${tint_root_dir}", |
| 51 | "${tint_gen_dir}", |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 52 | ] |
| 53 | } |
| 54 | |
| 55 | config("tint_public_config") { |
| 56 | defines = [] |
| 57 | if (tint_build_spv_reader) { |
| 58 | defines += [ "TINT_BUILD_SPV_READER=1" ] |
| 59 | } else { |
| 60 | defines += [ "TINT_BUILD_SPV_READER=0" ] |
| 61 | } |
| 62 | |
| 63 | if (tint_build_spv_writer) { |
| 64 | defines += [ "TINT_BUILD_SPV_WRITER=1" ] |
| 65 | } else { |
| 66 | defines += [ "TINT_BUILD_SPV_WRITER=0" ] |
| 67 | } |
| 68 | |
| 69 | if (tint_build_wgsl_reader) { |
| 70 | defines += [ "TINT_BUILD_WGSL_READER=1" ] |
| 71 | } else { |
| 72 | defines += [ "TINT_BUILD_WGSL_READER=0" ] |
| 73 | } |
| 74 | |
| 75 | if (tint_build_wgsl_writer) { |
| 76 | defines += [ "TINT_BUILD_WGSL_WRITER=1" ] |
| 77 | } else { |
| 78 | defines += [ "TINT_BUILD_WGSL_WRITER=0" ] |
| 79 | } |
| 80 | |
| 81 | if (tint_build_msl_writer) { |
| 82 | defines += [ "TINT_BUILD_MSL_WRITER=1" ] |
| 83 | } else { |
| 84 | defines += [ "TINT_BUILD_MSL_WRITER=0" ] |
| 85 | } |
| 86 | |
| 87 | if (tint_build_hlsl_writer) { |
| 88 | defines += [ "TINT_BUILD_HLSL_WRITER=1" ] |
| 89 | } else { |
| 90 | defines += [ "TINT_BUILD_HLSL_WRITER=0" ] |
| 91 | } |
| 92 | |
| 93 | if (tint_build_glsl_writer) { |
| 94 | defines += [ "TINT_BUILD_GLSL_WRITER=1" ] |
| 95 | } else { |
| 96 | defines += [ "TINT_BUILD_GLSL_WRITER=0" ] |
| 97 | } |
| 98 | |
Ben Clayton | f1b8a01 | 2023-10-11 17:15:52 +0000 | [diff] [blame] | 99 | if (tint_build_glsl_validator) { |
| 100 | defines += [ "TINT_BUILD_GLSL_VALIDATOR=1" ] |
| 101 | } else { |
| 102 | defines += [ "TINT_BUILD_GLSL_VALIDATOR=0" ] |
| 103 | } |
| 104 | |
dan sinclair | 0917fbb | 2023-03-07 18:28:38 +0000 | [diff] [blame] | 105 | if (tint_build_syntax_tree_writer) { |
| 106 | defines += [ "TINT_BUILD_SYNTAX_TREE_WRITER=1" ] |
| 107 | } else { |
| 108 | defines += [ "TINT_BUILD_SYNTAX_TREE_WRITER=0" ] |
| 109 | } |
| 110 | |
Ben Clayton | 5c69ff4 | 2023-11-23 13:32:36 +0000 | [diff] [blame] | 111 | if (tint_build_is_win) { |
| 112 | defines += [ "TINT_BUILD_IS_WIN=1" ] |
| 113 | } else { |
| 114 | defines += [ "TINT_BUILD_IS_WIN=0" ] |
| 115 | } |
| 116 | |
| 117 | if (tint_build_is_mac) { |
| 118 | defines += [ "TINT_BUILD_IS_MAC=1" ] |
| 119 | } else { |
| 120 | defines += [ "TINT_BUILD_IS_MAC=0" ] |
| 121 | } |
| 122 | |
| 123 | if (tint_build_is_linux) { |
| 124 | defines += [ "TINT_BUILD_IS_LINUX=1" ] |
| 125 | } else { |
| 126 | defines += [ "TINT_BUILD_IS_LINUX=0" ] |
| 127 | } |
| 128 | |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 129 | include_dirs = [ |
| 130 | "${tint_root_dir}/", |
| 131 | "${tint_root_dir}/include/", |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 132 | ] |
| 133 | } |
| 134 | |
| 135 | config("tint_config") { |
| 136 | include_dirs = [] |
| 137 | if (tint_build_spv_reader || tint_build_spv_writer) { |
| 138 | include_dirs += [ "${tint_spirv_tools_dir}/include/" ] |
| 139 | } |
| 140 | } |
| 141 | |
Ben Clayton | 30b420d | 2023-08-22 10:30:58 +0000 | [diff] [blame] | 142 | source_set("thread") { |
| 143 | # GN doesn't appear to need to depend on any thread libraries. |
| 144 | } |
| 145 | |
Ben Clayton | e977f54 | 2023-08-22 10:30:58 +0000 | [diff] [blame] | 146 | source_set("metal") { |
| 147 | frameworks = [ |
Ben Clayton | 89b9828 | 2023-09-05 16:28:13 +0000 | [diff] [blame] | 148 | "CoreGraphics.framework", |
Ben Clayton | e977f54 | 2023-08-22 10:30:58 +0000 | [diff] [blame] | 149 | "Foundation.framework", |
| 150 | "Metal.framework", |
| 151 | ] |
| 152 | } |
| 153 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 154 | config("tint_unittests_config") { |
| 155 | include_dirs = [ |
| 156 | "${tint_googletest_dir}/googlemock/include", |
| 157 | "${tint_googletest_dir}/googletest/include", |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 158 | ] |
| 159 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 160 | configs = [ |
| 161 | ":tint_common_config", |
| 162 | ":tint_public_config", |
dan sinclair | 2da119a | 2023-01-25 18:39:00 +0000 | [diff] [blame] | 163 | ] |
| 164 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 165 | if (is_win && is_debug) { |
| 166 | # TODO(crbug.com/tint/1749): both msvc and clang builds stack overflow on debug builds. |
| 167 | # Increase the initial stack size to 4 MB (default is 1MB). |
| 168 | ldflags = [ "/STACK:4194304" ] |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 169 | } |
| 170 | } |
dan sinclair | 889a499 | 2022-06-17 13:01:59 +0000 | [diff] [blame] | 171 | |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 172 | if (tint_build_unittests) { |
| 173 | ############################################################################### |
| 174 | # Gtest Gmock - Handle building inside and outside of Chromium. |
| 175 | ############################################################################### |
| 176 | # When building outside of Chromium we need to define our own targets for GTest |
| 177 | # and GMock. However when compiling inside of Chromium we need to reuse the |
| 178 | # existing targets, both because Chromium has a special harness for swarming |
| 179 | # and because otherwise the "gn check" fails. |
dan sinclair | 889a499 | 2022-06-17 13:01:59 +0000 | [diff] [blame] | 180 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 181 | if (build_with_chromium) { |
| 182 | # When we are in Chromium we reuse its targets, and also add some deps that |
| 183 | # are needed to launch the test in swarming mode. |
| 184 | group("gmock_and_gtest") { |
| 185 | testonly = true |
| 186 | public_deps = [ |
| 187 | "//base", |
| 188 | "//base/test:test_support", |
| 189 | "//testing/gmock", |
| 190 | "//testing/gtest", |
| 191 | "//third_party/googletest:gmock", |
| 192 | ] |
| 193 | } |
| 194 | } else { |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 195 | # When we aren't in Chromium we define out own targets based on the location |
| 196 | # of the googletest repo. |
| 197 | config("gtest_config") { |
| 198 | include_dirs = [ |
| 199 | "${tint_googletest_dir}/googletest", |
| 200 | "${tint_googletest_dir}/googletest/include", |
| 201 | ] |
| 202 | } |
| 203 | static_library("gtest") { |
| 204 | testonly = true |
| 205 | sources = [ "${tint_googletest_dir}/googletest/src/gtest-all.cc" ] |
| 206 | public_configs = [ ":gtest_config" ] |
| 207 | } |
| 208 | |
| 209 | config("gmock_config") { |
| 210 | include_dirs = [ |
| 211 | "${tint_googletest_dir}/googlemock", |
| 212 | "${tint_googletest_dir}/googlemock/include", |
| 213 | "${tint_googletest_dir}/googletest/include", |
| 214 | ] |
| 215 | } |
| 216 | |
| 217 | static_library("gmock") { |
| 218 | testonly = true |
| 219 | sources = [ "${tint_googletest_dir}/googlemock/src/gmock-all.cc" ] |
| 220 | public_configs = [ ":gmock_config" ] |
| 221 | } |
| 222 | |
| 223 | group("gmock_and_gtest") { |
| 224 | testonly = true |
| 225 | public_deps = [ |
| 226 | ":gmock", |
| 227 | ":gtest", |
| 228 | ] |
| 229 | } |
dan sinclair | 889a499 | 2022-06-17 13:01:59 +0000 | [diff] [blame] | 230 | } |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 231 | } |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 232 | |
Ben Clayton | 9d1b610 | 2023-09-29 12:12:48 +0000 | [diff] [blame] | 233 | if (tint_build_benchmarks) { |
| 234 | group("google_benchmark") { |
| 235 | testonly = true |
Ben Clayton | 089347a | 2023-09-30 04:19:28 +0000 | [diff] [blame] | 236 | public_deps = [ "//third_party/google_benchmark" ] |
Ben Clayton | 9d1b610 | 2023-09-29 12:12:48 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 240 | group("abseil") { |
| 241 | # When build_with_chromium=true we need to include "//third_party/abseil-cpp:absl" while |
| 242 | # it's beneficial to be more specific with standalone Dawn, especially when it comes to |
| 243 | # including it as a dependency in other projects (such as Skia). |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 244 | if (build_with_chromium) { |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 245 | public_deps = [ "$dawn_abseil_dir:absl" ] |
| 246 | } else { |
Geoff Lang | 29b75b8 | 2024-03-15 15:37:07 +0000 | [diff] [blame] | 247 | public_deps = [ "${dawn_root}/third_party/gn/abseil-cpp:strings" ] |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 248 | } |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 249 | } |
dan sinclair | 77bf233 | 2022-06-22 12:40:43 +0000 | [diff] [blame] | 250 | |
dan sinclair | 46bd2e1 | 2023-08-21 20:47:36 +0000 | [diff] [blame] | 251 | source_set("winsock") { |
| 252 | libs = [ "ws2_32.lib" ] |
| 253 | } |
| 254 | |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 255 | ############################################################################### |
Ben Clayton | 6ab5462 | 2023-10-02 18:40:36 +0000 | [diff] [blame] | 256 | # Fuzzers |
| 257 | ############################################################################### |
Jim Van Verth | ac72499 | 2023-10-06 17:21:52 +0000 | [diff] [blame] | 258 | if (tint_has_fuzzers) { |
| 259 | action("tint_generate_wgsl_corpus") { |
| 260 | script = "${tint_src_dir}/cmd/fuzz/wgsl/generate_wgsl_corpus.py" |
| 261 | sources = [ "${tint_src_dir}/cmd/fuzz/wgsl/generate_wgsl_corpus.py" ] |
| 262 | args = [ |
| 263 | "--stamp=" + rebase_path(fuzzer_corpus_wgsl_stamp, root_build_dir), |
| 264 | rebase_path("${tint_root_dir}/test", root_build_dir), |
| 265 | rebase_path(fuzzer_corpus_wgsl_dir, root_build_dir), |
| 266 | ] |
| 267 | outputs = [ fuzzer_corpus_wgsl_stamp ] |
| 268 | } |
Ben Clayton | 6ab5462 | 2023-10-02 18:40:36 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | ############################################################################### |
Ben Clayton | d283e95 | 2023-10-10 15:30:56 +0000 | [diff] [blame] | 272 | # Groups |
| 273 | ############################################################################### |
| 274 | group("libs") { |
| 275 | deps = [ "${tint_src_dir}/api" ] |
| 276 | } |
| 277 | |
| 278 | group("cmds") { |
Ben Clayton | 49a564c | 2023-10-11 16:04:52 +0000 | [diff] [blame] | 279 | deps = [] |
| 280 | if (tint_build_cmds) { |
| 281 | deps += [ |
Ben Clayton | b383cf0 | 2023-11-11 19:13:28 +0000 | [diff] [blame] | 282 | "${tint_src_dir}/cmd/info", |
Ben Clayton | 49a564c | 2023-10-11 16:04:52 +0000 | [diff] [blame] | 283 | "${tint_src_dir}/cmd/remote_compile", |
| 284 | "${tint_src_dir}/cmd/tint", |
| 285 | ] |
Ben Clayton | d283e95 | 2023-10-10 15:30:56 +0000 | [diff] [blame] | 286 | } |
Ben Clayton | f9a5b71 | 2024-03-13 17:37:33 +0000 | [diff] [blame] | 287 | if (tint_build_tintd) { |
| 288 | deps += [ "${tint_src_dir}/cmd/tintd" ] |
| 289 | } |
Ben Clayton | d283e95 | 2023-10-10 15:30:56 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | group("fuzzers") { |
| 293 | testonly = true |
| 294 | deps = [] |
| 295 | if (tint_has_fuzzers) { |
| 296 | deps += [ |
| 297 | "${tint_src_dir}/cmd/fuzz/wgsl", |
| 298 | "${tint_src_dir}/fuzzers", |
| 299 | ] |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | group("tests") { |
| 304 | testonly = true |
| 305 | deps = [] |
| 306 | if (tint_build_unittests) { |
| 307 | deps += [ "${tint_src_dir}/cmd/test:test_cmd" ] |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | group("benchmarks") { |
| 312 | testonly = true |
| 313 | deps = [] |
| 314 | if (tint_build_benchmarks) { |
| 315 | deps += [ "${tint_src_dir}/cmd/bench:bench_cmd" ] |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | ############################################################################### |
Ben Clayton | 6ab5462 | 2023-10-02 18:40:36 +0000 | [diff] [blame] | 320 | # Aliases |
Ben Clayton | 7d81e55 | 2023-08-17 12:01:50 +0000 | [diff] [blame] | 321 | ############################################################################### |
Ben Clayton | d283e95 | 2023-10-10 15:30:56 +0000 | [diff] [blame] | 322 | group("tint_unittests") { |
| 323 | testonly = true |
| 324 | public_deps = [ ":tests" ] |
dan sinclair | 889a499 | 2022-06-17 13:01:59 +0000 | [diff] [blame] | 325 | } |