Stop using public_deps in system_wrappers.

TBR=phoglund@webrtc.org

Bug: webrtc:8603
Change-Id: I5e515f0e4dc955a01460d69ba4e21bdfdf152d20
Reviewed-on: https://webrtc-review.googlesource.com/29104
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Edward Lemur <ehmaldonado@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21112}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index fbd1824..ac94457 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -101,6 +101,7 @@
     "../rtc_base:rtc_base_approved",
     "../rtc_base:sequenced_task_checker",
     "../system_wrappers",
+    "../system_wrappers:metrics_api",
   ]
   if (!build_with_chromium && is_clang) {
     # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
@@ -145,6 +146,7 @@
     "../rtc_base:rtc_task_queue",
     "../rtc_base:sequenced_task_checker",
     "../system_wrappers",
+    "../system_wrappers:metrics_api",
     "../video",
   ]
 }
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 836fb90..f756612 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -63,6 +63,7 @@
     "../rtc_base:gtest_prod",
     "../rtc_base:rtc_base_approved",
     "../system_wrappers",
+    "../system_wrappers:cpu_features_api",
   ]
   public_deps = [
     ":common_audio_c",
@@ -221,7 +222,8 @@
     "..:webrtc_common",
     "../rtc_base:compile_assert_c",
     "../rtc_base:rtc_base_approved",
-    "../system_wrappers:system_wrappers",
+    "../system_wrappers",
+    "../system_wrappers:cpu_features_api",
   ]
 }
 
@@ -236,7 +238,7 @@
   deps = [
     "..:webrtc_common",
     "../rtc_base:rtc_base_approved",
-    "../system_wrappers:system_wrappers",
+    "../system_wrappers",
   ]
 }
 
@@ -298,7 +300,7 @@
       ":fir_filter",
       ":sinc_resampler",
       "../rtc_base:rtc_base_approved",
-      "../system_wrappers:system_wrappers",
+      "../system_wrappers",
     ]
   }
 }
@@ -337,7 +339,7 @@
       ":fir_filter",
       ":sinc_resampler",
       "../rtc_base:rtc_base_approved",
-      "../system_wrappers:system_wrappers",
+      "../system_wrappers",
     ]
 
     public_deps = [
@@ -437,7 +439,7 @@
       "..:webrtc_common",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_utils",
-      "../system_wrappers",
+      "../system_wrappers:cpu_features_api",
       "../test:test_main",
       "//testing/gmock",
       "//testing/gtest",
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 2a1829a..a15dd29 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -130,6 +130,8 @@
     "../api:video_frame_api_i420",
     "../call:call_interfaces",
     "../modules/video_coding:video_coding_utility",
+    "../system_wrappers:field_trial_api",
+    "../system_wrappers:metrics_api",
   ]
   sources = [
     "engine/adm_helpers.cc",
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index c579997..a84f483 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -124,6 +124,7 @@
   }
 
   deps = audio_coding_deps + [
+           "../../system_wrappers:metrics_api",
            "..:module_api",
            "../../api:array_view",
            "../../api/audio_codecs:audio_codecs_api",
@@ -660,7 +661,7 @@
     "../../common_audio",
     "../../rtc_base:compile_assert_c",
     "../../rtc_base:rtc_base_approved",
-    "../../system_wrappers",
+    "../../system_wrappers:cpu_features_api",
   ]
 
   public_deps = [
@@ -796,7 +797,7 @@
     "../../common_audio",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_numerics",
-    "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
   ]
   public_deps = [
     ":webrtc_opus_c",
@@ -905,6 +906,7 @@
     "../../rtc_base:protobuf_utils",
     "../../rtc_base:rtc_base_approved",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
   ]
 
   if (rtc_enable_protobuf) {
@@ -1016,7 +1018,8 @@
     "../../common_audio",
     "../../rtc_base:gtest_prod",
     "../../rtc_base:rtc_base_approved",
-    "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
   ]
 }
 
@@ -1265,7 +1268,7 @@
       "../../api:optional",
       "../../api/audio_codecs:builtin_audio_decoder_factory",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:test_support",
     ]
     defines = audio_coding_defines
@@ -1295,7 +1298,8 @@
       "../../api/audio_codecs/opus:audio_encoder_opus",
       "../../rtc_base:protobuf_utils",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
+      "../../system_wrappers:field_trial_api",
       "../../test:test_support",
     ]
 
