blob: a8ba5d228a915f795d4c2fc7292991c7fc109696 [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001# Copyright 2021 The Dawn & Tint Authors
Ryan Harrisondbc13af2022-02-21 15:19:07 +00002#
Austin Engcc2516a2023-10-17 20:57:54 +00003# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
Ryan Harrisondbc13af2022-02-21 15:19:07 +00005#
Austin Engcc2516a2023-10-17 20:57:54 +00006# 1. Redistributions of source code must retain the above copyright notice, this
7# list of conditions and the following disclaimer.
Ryan Harrisondbc13af2022-02-21 15:19:07 +00008#
Austin Engcc2516a2023-10-17 20:57:54 +00009# 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 Harrisondbc13af2022-02-21 15:19:07 +000027
Ben Clayton7d81e552023-08-17 12:01:50 +000028# GEN_BUILD:DO_NOT_GENERATE - Don't regenerate this file with `./tools run gen`
29
Ryan Harrisondbc13af2022-02-21 15:19:07 +000030import("//build_overrides/build.gni")
Dan Sinclair5ae03c22022-11-03 14:25:37 +000031
dan sinclair2fe7f192023-03-07 18:20:23 +000032import("../../scripts/dawn_overrides_with_defaults.gni")
Ben Clayton66630762023-08-18 08:29:51 +000033import("../../scripts/tint_overrides_with_defaults.gni")
Ryan Harrisondbc13af2022-02-21 15:19:07 +000034
dan sinclair77bf2332022-06-22 12:40:43 +000035if (tint_build_unittests) {
36 import("//testing/test.gni")
37}
38
Ben Clayton7d81e552023-08-17 12:01:50 +000039import("tint.gni")
40
Ryan Harrisondbc13af2022-02-21 15:19:07 +000041###############################################################################
42# Common - Configs, etc. shared across targets
43###############################################################################
44
Ben Clayton44a29b52023-12-04 14:55:01 +000045# tint_gen_dir is the relative path of tint_root_dir to '//', under root_gen_dir
46tint_gen_dir = "${root_gen_dir}/" + rebase_path("${tint_root_dir}", "//")
47
Ryan Harrisondbc13af2022-02-21 15:19:07 +000048config("tint_common_config") {
49 include_dirs = [
Ben Clayton44a29b52023-12-04 14:55:01 +000050 "${tint_root_dir}",
51 "${tint_gen_dir}",
Ryan Harrisondbc13af2022-02-21 15:19:07 +000052 ]
53}
54
55config("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 Claytonf1b8a012023-10-11 17:15:52 +000099 if (tint_build_glsl_validator) {
100 defines += [ "TINT_BUILD_GLSL_VALIDATOR=1" ]
101 } else {
102 defines += [ "TINT_BUILD_GLSL_VALIDATOR=0" ]
103 }
104
dan sinclair0917fbb2023-03-07 18:28:38 +0000105 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 Clayton5c69ff42023-11-23 13:32:36 +0000111 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 Harrisondbc13af2022-02-21 15:19:07 +0000129 include_dirs = [
130 "${tint_root_dir}/",
131 "${tint_root_dir}/include/",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000132 ]
133}
134
135config("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 Clayton30b420d2023-08-22 10:30:58 +0000142source_set("thread") {
143 # GN doesn't appear to need to depend on any thread libraries.
144}
145
Ben Claytone977f542023-08-22 10:30:58 +0000146source_set("metal") {
147 frameworks = [
Ben Clayton89b98282023-09-05 16:28:13 +0000148 "CoreGraphics.framework",
Ben Claytone977f542023-08-22 10:30:58 +0000149 "Foundation.framework",
150 "Metal.framework",
151 ]
152}
153
Ben Clayton7d81e552023-08-17 12:01:50 +0000154config("tint_unittests_config") {
155 include_dirs = [
156 "${tint_googletest_dir}/googlemock/include",
157 "${tint_googletest_dir}/googletest/include",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000158 ]
159
Ben Clayton7d81e552023-08-17 12:01:50 +0000160 configs = [
161 ":tint_common_config",
162 ":tint_public_config",
dan sinclair2da119a2023-01-25 18:39:00 +0000163 ]
164
Ben Clayton7d81e552023-08-17 12:01:50 +0000165 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 Harrisondbc13af2022-02-21 15:19:07 +0000169 }
170}
dan sinclair889a4992022-06-17 13:01:59 +0000171
dan sinclair77bf2332022-06-22 12:40:43 +0000172if (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 sinclair889a4992022-06-17 13:01:59 +0000180
Ben Clayton7d81e552023-08-17 12:01:50 +0000181 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 sinclair77bf2332022-06-22 12:40:43 +0000195 # 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 sinclair889a4992022-06-17 13:01:59 +0000230 }
Ben Clayton7d81e552023-08-17 12:01:50 +0000231}
dan sinclair77bf2332022-06-22 12:40:43 +0000232
Ben Clayton9d1b6102023-09-29 12:12:48 +0000233if (tint_build_benchmarks) {
234 group("google_benchmark") {
235 testonly = true
Ben Clayton089347a2023-09-30 04:19:28 +0000236 public_deps = [ "//third_party/google_benchmark" ]
Ben Clayton9d1b6102023-09-29 12:12:48 +0000237 }
238}
239
Ben Clayton7d81e552023-08-17 12:01:50 +0000240group("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 sinclair77bf2332022-06-22 12:40:43 +0000244 if (build_with_chromium) {
Ben Clayton7d81e552023-08-17 12:01:50 +0000245 public_deps = [ "$dawn_abseil_dir:absl" ]
246 } else {
Geoff Lang29b75b82024-03-15 15:37:07 +0000247 public_deps = [ "${dawn_root}/third_party/gn/abseil-cpp:strings" ]
dan sinclair77bf2332022-06-22 12:40:43 +0000248 }
Ben Clayton7d81e552023-08-17 12:01:50 +0000249}
dan sinclair77bf2332022-06-22 12:40:43 +0000250
dan sinclair46bd2e12023-08-21 20:47:36 +0000251source_set("winsock") {
252 libs = [ "ws2_32.lib" ]
253}
254
Ben Clayton7d81e552023-08-17 12:01:50 +0000255###############################################################################
Ben Clayton6ab54622023-10-02 18:40:36 +0000256# Fuzzers
257###############################################################################
Jim Van Verthac724992023-10-06 17:21:52 +0000258if (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 Clayton6ab54622023-10-02 18:40:36 +0000269}
270
271###############################################################################
Ben Claytond283e952023-10-10 15:30:56 +0000272# Groups
273###############################################################################
274group("libs") {
275 deps = [ "${tint_src_dir}/api" ]
276}
277
278group("cmds") {
Ben Clayton49a564c2023-10-11 16:04:52 +0000279 deps = []
280 if (tint_build_cmds) {
281 deps += [
Ben Claytonb383cf02023-11-11 19:13:28 +0000282 "${tint_src_dir}/cmd/info",
Ben Clayton49a564c2023-10-11 16:04:52 +0000283 "${tint_src_dir}/cmd/remote_compile",
284 "${tint_src_dir}/cmd/tint",
285 ]
Ben Claytond283e952023-10-10 15:30:56 +0000286 }
Ben Claytonf9a5b712024-03-13 17:37:33 +0000287 if (tint_build_tintd) {
288 deps += [ "${tint_src_dir}/cmd/tintd" ]
289 }
Ben Claytond283e952023-10-10 15:30:56 +0000290}
291
292group("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
303group("tests") {
304 testonly = true
305 deps = []
306 if (tint_build_unittests) {
307 deps += [ "${tint_src_dir}/cmd/test:test_cmd" ]
308 }
309}
310
311group("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 Clayton6ab54622023-10-02 18:40:36 +0000320# Aliases
Ben Clayton7d81e552023-08-17 12:01:50 +0000321###############################################################################
Ben Claytond283e952023-10-10 15:30:56 +0000322group("tint_unittests") {
323 testonly = true
324 public_deps = [ ":tests" ]
dan sinclair889a4992022-06-17 13:01:59 +0000325}