Remove the expat and jsoncpp dependencies to reduce binary size.

The dependency on third_party/expat/ is removed.

The dependency on third_party/jsoncpp is removed from
libjingle_peerconnection while peerconnection_client still
depends on it.

BUG=webrtc:7516

Review-Url: https://codereview.webrtc.org/2832283002
Cr-Original-Commit-Position: refs/heads/master@{#17848}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 44d305a80618eb1d3ab481dd3743adbb167382ec
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 6f1d429..9e5bdc6 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -368,6 +368,25 @@
   }
 }
 
+rtc_source_set("rtc_json") {
+  defines = []
+  sources = [
+    "json.cc",
+    "json.h",
+  ]
+  if (rtc_build_json) {
+    public_deps = [
+      "//third_party/jsoncpp",
+    ]
+  } else {
+    include_dirs = [ "$rtc_jsoncpp_root" ]
+
+    # When defined changes the include path for json.h to where it is
+    # expected to be when building json outside of the standalone build.
+    defines += [ "WEBRTC_EXTERNAL_JSON" ]
+  }
+}
+
 rtc_static_library("rtc_base") {
   cflags = []
   cflags_cc = []
@@ -503,8 +522,6 @@
     configs += [ ":rtc_base_warnings_config" ]
     sources += [
       "callback.h",
-      "json.cc",
-      "json.h",
       "logsinks.cc",
       "logsinks.h",
       "mathutils.h",
@@ -530,16 +547,6 @@
         "win32socketserver.h",
       ]
     }
-
-    if (rtc_build_json) {
-      deps += [ "//third_party/jsoncpp" ]
-    } else {
-      include_dirs = [ "$rtc_jsoncpp_root" ]
-
-      # When defined changes the include path for json.h to where it is
-      # expected to be when building json outside of the standalone build.
-      defines += [ "WEBRTC_EXTERNAL_JSON" ]
-    }
   }  # !build_with_chromium
 
   if (rtc_build_ssl) {
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index a33ecc7..80b3efa 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -517,15 +517,13 @@
       "//webrtc/api:video_frame_api",
       "//webrtc/base:rtc_base",
       "//webrtc/base:rtc_base_approved",
+      "//webrtc/base:rtc_json",
       "//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") {
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 3141c52..e4770cc 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -91,13 +91,6 @@
     "../system_wrappers:field_trial_api",
   ]
 
-  if (rtc_build_expat) {
-    deps += [ "//third_party/expat" ]
-    public_deps = [
-      "//third_party/expat",
-    ]
-  }
-
   public_configs = [ ":rtc_p2p_inherited_config" ]
 
   if (build_with_chromium) {
diff --git a/webrtc.gni b/webrtc.gni
index e47ac08..5e1c12d 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -78,7 +78,6 @@
   rtc_enable_sctp = true
 
   # Disable these to not build components which can be externally provided.
-  rtc_build_expat = true
   rtc_build_json = true
   rtc_build_libjpeg = true
   rtc_build_libsrtp = true