@@ -1619,10 +1623,10 @@
              "../../api/audio_codecs/L16:audio_encoder_L16",
              "../../api/audio_codecs/g722:audio_encoder_g722",
              "../../api/audio_codecs/ilbc:audio_encoder_ilbc",
+             "../../system_wrappers:system_wrappers_default",
              "../../api/audio_codecs/isac:audio_encoder_isac",
              "../../api/audio_codecs/opus:audio_encoder_opus",
              "../../rtc_base:rtc_base_approved",
-             "../../system_wrappers:system_wrappers_default",
            ]
 
     sources = [
@@ -1636,10 +1640,10 @@
     testonly = true
 
     deps = audio_coding_deps + [
+             "../../system_wrappers:system_wrappers_default",
              "../rtp_rtcp:rtp_rtcp_format",
              "../../api:array_view",
              "../../rtc_base:rtc_base_approved",
-             "../../system_wrappers:system_wrappers_default",
            ]
 
     sources = [
@@ -2054,7 +2058,8 @@
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_base_tests_utils",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
+      "../../system_wrappers:cpu_features_api",
       "../../test:audio_codec_mocks",
       "../../test:field_trial",
       "../../test:rtp_test_utils",
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index ba39ac0..2fd6f9b 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -104,6 +104,7 @@
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_task_queue",
     "../../system_wrappers",
+    "../../system_wrappers:metrics_api",
     "../utility",
   ]
 
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 75a5ac2..1d4a9d4 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -248,6 +248,8 @@
     "../../audio/utility:audio_frame_operations",
     "../../rtc_base:gtest_prod",
     "../../rtc_base:protobuf_utils",
+    "../../system_wrappers:cpu_features_api",
+    "../../system_wrappers:metrics_api",
     "../audio_coding:isac",
   ]
 
@@ -376,7 +378,7 @@
     "../..:webrtc_common",
     "../../common_audio",
     "../../rtc_base:rtc_base_approved",
-    "../../system_wrappers",
+    "../../system_wrappers:cpu_features_api",
   ]
 
   if (rtc_build_with_neon) {
@@ -570,7 +572,8 @@
       "../../rtc_base:protobuf_utils",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
+      "../../system_wrappers:cpu_features_api",
       "../../test:test_support",
       "../audio_coding:neteq_input_audio_tools",
       "aec_dump:mock_aec_dump_unittests",
@@ -707,7 +710,7 @@
       "../../modules:module_api",
       "../../rtc_base:protobuf_utils",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:test_support",
     ]
 
@@ -806,7 +809,7 @@
       "../../api:optional",
       "../../common_audio",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:test_support",
       "../audio_coding:neteq_input_audio_tools",
       "//testing/gtest",
@@ -826,8 +829,7 @@
       "../..:webrtc_common",
       "../../common_audio:common_audio",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:metrics_default",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:test_support",
       "//testing/gtest",
     ]
@@ -843,8 +845,8 @@
     deps = [
       ":audio_processing",
       "../..:webrtc_common",
+      "../../system_wrappers",
       "../../system_wrappers:metrics_default",
-      "../../system_wrappers:system_wrappers",
     ]
   }
 
diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn
index d1a8653..295f40a 100644
--- a/modules/congestion_controller/BUILD.gn
+++ b/modules/congestion_controller/BUILD.gn
@@ -55,6 +55,8 @@
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_numerics",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
     "../bitrate_controller",
     "../pacing",
     "../remote_bitrate_estimator",
@@ -88,7 +90,7 @@
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_base_tests_utils",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:field_trial",
       "../../test:test_support",
       "../bitrate_controller:bitrate_controller",
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 204aaff..0ae0548 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -87,7 +87,7 @@
       ":primitives",
       "../..:webrtc_common",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers",
+      "../../system_wrappers:cpu_features_api",
       "../../test:test_support",
       "//testing/gmock",
     ]
@@ -329,6 +329,8 @@
     "../../api:refcountedbase",
     "../../rtc_base:rtc_base",  # TODO(kjellander): Cleanup in bugs.webrtc.org/3806.
     "../../system_wrappers",
+    "../../system_wrappers:cpu_features_api",
+    "../../system_wrappers:metrics_api",
     "//third_party/libyuv",
   ]
 
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index 02abf63..de10eae 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -39,6 +39,7 @@
     "../../logging:rtc_event_log_api",
     "../../rtc_base:rtc_base_approved",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
     "../remote_bitrate_estimator",
     "../rtp_rtcp",
     "../rtp_rtcp:rtp_rtcp_format",
