[gn] Disable fuzzers when '[dawn|tint]_has_build' is false

Change-Id: Icd8521e0021ea59af9dcad83521fa608c3ee08b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/154541
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
diff --git a/build_overrides/tint.gni b/build_overrides/tint.gni
index 7d5af1a..46355c8 100644
--- a/build_overrides/tint.gni
+++ b/build_overrides/tint.gni
@@ -12,6 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# True if Tint can access build/, testing/ and other Chrome folders.
+tint_has_build = true
+
 tint_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src"
 tint_spirv_headers_dir = "//third_party/vulkan-deps/spirv-headers/src"
 tint_glslang_dir = "//third_party/vulkan-deps/glslang/src"
diff --git a/scripts/dawn_overrides_with_defaults.gni b/scripts/dawn_overrides_with_defaults.gni
index d1f268e..50d94ea 100644
--- a/scripts/dawn_overrides_with_defaults.gni
+++ b/scripts/dawn_overrides_with_defaults.gni
@@ -28,6 +28,8 @@
   dawn_has_build = true
 }
 
+dawn_has_fuzzers = dawn_has_build
+
 if (!defined(dawn_root)) {
   dawn_root = get_path_info("..", "abspath")
 }
diff --git a/scripts/tint_overrides_with_defaults.gni b/scripts/tint_overrides_with_defaults.gni
index df509f1..cebe887 100644
--- a/scripts/tint_overrides_with_defaults.gni
+++ b/scripts/tint_overrides_with_defaults.gni
@@ -16,6 +16,12 @@
 
 # This file contains Tint-related build flags.
 
