From 49a564c40dd569b29fe9e569cd1ace173a170844 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 11 Oct 2023 16:04:52 +0000 Subject: [PATCH] [tint][gn] Only build 'cmd' targets when 'tint_standalone' Chromium builds all the targets it can find. We have build failures when targeting ios. We don't need to build the tint executables in regular chromium builds, so just disable them. Change-Id: I42a92e19ce483fcd0cba92222d4850a73ffd517b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/155701 Kokoro: Ben Clayton Auto-Submit: Ben Clayton Reviewed-by: Antonio Maiorano Commit-Queue: Ben Clayton Kokoro: Kokoro --- BUILD.gn | 5 +---- build_overrides/tint.gni | 1 + scripts/tint_overrides_with_defaults.gni | 12 ++++++++++++ src/tint/BUILD.gn | 9 ++++++--- src/tint/cmd/info/BUILD.gn | 2 +- src/tint/cmd/loopy/BUILD.gn | 2 +- src/tint/cmd/remote_compile/BUILD.gn | 2 +- src/tint/cmd/tint/BUILD.gn | 2 +- src/tint/tint.gni | 15 +++++++++++++-- tools/src/cmd/gen/build/BUILD.gn.tmpl | 2 +- 10 files changed, 38 insertions(+), 14 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 4084b3a182a..da38ee46a27 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -54,14 +54,11 @@ group("all") { testonly = true deps = [ ":benchmarks", + ":cmds", ":fuzzers", ":libs", ":tests", ] - - if (dawn_standalone) { - deps += [ ":cmds" ] - } } # This target is built when no specific target is specified on the command line. diff --git a/build_overrides/tint.gni b/build_overrides/tint.gni index 46355c84fca..48dc59c495d 100644 --- a/build_overrides/tint.gni +++ b/build_overrides/tint.gni @@ -13,6 +13,7 @@ # limitations under the License. # True if Tint can access build/, testing/ and other Chrome folders. +tint_standalone = true tint_has_build = true tint_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src" diff --git a/scripts/tint_overrides_with_defaults.gni b/scripts/tint_overrides_with_defaults.gni index cebe887c514..54585bf93c2 100644 --- a/scripts/tint_overrides_with_defaults.gni +++ b/scripts/tint_overrides_with_defaults.gni @@ -16,6 +16,14 @@ import("//build_overrides/tint.gni") # This file contains Tint-related build flags. +if (!defined(tint_standalone)) { + if (defined(dawn_standalone)) { + tint_standalone = dawn_standalone + } else { + tint_standalone = false + } +} + if (!defined(tint_has_build)) { tint_has_build = true } @@ -48,6 +56,10 @@ declare_args() { tint_spirv_headers_dir = "//third_party/vulkan-deps/spirv-headers/src" } + if (!defined(tint_build_cmds)) { + tint_build_cmds = tint_standalone + } + # Build the SPIR-V input reader if (!defined(tint_build_spv_reader)) { tint_build_spv_reader = true diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 8842398d5b7..7029878b327 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -240,9 +240,12 @@ group("libs") { } group("cmds") { - deps = [ "${tint_src_dir}/cmd/tint" ] - if (dawn_standalone) { - deps += [ "${tint_src_dir}/cmd/remote_compile" ] + deps = [] + if (tint_build_cmds) { + deps += [ + "${tint_src_dir}/cmd/remote_compile", + "${tint_src_dir}/cmd/tint", + ] } } diff --git a/src/tint/cmd/info/BUILD.gn b/src/tint/cmd/info/BUILD.gn index e9d84ce8d6d..79018c2f55e 100644 --- a/src/tint/cmd/info/BUILD.gn +++ b/src/tint/cmd/info/BUILD.gn @@ -25,7 +25,7 @@ import("../../../../scripts/tint_overrides_with_defaults.gni") import("${tint_src_dir}/tint.gni") -executable("info") { +tint_executable("info") { output_name = "tint_info" sources = [ "main.cc" ] deps = [ diff --git a/src/tint/cmd/loopy/BUILD.gn b/src/tint/cmd/loopy/BUILD.gn index 954e5e6a48b..f8b76c935ae 100644 --- a/src/tint/cmd/loopy/BUILD.gn +++ b/src/tint/cmd/loopy/BUILD.gn @@ -25,7 +25,7 @@ import("../../../../scripts/tint_overrides_with_defaults.gni") import("${tint_src_dir}/tint.gni") -executable("loopy") { +tint_executable("loopy") { output_name = "tint_loopy" sources = [ "main.cc" ] deps = [ diff --git a/src/tint/cmd/remote_compile/BUILD.gn b/src/tint/cmd/remote_compile/BUILD.gn index 6d5be7dbb77..58dfd2ea2f6 100644 --- a/src/tint/cmd/remote_compile/BUILD.gn +++ b/src/tint/cmd/remote_compile/BUILD.gn @@ -25,7 +25,7 @@ import("../../../../scripts/tint_overrides_with_defaults.gni") import("${tint_src_dir}/tint.gni") -executable("remote_compile") { +tint_executable("remote_compile") { output_name = "tint_remote_compile" sources = [ "main.cc" ] deps = [ diff --git a/src/tint/cmd/tint/BUILD.gn b/src/tint/cmd/tint/BUILD.gn index 38599603095..b398ecaabe6 100644 --- a/src/tint/cmd/tint/BUILD.gn +++ b/src/tint/cmd/tint/BUILD.gn @@ -25,7 +25,7 @@ import("../../../../scripts/tint_overrides_with_defaults.gni") import("${tint_src_dir}/tint.gni") -executable("tint") { +tint_executable("tint") { output_name = "tint" sources = [ "main.cc" ] deps = [ diff --git a/src/tint/tint.gni b/src/tint/tint.gni index ba3fe747c81..a5b6a2d7054 100644 --- a/src/tint/tint.gni +++ b/src/tint/tint.gni @@ -44,7 +44,18 @@ template("libtint_source_set") { } ############################################################################### -# Unit tests +# Executables - only built when tint_build_cmds is enabled +############################################################################### +template("tint_executable") { + if (tint_build_cmds) { + source_set(target_name) { + forward_variables_from(invoker, "*") + } + } +} + +############################################################################### +# Unit tests - only built when tint_build_unittests is enabled ############################################################################### template("tint_unittests_source_set") { if (tint_build_unittests) { @@ -74,7 +85,7 @@ template("tint_unittests_source_set") { } ############################################################################### -# Fuzzers +# Fuzzers - only built when tint_has_fuzzers is enabled ############################################################################### if (tint_has_fuzzers) { import("//testing/libfuzzer/fuzzer_test.gni") diff --git a/tools/src/cmd/gen/build/BUILD.gn.tmpl b/tools/src/cmd/gen/build/BUILD.gn.tmpl index 780855e48c2..fabe9530289 100644 --- a/tools/src/cmd/gen/build/BUILD.gn.tmpl +++ b/tools/src/cmd/gen/build/BUILD.gn.tmpl @@ -56,7 +56,7 @@ if({{$.Condition}}) { {{ if $.Kind.IsLib -}} libtint_source_set("{{$.Directory.Name}}") { {{- else if $.Kind.IsCmd -}} -executable("{{$.Directory.Name}}") { +tint_executable("{{$.Directory.Name}}") { {{- else if $.Kind.IsTest -}} tint_unittests_source_set("unittests") { {{- else if $.Kind.IsBench -}}