@@ -61,7 +62,8 @@
       ":pacing",
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_base_tests_utils",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
+      "../../system_wrappers:field_trial_api",
       "../../test:field_trial",
       "../../test:test_support",
       "../rtp_rtcp",
diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn
index b9bf792..2dc4b22 100644
--- a/modules/remote_bitrate_estimator/BUILD.gn
+++ b/modules/remote_bitrate_estimator/BUILD.gn
@@ -51,6 +51,8 @@
     "../../modules/rtp_rtcp:rtp_rtcp_format",
     "../../rtc_base:rtc_base_approved",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
   ]
 }
 
@@ -143,6 +145,7 @@
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_numerics",
       "../../system_wrappers",
+      "../../system_wrappers:field_trial_api",
       "../../test:test_support",
       "../../voice_engine",
       "../bitrate_controller",
@@ -202,7 +205,7 @@
       "../..:webrtc_common",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:field_trial",
       "../../test:test_support",
       "../pacing:pacing",
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 0879ab0..def1483 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -203,6 +203,8 @@
     "../../rtc_base:rtc_numerics",
     "../../rtc_base:sequenced_task_checker",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
     "../audio_coding:audio_format_conversion",
     "../remote_bitrate_estimator",
   ]
@@ -238,7 +240,7 @@
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_task_queue",
     "../../rtc_base:weak_ptr",
-    "../../system_wrappers:system_wrappers",
+    "../../system_wrappers",
   ]
 }
 
@@ -399,7 +401,7 @@
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_base_tests_utils",
       "../../rtc_base:rtc_task_queue",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:field_trial",
       "../../test:rtp_test_utils",
       "../../test:test_common",
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 19b0501..6de45e2 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -109,6 +109,8 @@
     "../../rtc_base:rtc_task_queue",
     "../../rtc_base:sequenced_task_checker",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
     "../pacing",
     "../rtp_rtcp:rtp_rtcp_format",
     "../utility:utility",
@@ -197,7 +199,7 @@
     "../../api/video_codecs:video_codecs_api",
     "../../media:rtc_media_base",
     "../../rtc_base:rtc_base_approved",
-    "../../system_wrappers",
+    "../../system_wrappers:metrics_api",
   ]
 
   if (rtc_use_h264) {
@@ -303,6 +305,8 @@
     "../../rtc_base:rtc_numerics",
     "../../rtc_base:sequenced_task_checker",
     "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
+    "../../system_wrappers:metrics_api",
   ]
   if (rtc_build_libvpx) {
     deps += [ rtc_libvpx_dir ]
@@ -426,7 +430,7 @@
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_task_queue",
       "../../rtc_base:sequenced_task_checker",
-      "../../system_wrappers:system_wrappers",
+      "../../system_wrappers",
       "../../test:test_support",
       "../../test:video_test_common",
       "../../test:video_test_support",
@@ -594,8 +598,10 @@
       "../../rtc_base:rtc_base_approved",
       "../../rtc_base:rtc_numerics",
       "../../rtc_base:rtc_task_queue",
+      "../../system_wrappers",
+      "../../system_wrappers:field_trial_api",
+      "../../system_wrappers:metrics_api",
       "../../system_wrappers:metrics_default",
-      "../../system_wrappers:system_wrappers",
       "../../test:field_trial",
       "../../test:test_support",
       "../../test:video_test_common",
diff --git a/modules/video_processing/BUILD.gn b/modules/video_processing/BUILD.gn
index 9c0afbd..da889a8 100644
--- a/modules/video_processing/BUILD.gn
+++ b/modules/video_processing/BUILD.gn
@@ -32,7 +32,7 @@
     "../../common_video",
     "../../modules/utility",
     "../../rtc_base:rtc_base_approved",
-    "../../system_wrappers",
+    "../../system_wrappers:cpu_features_api",
   ]
   if (build_video_processing_sse2) {
     deps += [ ":video_processing_sse2" ]
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 165be56..d6260a9 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -187,7 +187,8 @@
     "../rtc_base:rtc_base",
     "../rtc_base:rtc_base_approved",
     "../stats",
-    "../system_wrappers:system_wrappers",
+    "../system_wrappers",
+    "../system_wrappers:field_trial_api",
   ]
 
   public_deps = [
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 0b0a56f..e68e748 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -544,12 +544,11 @@
             ":peerconnectionfactory_objc",
             ":videotoolbox_objc",
             ":videotracksource_objc",
-            "..//system_wrappers:system_wrappers_default",
+            "../../system_wrappers:system_wrappers_default",
             "../media:rtc_media_base",
             "../modules:module_api",
             "../rtc_base:rtc_base",
             "../rtc_base:rtc_base_tests_utils",
-            "../system_wrappers:system_wrappers_default",
           ]
           public_deps = [
             "//build/config/ios:xctest",
@@ -622,11 +621,10 @@
           ":peerconnectionfactory_objc",
           ":videotoolbox_objc",
           ":videotracksource_objc",
-          "..//system_wrappers:system_wrappers_default",
+          "../../system_wrappers:system_wrappers_default",
           "../media:rtc_media_base",
           "../modules:module_api",
           "../rtc_base:rtc_base_tests_utils",
-          "../system_wrappers:system_wrappers_default",
           "//test:test_support",
           "//third_party/ocmock",
         ]
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 5d5c330..c484fd9 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -224,7 +224,8 @@
     "../../rtc_base:rtc_task_queue",
     "../../rtc_base:sequenced_task_checker",
     "../../rtc_base:weak_ptr",