+if (!defined(tint_has_build)) {
+  tint_has_build = true
+}
+
+tint_has_fuzzers = tint_has_build
+
 declare_args() {
   # Path to tint checkout
   if (!defined(tint_root_dir)) {
diff --git a/src/dawn/fuzzers/BUILD.gn b/src/dawn/fuzzers/BUILD.gn
index a6296b3..2fd2a26 100644
--- a/src/dawn/fuzzers/BUILD.gn
+++ b/src/dawn/fuzzers/BUILD.gn
@@ -14,138 +14,141 @@
 
 import("../../../scripts/dawn_overrides_with_defaults.gni")
 
-import("//build_overrides/build.gni")
-import("//testing/libfuzzer/fuzzer_test.gni")
-import("${dawn_root}/scripts/dawn_features.gni")
-import("${dawn_root}/src/dawn/fuzzers/dawn_fuzzers.gni")
+if (dawn_has_fuzzers) {
+  import("//build_overrides/build.gni")
+  import("//testing/libfuzzer/fuzzer_test.gni")
+  import("${dawn_root}/scripts/dawn_features.gni")
+  import("${dawn_root}/src/dawn/fuzzers/dawn_fuzzers.gni")
 
-static_library("dawn_wire_server_fuzzer_common") {
-  sources = [
-    "DawnWireServerFuzzer.cpp",
-    "DawnWireServerFuzzer.h",
-  ]
-  public_deps = [
-    "${dawn_root}/src/dawn:cpp",
-    "${dawn_root}/src/dawn:proc",
-    "${dawn_root}/src/dawn/common",
-    "${dawn_root}/src/dawn/native:static",
-    "${dawn_root}/src/dawn/utils",
-    "${dawn_root}/src/dawn/wire:static",
-  ]
-}
+  static_library("dawn_wire_server_fuzzer_common") {
+    sources = [
+      "DawnWireServerFuzzer.cpp",
+      "DawnWireServerFuzzer.h",
+    ]
+    public_deps = [
+      "${dawn_root}/src/dawn:cpp",
+      "${dawn_root}/src/dawn:proc",
+      "${dawn_root}/src/dawn/common",
+      "${dawn_root}/src/dawn/native:static",
+      "${dawn_root}/src/dawn/utils",
+      "${dawn_root}/src/dawn/wire:static",
+    ]
+  }
 
-fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
-  sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ]
-
-  deps = [ ":dawn_wire_server_fuzzer_common" ]
-
-  additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
-}
-
-if (is_win) {
-  fuzzer_test("dawn_wire_server_and_d3d12_backend_fuzzer") {
-    sources = [ "DawnWireServerAndD3D12BackendFuzzer.cpp" ]
+  fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
+    sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ]
 
     deps = [ ":dawn_wire_server_fuzzer_common" ]
 
     additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
   }
-}
-
-fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") {
-  sources = [ "DawnWireServerAndVulkanBackendFuzzer.cpp" ]
-
-  deps = [ ":dawn_wire_server_fuzzer_common" ]
-
-  additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
-}
-
-if (is_dawn_lpm_fuzzer && build_with_chromium && dawn_use_swiftshader &&
-    !disable_libfuzzer && use_fuzzing_engine) {
-  import("//third_party/protobuf/proto_library.gni")
-  import("${dawn_root}/generator/dawn_generator.gni")
-
-  # Generate the fuzzer's serializer in `.cpp`
-  dawn_json_lpm_generator("dawn_lpmfuzz_cpp") {
-    target = "dawn_lpmfuzz_cpp"
-    outputs = [
-      "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.cpp",
-      "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.h",
-      "src/dawn/fuzzers/lpmfuzz/DawnLPMConstants_autogen.h",
-    ]
-  }
-
-  # Generate the `.proto` files
-  dawn_json_lpm_generator("dawn_lpmfuzz_proto") {
-    target = "dawn_lpmfuzz_proto"
-    outputs = [
-      "src/dawn/fuzzers/lpmfuzz/dawn_lpm_autogen.proto",
-      "src/dawn/fuzzers/lpmfuzz/dawn_object_types_lpm_autogen.proto",
-    ]
-  }
-
-  # Copy handwritten `.proto` file to build directory
-  copy("copy_dawn_custom_lpm") {
-    sources = [ "${dawn_root}/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ]
-    outputs = [ "$root_out_dir/gen/third_party/dawn/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ]
-  }
-
-  # Generate the `.pb.h` and `.pb.cc` files
-  proto_library("dawn_lpm_proto") {
-    proto_in_dir = "$root_out_dir/gen"
-    proto_out_dir = "//"
-    sources = get_target_outputs(":dawn_lpmfuzz_proto")
-    sources += get_target_outputs(":copy_dawn_custom_lpm")
-
-    generate_python = false
-    use_protobuf_full = true
-    deps = [
-      ":copy_dawn_custom_lpm",
-      ":dawn_lpmfuzz_proto",
-      "//third_party/protobuf:protobuf_full",
-    ]
-  }
-
-  # Compile dawnlpm fuzzer with extensive tint coverage
-  dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend_with_tint") {
-    defines = [ "DAWNLPM_FUZZ_TINT=1" ]
-    dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp")
-    dawn_lpm_sources += [
-      "lpmfuzz/DawnLPMFuzzer.cpp",
-      "lpmfuzz/DawnLPMFuzzer.h",
-      "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp",
-      "lpmfuzz/DawnLPMObjectStore.cpp",
-      "lpmfuzz/DawnLPMObjectStore.h",
-      "lpmfuzz/DawnLPMSerializerCustom.cpp",
-      "lpmfuzz/DawnLPMSerializerCustom.h",
-    ]
-  }
-
-  # Compile dawnlpm api fuzzer
-  dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend") {
-    defines = [ "DAWNLPM_FUZZ_TINT=0" ]
-    dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp")
-    dawn_lpm_sources += [
-      "lpmfuzz/DawnLPMFuzzer.cpp",
-      "lpmfuzz/DawnLPMFuzzer.h",
-      "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp",
-      "lpmfuzz/DawnLPMObjectStore.cpp",
-      "lpmfuzz/DawnLPMObjectStore.h",
-      "lpmfuzz/DawnLPMSerializerCustom.cpp",
-      "lpmfuzz/DawnLPMSerializerCustom.h",
-    ]
-  }
-}
-
-# A group target to build all the fuzzers
-group("fuzzers") {
-  testonly = true
-  deps = [
-    ":dawn_wire_server_and_frontend_fuzzer",
-    ":dawn_wire_server_and_vulkan_backend_fuzzer",
-  ]
 
   if (is_win) {
-    deps += [ ":dawn_wire_server_and_d3d12_backend_fuzzer" ]
+    fuzzer_test("dawn_wire_server_and_d3d12_backend_fuzzer") {
+      sources = [ "DawnWireServerAndD3D12BackendFuzzer.cpp" ]
+
+      deps = [ ":dawn_wire_server_fuzzer_common" ]
+
+      additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
+    }
+  }
+
+  fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") {
+    sources = [ "DawnWireServerAndVulkanBackendFuzzer.cpp" ]
+
+    deps = [ ":dawn_wire_server_fuzzer_common" ]
+
+    additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
+  }
+
+  if (is_dawn_lpm_fuzzer && build_with_chromium && dawn_use_swiftshader &&
+      !disable_libfuzzer && use_fuzzing_engine) {
+    import("//third_party/protobuf/proto_library.gni")
+    import("${dawn_root}/generator/dawn_generator.gni")
+
+    # Generate the fuzzer's serializer in `.cpp`
+    dawn_json_lpm_generator("dawn_lpmfuzz_cpp") {
+      target = "dawn_lpmfuzz_cpp"
+      outputs = [
+        "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.cpp",
+        "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.h",
+        "src/dawn/fuzzers/lpmfuzz/DawnLPMConstants_autogen.h",
+      ]
+    }
+
+    # Generate the `.proto` files
+    dawn_json_lpm_generator("dawn_lpmfuzz_proto") {
+      target = "dawn_lpmfuzz_proto"
+      outputs = [
+        "src/dawn/fuzzers/lpmfuzz/dawn_lpm_autogen.proto",
+        "src/dawn/fuzzers/lpmfuzz/dawn_object_types_lpm_autogen.proto",
+      ]
+    }
+
+    # Copy handwritten `.proto` file to build directory
+    copy("copy_dawn_custom_lpm") {
+      sources =
+          [ "${dawn_root}/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ]
+      outputs = [ "$root_out_dir/gen/third_party/dawn/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ]
+    }
+
+    # Generate the `.pb.h` and `.pb.cc` files
+    proto_library("dawn_lpm_proto") {
+      proto_in_dir = "$root_out_dir/gen"
+      proto_out_dir = "//"
+      sources = get_target_outputs(":dawn_lpmfuzz_proto")
+      sources += get_target_outputs(":copy_dawn_custom_lpm")
+
+      generate_python = false
+      use_protobuf_full = true
+      deps = [
+        ":copy_dawn_custom_lpm",
+        ":dawn_lpmfuzz_proto",
+        "//third_party/protobuf:protobuf_full",
+      ]
+    }
+
+    # Compile dawnlpm fuzzer with extensive tint coverage
+    dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend_with_tint") {
+      defines = [ "DAWNLPM_FUZZ_TINT=1" ]
+      dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp")
+      dawn_lpm_sources += [
+        "lpmfuzz/DawnLPMFuzzer.cpp",
+        "lpmfuzz/DawnLPMFuzzer.h",
+        "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp",
+        "lpmfuzz/DawnLPMObjectStore.cpp",
+        "lpmfuzz/DawnLPMObjectStore.h",
+        "lpmfuzz/DawnLPMSerializerCustom.cpp",
+        "lpmfuzz/DawnLPMSerializerCustom.h",
+      ]
+    }
+
+    # Compile dawnlpm api fuzzer
+    dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend") {
+      defines = [ "DAWNLPM_FUZZ_TINT=0" ]
+      dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp")
+      dawn_lpm_sources += [
+        "lpmfuzz/DawnLPMFuzzer.cpp",
+        "lpmfuzz/DawnLPMFuzzer.h",
+        "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp",
+        "lpmfuzz/DawnLPMObjectStore.cpp",
+        "lpmfuzz/DawnLPMObjectStore.h",
+        "lpmfuzz/DawnLPMSerializerCustom.cpp",
+        "lpmfuzz/DawnLPMSerializerCustom.h",
+      ]
+    }
+  }
+
+  # A group target to build all the fuzzers
+  group("fuzzers") {
+    testonly = true
+    deps = [
+      ":dawn_wire_server_and_frontend_fuzzer",
+      ":dawn_wire_server_and_vulkan_backend_fuzzer",
+    ]
+
+    if (is_win) {
+      deps += [ ":dawn_wire_server_and_d3d12_backend_fuzzer" ]
+    }
   }
 }
