Reland "Enable GN check for webrtc/examples"

This is a reland of https://codereview.webrtc.org/2714343002
with the errors related to inclusions of test targets in webrtc/api
resolved.

BUG=webrtc:6828
NOTRY=True

Review-Url: https://codereview.webrtc.org/2733673002
Cr-Original-Commit-Position: refs/heads/master@{#17053}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 1993b1de1f27e0892cd5fd6921b6f761b0af1166
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index d575c65..74d340f 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -50,6 +50,7 @@
 
 if (is_android) {
   android_apk("AppRTCMobile") {
+    testonly = true
     apk_name = "AppRTCMobile"
     android_manifest = "androidapp/AndroidManifest.xml"
 
@@ -64,6 +65,7 @@
   }
 
   android_library("AppRTCMobile_javalib") {
+    testonly = true
     android_manifest = "androidapp/AndroidManifest.xml"
 
     java_files = [
@@ -101,6 +103,7 @@
   }
 
   android_resources("AppRTCMobile_resources") {
+    testonly = true
     resource_dirs = [ "androidapp/res" ]
     custom_package = "org.appspot.apprtc"
   }
@@ -169,6 +172,7 @@
   }
 
   rtc_static_library("apprtc_common") {
+    testonly = true
     sources = [
       "objc/AppRTCMobile/common/ARDUtilities.h",
       "objc/AppRTCMobile/common/ARDUtilities.m",
@@ -180,9 +184,9 @@
     public_configs = [ ":apprtc_common_config" ]
 
     deps = [
-      "../sdk:rtc_sdk_common_objc",
-      "../system_wrappers:field_trial_default",
-      "../system_wrappers:metrics_default",
+      "//webrtc/sdk:rtc_sdk_common_objc",
+      "//webrtc/system_wrappers:field_trial_default",
+      "//webrtc/system_wrappers:metrics_default",
     ]
   }
 
@@ -199,6 +203,7 @@
   }
 
   rtc_static_library("apprtc_signaling") {
+    testonly = true
     sources = [
       "objc/AppRTCMobile/ARDAppClient+Internal.h",
       "objc/AppRTCMobile/ARDAppClient.h",
@@ -245,13 +250,14 @@
       ":socketrocket",
     ]
     public_deps = [
-      "../sdk:rtc_sdk_peerconnection_objc",
+      "//webrtc/sdk:rtc_sdk_peerconnection_objc",
     ]
     libs = [ "QuartzCore.framework" ]
   }
 
   if (is_ios) {
     rtc_static_library("AppRTCMobile_lib") {
+      testonly = true
       sources = [
         "objc/AppRTCMobile/ios/ARDAppDelegate.m",
         "objc/AppRTCMobile/ios/ARDMainView.h",
@@ -283,10 +289,12 @@
       deps = [
         ":apprtc_common",
         ":apprtc_signaling",
+        "//webrtc/modules/audio_device",
       ]
     }
 
     ios_app_bundle("AppRTCMobile") {
+      testonly = true
       sources = [
         "objc/AppRTCMobile/ios/main.m",
       ]
@@ -346,6 +354,7 @@
 
   if (is_mac) {
     rtc_static_library("AppRTCMobile_lib") {
+      testonly = true
       sources = [
         "objc/AppRTCMobile/mac/APPRTCAppDelegate.h",
         "objc/AppRTCMobile/mac/APPRTCAppDelegate.m",
@@ -353,7 +362,7 @@
         "objc/AppRTCMobile/mac/APPRTCViewController.m",
       ]
       configs += [
-        "..:common_objc",
+        "//webrtc:common_objc",
         "//build/config/compiler:enable_arc",
       ]
       deps = [
@@ -363,6 +372,7 @@
     }
 
     mac_app_bundle("AppRTCMobile") {
+      testonly = true
       output_name = "AppRTCMobile"
 
       sources = [
@@ -403,6 +413,7 @@
   }
 
   rtc_static_library("socketrocket") {
+    testonly = true
     sources = [
       "objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h",
       "objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m",
@@ -423,6 +434,7 @@
     # TODO(kthelgason): compile xctests on mac when chromium supports it.
     if (is_ios) {
       rtc_source_set("apprtcmobile_test_sources") {
+        testonly = true
         include_dirs = [
           "objc/AppRTCMobile",
           "objc/AppRTCMobile/ios",
@@ -433,6 +445,9 @@
           "objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm",
           "objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm",
         ]
+        deps = [
+          "//webrtc/base:rtc_base",
+        ]
         public_deps = [
           ":AppRTCMobile_ios_frameworks",
           ":AppRTCMobile_lib",
@@ -487,6 +502,7 @@
   }
 
   rtc_executable("peerconnection_client") {
+    testonly = true
     sources = [
       "peerconnection/client/conductor.cc",
       "peerconnection/client/conductor.h",
@@ -500,6 +516,7 @@
       # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
       suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
     }
+    deps = []
     if (is_win) {
       sources += [
         "peerconnection/client/flagdefs.h",
@@ -509,13 +526,8 @@
       ]
       cflags = [ "/wd4245" ]
       configs += [ "//build/config/win:windowed" ]
+      deps += [ "//webrtc/media:rtc_media_base" ]
     }
-    deps = [
-      "//third_party/libyuv",
-      "//webrtc/pc:libjingle_peerconnection",
-      "//webrtc/system_wrappers:field_trial_default",
-      "//webrtc/system_wrappers:metrics_default",
-    ]
     if (is_linux) {
       sources += [
         "peerconnection/client/linux/main.cc",
@@ -531,12 +543,26 @@
       deps += [ "//build/config/linux/gtk" ]
     }
     configs += [ ":peerconnection_client_warnings_config" ]
+
+    deps += [
+      "//third_party/libyuv",
+      "//webrtc/api:libjingle_peerconnection_test_api",
+      "//webrtc/api:video_frame_api",
+      "//webrtc/base:rtc_base",
+      "//webrtc/base:rtc_base_approved",
+      "//webrtc/media:rtc_media",
+      "//webrtc/modules/video_capture:video_capture_module",
+      "//webrtc/pc:libjingle_peerconnection",
+      "//webrtc/system_wrappers:field_trial_default",
+      "//webrtc/system_wrappers:metrics_default",
+    ]
     if (rtc_build_json) {
       deps += [ "//third_party/jsoncpp" ]
     }
   }
 
   rtc_executable("peerconnection_server") {
+    testonly = true
     sources = [
       "peerconnection/server/data_socket.cc",
       "peerconnection/server/data_socket.h",
@@ -557,11 +583,14 @@
     }
   }
   rtc_executable("relayserver") {
+    testonly = true
     sources = [
       "relayserver/relayserver_main.cc",
     ]
     deps = [
+      "../base:rtc_base",
       "//webrtc/base:rtc_base_approved",
+      "//webrtc/p2p:rtc_p2p",
       "//webrtc/pc:rtc_pc",
       "//webrtc/system_wrappers:field_trial_default",
       "//webrtc/system_wrappers:metrics_default",
@@ -572,11 +601,14 @@
     }
   }
   rtc_executable("turnserver") {
+    testonly = true
     sources = [
       "turnserver/turnserver_main.cc",
     ]
     deps = [
+      "../base:rtc_base",
       "//webrtc/base:rtc_base_approved",
+      "//webrtc/p2p:rtc_p2p",
       "//webrtc/pc:rtc_pc",
       "//webrtc/system_wrappers:field_trial_default",
       "//webrtc/system_wrappers:metrics_default",
@@ -587,11 +619,14 @@
     }
   }
   rtc_executable("stunserver") {
+    testonly = true
     sources = [
       "stunserver/stunserver_main.cc",
     ]
     deps = [
+      "../base:rtc_base",
       "//webrtc/base:rtc_base_approved",
+      "//webrtc/p2p:rtc_p2p",
       "//webrtc/pc:rtc_pc",
       "//webrtc/system_wrappers:field_trial_default",
       "//webrtc/system_wrappers:metrics_default",
@@ -606,6 +641,7 @@
 if (!build_with_chromium) {
   # Doesn't build within Chrome on Win.
   rtc_executable("stun_prober") {
+    testonly = true
     sources = [
       "stunprober/main.cc",
     ]
@@ -617,6 +653,8 @@
     }
 
     deps = [
+      "../base:rtc_base",
+      "../base:rtc_base_approved",
       "../p2p:libstunprober",
       "../p2p:rtc_p2p",
       "../system_wrappers:field_trial_default",