-    "../../system_wrappers:system_wrappers",
+    "../../system_wrappers",
+    "../../system_wrappers:field_trial_api",
   ]
 }
 
@@ -370,7 +371,7 @@
     "../../rtc_base:rtc_base",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_task_queue",
-    "../../system_wrappers:system_wrappers",
+    "../../system_wrappers:field_trial_api",
   ]
 }
 
@@ -405,8 +406,8 @@
     ":generated_metrics_jni",
     ":peerconnection_jni",
     "../../pc:peerconnection",
-    "../../system_wrappers",
     "../../system_wrappers:field_trial_default",
+    "../../system_wrappers:metrics_api",
     "../../system_wrappers:metrics_default",
   ]
 }
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index ca11b89..e98c186 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -50,14 +50,12 @@
   defines = []
   libs = []
   deps = [
-    "..:webrtc_common",
-    "../api:optional",
-    "../modules:module_api_public",
-  ]
-  public_deps = [
     ":cpu_features_api",
     ":field_trial_api",
     ":metrics_api",
+    "..:webrtc_common",
+    "../api:optional",
+    "../modules:module_api_public",
   ]
 
   if (is_android) {
@@ -211,6 +209,7 @@
     }
 
     deps = [
+      ":metrics_api",
       ":metrics_default",
       ":system_wrappers",
       "..:webrtc_common",
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 8bc9541..936d375 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -108,7 +108,7 @@
 
   deps = [
     "..:webrtc_common",
-    "../system_wrappers",
+    "../system_wrappers:field_trial_api",
     "../system_wrappers:field_trial_default",
   ]
 }
@@ -504,7 +504,7 @@
     "../common_audio:common_audio",
     "../modules/audio_device:audio_device",
     "../rtc_base:rtc_base_approved",
-    "../system_wrappers:system_wrappers",
+    "../system_wrappers",
   ]
 }
 
@@ -585,6 +585,7 @@
     "../rtc_base:rtc_task_queue",
     "../rtc_base:sequenced_task_checker",
     "../system_wrappers",
+    "../system_wrappers:field_trial_api",
     "../video",
     "../voice_engine",
     "//testing/gmock",
diff --git a/video/BUILD.gn b/video/BUILD.gn
index c30f42f..ea31bf5 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -64,6 +64,8 @@
     "../call:rtp_interfaces",
     "../call:video_stream_api",
     "../modules/rtp_rtcp:rtp_rtcp_format",
+    "../system_wrappers:field_trial_api",
+    "../system_wrappers:metrics_api",
 
     # For RtxReceiveStream.
     "../call:rtp_receiver",
@@ -115,6 +117,7 @@
       "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue",
       "../system_wrappers",
+      "../system_wrappers:field_trial_api",
       "../test:rtp_test_utils",
       "../test:test_common",
       "../test:test_renderer",
diff --git a/voice_engine/BUILD.gn b/voice_engine/BUILD.gn
index 292e8c4..c8bc8c5 100644
--- a/voice_engine/BUILD.gn
+++ b/voice_engine/BUILD.gn
@@ -76,6 +76,8 @@
     "../rtc_base:rtc_base_approved",
     "../rtc_base:rtc_task_queue",
     "../system_wrappers",
+    "../system_wrappers:field_trial_api",
+    "../system_wrappers:metrics_api",
   ]
 }