diff --git a/src/tint/fuzzers/BUILD.gn b/src/tint/fuzzers/BUILD.gn
index d10eb7a..a482492 100644
--- a/src/tint/fuzzers/BUILD.gn
+++ b/src/tint/fuzzers/BUILD.gn
@@ -18,7 +18,7 @@
 # Fuzzers - Libfuzzer based fuzzing targets for Chromium
 # To run the fuzzers outside of Chromium, use the CMake based builds.
 
-if (build_with_chromium) {
+if (tint_has_fuzzers) {
   import("//testing/libfuzzer/fuzzer_test.gni")
   import("../../../scripts/dawn_overrides_with_defaults.gni")
 
@@ -40,13 +40,15 @@
     "max_len=10000",
   ]
 
-  tint_ast_fuzzer_common_libfuzzer_options =
-      tint_fuzzer_common_libfuzzer_options + [
-        "cross_over=0",
-        "mutate_depth=1",
-        "tint_enable_all_mutations=false",
-        "tint_mutation_batch_size=5",
-      ]
+  if (build_with_chromium) {
+    tint_ast_fuzzer_common_libfuzzer_options =
+        tint_fuzzer_common_libfuzzer_options + [
+          "cross_over=0",
+          "mutate_depth=1",
+          "tint_enable_all_mutations=false",
+          "tint_mutation_batch_size=5",
+        ]
+  }
 
   tint_regex_fuzzer_common_libfuzzer_options =
       tint_fuzzer_common_libfuzzer_options + [
@@ -132,12 +134,14 @@
       seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
     }
 
-    fuzzer_test("tint_ast_wgsl_writer_fuzzer") {
-      sources = [ "tint_ast_fuzzer/tint_ast_wgsl_writer_fuzzer.cc" ]
-      deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
-      libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
-      seed_corpus = fuzzer_corpus_wgsl_dir
-      seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+    if (build_with_chromium) {
+      fuzzer_test("tint_ast_wgsl_writer_fuzzer") {
+        sources = [ "tint_ast_fuzzer/tint_ast_wgsl_writer_fuzzer.cc" ]
+        deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
+        libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
+        seed_corpus = fuzzer_corpus_wgsl_dir
+        seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+      }
     }
 
     fuzzer_test("tint_regex_wgsl_writer_fuzzer") {
@@ -168,12 +172,14 @@
       seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
     }
 
-    fuzzer_test("tint_ast_spv_writer_fuzzer") {
-      sources = [ "tint_ast_fuzzer/tint_ast_spv_writer_fuzzer.cc" ]
-      deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
-      libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
-      seed_corpus = fuzzer_corpus_wgsl_dir
-      seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+    if (build_with_chromium) {
+      fuzzer_test("tint_ast_spv_writer_fuzzer") {
+        sources = [ "tint_ast_fuzzer/tint_ast_spv_writer_fuzzer.cc" ]
+        deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
+        libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
+        seed_corpus = fuzzer_corpus_wgsl_dir
+        seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+      }
     }
 
     fuzzer_test("tint_binding_remapper_fuzzer") {
@@ -261,12 +267,14 @@
   }
 
   if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
-    fuzzer_test("tint_ast_hlsl_writer_fuzzer") {
-      sources = [ "tint_ast_fuzzer/tint_ast_hlsl_writer_fuzzer.cc" ]
-      deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
-      libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
-      seed_corpus = fuzzer_corpus_wgsl_dir
-      seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+    if (build_with_chromium) {
+      fuzzer_test("tint_ast_hlsl_writer_fuzzer") {
+        sources = [ "tint_ast_fuzzer/tint_ast_hlsl_writer_fuzzer.cc" ]
+        deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
+        libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
+        seed_corpus = fuzzer_corpus_wgsl_dir
+        seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+      }
     }
 
     fuzzer_test("tint_regex_hlsl_writer_fuzzer") {
@@ -288,12 +296,14 @@
   }
 
   if (tint_build_wgsl_reader && tint_build_msl_writer) {
-    fuzzer_test("tint_ast_msl_writer_fuzzer") {
-      sources = [ "tint_ast_fuzzer/tint_ast_msl_writer_fuzzer.cc" ]
-      deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
-      libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
-      seed_corpus = fuzzer_corpus_wgsl_dir
-      seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+    if (build_with_chromium) {
+      fuzzer_test("tint_ast_msl_writer_fuzzer") {
+        sources = [ "tint_ast_fuzzer/tint_ast_msl_writer_fuzzer.cc" ]
+        deps = [ "tint_ast_fuzzer:tint_ast_fuzzer" ]
+        libfuzzer_options = tint_ast_fuzzer_common_libfuzzer_options
+        seed_corpus = fuzzer_corpus_wgsl_dir
+        seed_corpus_deps = [ ":tint_generate_wgsl_corpus" ]
+      }
     }
 
     fuzzer_test("tint_regex_msl_writer_fuzzer") {
@@ -321,15 +331,16 @@
     if (tint_build_wgsl_reader && tint_build_wgsl_writer) {
       deps += [
         ":tint_ast_clone_fuzzer",
-        ":tint_ast_wgsl_writer_fuzzer",
         ":tint_regex_wgsl_writer_fuzzer",
         ":tint_wgsl_reader_wgsl_writer_fuzzer",
       ]
+      if (build_with_chromium) {
+        deps += [ ":tint_ast_wgsl_writer_fuzzer" ]
+      }
     }
     if (tint_build_wgsl_reader && tint_build_spv_writer) {
       deps += [
         ":tint_all_transforms_fuzzer",
-        ":tint_ast_spv_writer_fuzzer",
         ":tint_binding_remapper_fuzzer",
         ":tint_first_index_offset_fuzzer",
         ":tint_regex_spv_writer_fuzzer",
@@ -339,20 +350,27 @@
         ":tint_vertex_pulling_fuzzer",
         ":tint_wgsl_reader_spv_writer_fuzzer",
       ]
+      if (build_with_chromium) {
+        deps += [ ":tint_ast_spv_writer_fuzzer" ]
+      }
     }
     if (tint_build_wgsl_reader && tint_build_hlsl_writer) {
       deps += [
-        ":tint_ast_hlsl_writer_fuzzer",
         ":tint_regex_hlsl_writer_fuzzer",
         ":tint_wgsl_reader_hlsl_writer_fuzzer",
       ]
+      if (build_with_chromium) {
+        deps += [ ":tint_ast_hlsl_writer_fuzzer" ]
+      }
     }
     if (tint_build_wgsl_reader && tint_build_msl_writer) {
       deps += [
-        ":tint_ast_msl_writer_fuzzer",
         ":tint_regex_msl_writer_fuzzer",
         ":tint_wgsl_reader_msl_writer_fuzzer",
       ]
+      if (build_with_chromium) {
+        deps += [ ":tint_ast_msl_writer_fuzzer" ]
+      }
     }
   }
 } else {
diff --git a/src/tint/fuzzers/tint_regex_fuzzer/BUILD.gn b/src/tint/fuzzers/tint_regex_fuzzer/BUILD.gn
index 78a3623..cddb936 100644
--- a/src/tint/fuzzers/tint_regex_fuzzer/BUILD.gn
+++ b/src/tint/fuzzers/tint_regex_fuzzer/BUILD.gn
@@ -15,7 +15,7 @@
 import("//build_overrides/build.gni")
 import("../../../../scripts/tint_overrides_with_defaults.gni")
 
-if (build_with_chromium) {
+if (tint_has_fuzzers) {
   source_set("tint_regex_fuzzer") {
     public_configs = [
       "${tint_src_dir}:tint_config",
diff --git a/src/tint/tint.gni b/src/tint/tint.gni
index 9833c02..ba3fe74 100644
--- a/src/tint/tint.gni
+++ b/src/tint/tint.gni
@@ -76,54 +76,61 @@
 ###############################################################################
 # Fuzzers
 ###############################################################################
-import("//testing/libfuzzer/fuzzer_test.gni")
-fuzzer_corpus_wgsl_dir = "${root_gen_dir}/fuzzers/wgsl_corpus"
-fuzzer_corpus_wgsl_stamp = "${fuzzer_corpus_wgsl_dir}.stamp"
+if (tint_has_fuzzers) {
+  import("//testing/libfuzzer/fuzzer_test.gni")
+  fuzzer_corpus_wgsl_dir = "${root_gen_dir}/fuzzers/wgsl_corpus"
+  fuzzer_corpus_wgsl_stamp = "${fuzzer_corpus_wgsl_dir}.stamp"
 
-template("tint_fuzz_source_set") {
-  source_set(target_name) {
-    forward_variables_from(invoker, "*", [ "configs" ])
+  template("tint_fuzz_source_set") {
+    source_set(target_name) {
+      forward_variables_from(invoker, "*", [ "configs" ])
 
-    testonly = true
+      testonly = true
 
-    if (!defined(invoker.deps)) {
-      deps = []
+      if (!defined(invoker.deps)) {
+        deps = []
+      }
+
+      if (defined(invoker.configs)) {
+        configs += invoker.configs
+      }
+
+      configs += [ "${tint_src_dir}:tint_common_config" ]
+
+      if (build_with_chromium) {
+        configs -= [ "//build/config/compiler:chromium_code" ]
+        configs += [ "//build/config/compiler:no_chromium_code" ]
+      }
+
+      if (!defined(invoker.public_configs)) {
+        public_configs = []
+      }
+
+      public_configs += [ "${tint_src_dir}:tint_public_config" ]
     }
-
-    if (defined(invoker.configs)) {
-      configs += invoker.configs
-    }
-
-    configs += [ "${tint_src_dir}:tint_common_config" ]
-
-    if (build_with_chromium) {
-      configs -= [ "//build/config/compiler:chromium_code" ]
-      configs += [ "//build/config/compiler:no_chromium_code" ]
-    }
-
-    if (!defined(invoker.public_configs)) {
-      public_configs = []
-    }
-
-    public_configs += [ "${tint_src_dir}:tint_public_config" ]
   }
-}
 
-template("tint_fuzzer_test") {
-  fuzzer_test(target_name) {
-    forward_variables_from(invoker, "*")
-    exclude_main = false
+  template("tint_fuzzer_test") {
+    fuzzer_test(target_name) {
+      forward_variables_from(invoker, "*")
+      exclude_main = false
 
-    if (target_name == "wgsl") {
-      dict = "dictionary.txt"
-      libfuzzer_options = [
-        "only_ascii=1",  # TODO(bclayton): Remove this to fuzz unicode?
-        "max_len=10000",
-      ]
-      seed_corpus = fuzzer_corpus_wgsl_dir
-      seed_corpus_deps = [ "${tint_src_dir}:tint_generate_wgsl_corpus" ]
-    } else {
-      assert(false, "unsupported tint fuzzer target")
+      if (target_name == "wgsl") {
+        dict = "dictionary.txt"
+        libfuzzer_options = [
+          "only_ascii=1",  # TODO(bclayton): Remove this to fuzz unicode?
+          "max_len=10000",
+        ]
+        seed_corpus = fuzzer_corpus_wgsl_dir
+        seed_corpus_deps = [ "${tint_src_dir}:tint_generate_wgsl_corpus" ]
+      } else {
+        assert(false, "unsupported tint fuzzer target")
+      }
     }
   }
+} else {
+  template("tint_fuzz_source_set") {
+  }
+  template("tint_fuzzer_test") {
+  }
 }