[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 <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 4084b3a..da38ee4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -54,14 +54,11 @@
   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 46355c8..48dc59c 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 cebe887..54585bf 100644
--- a/scripts/tint_overrides_with_defaults.gni
+++ b/scripts/tint_overrides_with_defaults.gni
@@ -16,6 +16,14 @@
 
 # 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 @@
     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 8842398..7029878 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -240,9 +240,12 @@
 }
 
 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 e9d84ce..79018c2 100644
--- a/src/tint/cmd/info/BUILD.gn
+++ b/src/tint/cmd/info/BUILD.gn
@@ -25,7 +25,7 @@
 
 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 954e5e6..f8b76c9 100644
--- a/src/tint/cmd/loopy/BUILD.gn
+++ b/src/tint/cmd/loopy/BUILD.gn
@@ -25,7 +25,7 @@
 
 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 6d5be7d..58dfd2e 100644
--- a/src/tint/cmd/remote_compile/BUILD.gn
+++ b/src/tint/cmd/remote_compile/BUILD.gn
@@ -25,7 +25,7 @@
 
 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 3859960..b398eca 100644
--- a/src/tint/cmd/tint/BUILD.gn
+++ b/src/tint/cmd/tint/BUILD.gn
@@ -25,7 +25,7 @@
 
 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 ba3fe74..a5b6a2d 100644
--- a/src/tint/tint.gni
+++ b/src/tint/tint.gni
@@ -44,7 +44,18 @@
 }
 
 ###############################################################################
-# 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 @@
 }
 
 ###############################################################################
-# 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 780855e..fabe953 100644
--- a/tools/src/cmd/gen/build/BUILD.gn.tmpl
+++ b/tools/src/cmd/gen/build/BUILD.gn.tmpl
@@ -56,7 +56,7 @@
 {{  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 -}}