[tint][gn] Fix naming of ClusterFuzz data files

`fuzzer_test.gni` doesn't handle targets that use `output_name` correctly.

It will build an executable with the requested name, but the ClusterFuzz data files (corpus, dictionary, options, owners, runtime_deps) will all use the target name for their output file names, and these will not be used by ClusterFuzz.

To work around this, if an 'output_name' is specified, pass the 'output_name' to fuzzer_test() as the target name, then make a proxy 'target_name' group that depends on the fuzzer target.

Change-Id: I97bcc254e08f7b4d42dc1f447141c46445908f00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/184180
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/tint.gni b/src/tint/tint.gni
index b284b4b..bf48aae 100644
--- a/src/tint/tint.gni
+++ b/src/tint/tint.gni
@@ -164,8 +164,22 @@
   }
 
   template("tint_fuzzer_test") {
-    fuzzer_test(target_name) {
-      forward_variables_from(invoker, "*")
+    # fuzzer_test.gni doesn't handle targets that use 'output_name' correctly.
+    # It will build an executable with the requested name, but the ClusterFuzz
+    # data files (corpus, dictionary, options, owners, runtime_deps) will all
+    # use the target name for their output file names, and these will not be
+    # used by ClusterFuzz.
+    # To work around this, if an 'output_name' is specified, pass the
+    # 'output_name' to fuzzer_test() as the target name, then make a proxy
+    # 'target_name' group that depends on the fuzzer target.
+    if (defined(invoker.output_name)) {
+      fuzzer_name = invoker.output_name
+    } else {
+      fuzzer_name = target_name
+    }
+
+    fuzzer_test(fuzzer_name) {
+      forward_variables_from(invoker, "*", [ "output_name" ])
       exclude_main = false
 
       if (target_name == "wgsl") {
@@ -181,6 +195,13 @@
         assert(false, "unsupported tint fuzzer target")
       }
     }
+
+    if (fuzzer_name != target_name) {
+      group(target_name) {
+        testonly = true
+        deps = [ ":${fuzzer_name}" ]
+      }
+    }
   }
 } else {
   template("tint_fuzz_source_set") {