Base webrtc fuzzers on a template.

Removes noisy dependencies on webrtc_fuzzer_main and removal of
find_bad_constructs, removes 1-6 lines of gn per fuzzer target.

BUG=webrtc:4771
R=kjellander@webrtc.org

Review URL: https://codereview.webrtc.org/1524993002 .

Cr-Commit-Position: refs/heads/master@{#11022}
diff --git a/webrtc/test/fuzzers/BUILD.gn b/webrtc/test/fuzzers/BUILD.gn
index 7b530b6..cf4fc5b 100644
--- a/webrtc/test/fuzzers/BUILD.gn
+++ b/webrtc/test/fuzzers/BUILD.gn
@@ -7,7 +7,7 @@
 # be found in the AUTHORS file in the root of the source tree.
 
 import("//build/config/features.gni")
-import("//testing/test.gni")
+import("webrtc_fuzzer.gni")
 
 static_library("webrtc_fuzzer_main") {
   public_configs = [ "../..:common_inherited_config" ]
@@ -21,51 +21,31 @@
   ]
 }
 
-test("vp9_depacketizer_fuzzer") {
+webrtc_fuzzer_test("vp9_depacketizer_fuzzer") {
   sources = [
     "vp9_depacketizer_fuzzer.cc",
   ]
   deps = [
-    ":webrtc_fuzzer_main",
     "../../modules/rtp_rtcp",
   ]
-  if (is_clang) {
-    # Suppress warnings from Chrome's Clang plugins.
-    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
-    configs -= [ "//build/config/clang:find_bad_constructs" ]
-  }
 }
 
-test("vp8_qp_parser_fuzzer") {
+webrtc_fuzzer_test("vp8_qp_parser_fuzzer") {
   sources = [
     "vp8_qp_parser_fuzzer.cc",
   ]
   deps = [
-    ":webrtc_fuzzer_main",
     "../../modules/video_coding/",
   ]
-
-  if (is_clang) {
-    # Suppress warnings from Chrome's Clang plugins.
-    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
-    configs -= [ "//build/config/clang:find_bad_constructs" ]
-  }
 }
 
-test("producer_fec_fuzzer") {
+webrtc_fuzzer_test("producer_fec_fuzzer") {
   sources = [
     "producer_fec_fuzzer.cc",
   ]
   deps = [
-    ":webrtc_fuzzer_main",
     "../../modules/rtp_rtcp/",
   ]
-
-  if (is_clang) {
-    # Suppress warnings from Chrome's Clang plugins.
-    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
-    configs -= [ "//build/config/clang:find_bad_constructs" ]
-  }
 }
 
 source_set("audio_decoder_fuzzer") {
@@ -73,12 +53,9 @@
     "audio_decoder_fuzzer.cc",
     "audio_decoder_fuzzer.h",
   ]
-  deps = [
-    ":webrtc_fuzzer_main",
-  ]
 }
 
-test("audio_decoder_ilbc_fuzzer") {
+webrtc_fuzzer_test("audio_decoder_ilbc_fuzzer") {
   sources = [
     "audio_decoder_ilbc_fuzzer.cc",
   ]
@@ -88,7 +65,7 @@
   ]
 }
 
-test("audio_decoder_isac_fuzzer") {
+webrtc_fuzzer_test("audio_decoder_isac_fuzzer") {
   sources = [
     "audio_decoder_isac_fuzzer.cc",
   ]
@@ -98,7 +75,7 @@
   ]
 }
 
-test("audio_decoder_isacfix_fuzzer") {
+webrtc_fuzzer_test("audio_decoder_isacfix_fuzzer") {
   sources = [
     "audio_decoder_isacfix_fuzzer.cc",
   ]
@@ -108,7 +85,7 @@
   ]
 }
 
-test("audio_decoder_opus_fuzzer") {
+webrtc_fuzzer_test("audio_decoder_opus_fuzzer") {
   sources = [
     "audio_decoder_opus_fuzzer.cc",
   ]
diff --git a/webrtc/test/fuzzers/webrtc_fuzzer.gni b/webrtc/test/fuzzers/webrtc_fuzzer.gni
new file mode 100644
index 0000000..d264392
--- /dev/null
+++ b/webrtc/test/fuzzers/webrtc_fuzzer.gni
@@ -0,0 +1,28 @@
+# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+import("//testing/test.gni")
+
+template("webrtc_fuzzer_test") {
+  assert(defined(invoker.sources), "Need sources in $target_name.")
+
+  test(target_name) {
+    forward_variables_from(invoker, [ "sources" ])
+    deps = [
+      ":webrtc_fuzzer_main",
+    ]
+    if (defined(invoker.deps)) {
+      deps += invoker.deps
+    }
+    if (is_clang) {
+      # Suppress warnings from Chrome's Clang plugins.
+      # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
+      configs -= [ "//build/config/clang:find_bad_constructs" ]
+    }
+  }
+}