GN: Changes for vp9, opus and direct trace

Corresponding GN changes for
https://webrtc-codereview.appspot.com/34099004/

BUG=4185
R=brettw@chromium.org

Review URL: https://webrtc-codereview.appspot.com/40669004

Cr-Commit-Position: refs/heads/master@{#8377}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8377 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/build/webrtc.gni b/webrtc/build/webrtc.gni
index 6459dae..7fdd462 100644
--- a/webrtc/build/webrtc.gni
+++ b/webrtc/build/webrtc.gni
@@ -46,6 +46,7 @@
   rtc_build_libjpeg = true
   rtc_build_libyuv = true
   rtc_build_libvpx = true
+  rtc_build_vp9 = true
   rtc_build_ssl = true
 
   # Disable by default.
@@ -66,6 +67,10 @@
   # https://gcc.gnu.org/wiki/LinkTimeOptimization
   rtc_use_lto = false
 
+  # Directly call the trace callback instead of passing it to a logging
+  # thread. Used for components that provide their own threaded logging.
+  rtc_use_direct_trace = false
+
   if (build_with_chromium) {
     # Exclude pulse audio on Chromium since its prerequisites don't require
     # pulse audio.
@@ -116,3 +121,9 @@
   # //build/config/arm.gni (since it disables Neon for Android).
   rtc_build_armv7_neon = (cpu_arch == "arm" && arm_version >= 7)
 }
+
+# Make it possible to provide custom locations for some libraries (move these
+# up into declare_args should we need to actually use them for the GN build).
+rtc_libvpx_dir = "//third_party/libvpx"
+rtc_libyuv_dir = "//third_party/libyuv"
+rtc_opus_dir = "//third_party/opus"
diff --git a/webrtc/common_video/BUILD.gn b/webrtc/common_video/BUILD.gn
index 8085bce..2999847 100644
--- a/webrtc/common_video/BUILD.gn
+++ b/webrtc/common_video/BUILD.gn
@@ -47,10 +47,10 @@
   deps = [ "../system_wrappers" ]
 
   if (rtc_build_libyuv) {
-    deps += [ "//third_party/libyuv" ]
-    public_deps = [ "//third_party/libyuv" ]
+    deps += [ "$rtc_libyuv_dir" ]
+    public_deps = [ "$rtc_libyuv_dir" ]
   } else {
     # Need to add a directory normally exported by libyuv.
-    include_dirs += [ "//third_party/libyuv/include" ]
+    include_dirs += [ "$rtc_libyuv_dir/include" ]
   }
 }
diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn
index f4952a7..2577f34 100644
--- a/webrtc/modules/audio_coding/BUILD.gn
+++ b/webrtc/modules/audio_coding/BUILD.gn
@@ -718,7 +718,7 @@
     configs += [ "../..:common_config" ]
     public_configs = [ "../..:common_inherited_config" ]
 
-    deps += [ "//third_party/opus" ]
+    deps += [ rtc_opus_dir ]
   }
 }
 
@@ -806,7 +806,7 @@
     ":neteq_config",
   ]
 
-  forward_dependent_configs_from = [ "//third_party/opus" ]
+  forward_dependent_configs_from = [ rtc_opus_dir ]
 
   if (is_clang) {
     # Suppress warnings from Chrome's Clang plugins.
@@ -825,6 +825,6 @@
     ":pcm16b",
     "../../common_audio",
     "../../system_wrappers",
-    "//third_party/opus",
+    rtc_opus_dir,
   ]
 }
diff --git a/webrtc/modules/video_coding/BUILD.gn b/webrtc/modules/video_coding/BUILD.gn
index 969ce8a..353eca2 100644
--- a/webrtc/modules/video_coding/BUILD.gn
+++ b/webrtc/modules/video_coding/BUILD.gn
@@ -166,7 +166,7 @@
 
   # TODO(kjellander): Remove once libvpx has changed it's libvpx_config to be
   # in direct_dependent_configs.
-  configs += [ "//third_party/libvpx:libvpx_config" ]
+  configs += [ "$rtc_libvpx_dir:libvpx_config" ]
 
   deps = [
     ":video_coding_utility",
@@ -175,17 +175,21 @@
   ]
   if (rtc_build_libvpx) {
     deps += [
-      "//third_party/libvpx",
+      rtc_libvpx_dir,
     ]
   }
 }
 
 source_set("webrtc_vp9") {
-  sources = [
-    "codecs/vp9/include/vp9.h",
-    "codecs/vp9/vp9_impl.cc",
-    "codecs/vp9/vp9_impl.h",
-  ]
+  if (rtc_build_vp9) {
+    sources = [
+      "codecs/vp9/include/vp9.h",
+      "codecs/vp9/vp9_impl.cc",
+      "codecs/vp9/vp9_impl.h",
+    ]
+  } else {
+    sources = [ "codecs/vp9/vp9_dummy_impl.cc" ]
+  }
 
   configs += [ "../..:common_config" ]
   public_configs = [ "../..:common_inherited_config" ]
@@ -198,7 +202,7 @@
 
   # TODO(kjellander): Remove once libvpx has changed it's libvpx_config to be
   # in direct_dependent_configs.
-  configs += [ "//third_party/libvpx:libvpx_config" ]
+  configs += [ "$rtc_libvpx_dir:libvpx_config" ]
 
   deps = [
     ":video_coding_utility",
@@ -207,7 +211,7 @@
   ]
   if (rtc_build_libvpx) {
     deps += [
-      "//third_party/libvpx",
+      rtc_libvpx_dir,
     ]
   }
 }
diff --git a/webrtc/system_wrappers/BUILD.gn b/webrtc/system_wrappers/BUILD.gn
index 23063f3..720fa87 100644
--- a/webrtc/system_wrappers/BUILD.gn
+++ b/webrtc/system_wrappers/BUILD.gn
@@ -122,6 +122,10 @@
   libs = []
   deps = []
 
+  if (rtc_use_direct_trace) {
+    defines += [ "WEBRTC_DIRECT_TRACE" ]
+  }
+
   if (is_android) {
     sources += [
       "interface/logcat_trace_context.h",