Restructure GYP for vp9, opus and direct trace

This is needed to make the build more flexible for some use cases.

BUG=4185
R=andresp@webrtc.org, stefan@webrtc.org, tommi@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8290}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8290 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi
index 4a9e7b8..e680ba0 100644
--- a/webrtc/build/common.gypi
+++ b/webrtc/build/common.gypi
@@ -41,6 +41,7 @@
       'webrtc_vp8_dir%': '<(webrtc_root)/modules/video_coding/codecs/vp8',
       'webrtc_vp9_dir%': '<(webrtc_root)/modules/video_coding/codecs/vp9',
       'include_opus%': 1,
+      'opus_dir%': '<(DEPTH)/third_party/opus',
     },
     'build_with_chromium%': '<(build_with_chromium)',
     'build_with_libjingle%': '<(build_with_libjingle)',
@@ -92,6 +93,7 @@
     'build_libjpeg%': 1,
     'build_libyuv%': 1,
     'build_libvpx%': 1,
+    'build_vp9%': 1,
     'build_ssl%': 1,
 
     # Disable by default
@@ -100,7 +102,10 @@
     # Enable to use the Mozilla internal settings.
     'build_with_mozilla%': 0,
 
+    # Make it possible to provide custom locations for some libraries.
+    'libvpx_dir%': '<(DEPTH)/third_party/libvpx',
     'libyuv_dir%': '<(DEPTH)/third_party/libyuv',
+    'opus_dir%': '<(opus_dir)',
 
     # Define MIPS architecture variant, MIPS DSP variant and MIPS FPU
     # This may be subject to change in accordance to Chromium's MIPS flags
@@ -122,6 +127,10 @@
     # enable schannel on windows.
     'use_legacy_ssl_defaults%': 0,
 
+    # 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%': 0,
+
     'conditions': [
       ['build_with_chromium==1', {
         # Exclude pulse audio on Chromium since its prerequisites don't require
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus.gypi b/webrtc/modules/audio_coding/codecs/opus/opus.gypi
index c9f65f9..4b61220 100644
--- a/webrtc/modules/audio_coding/codecs/opus/opus.gypi
+++ b/webrtc/modules/audio_coding/codecs/opus/opus.gypi
@@ -19,7 +19,7 @@
            ]
         }, {
           'dependencies': [
-            '<(DEPTH)/third_party/opus/opus.gyp:opus'
+            '<(opus_dir)/opus.gyp:opus'
           ],
         }],
       ],
diff --git a/webrtc/modules/audio_coding/neteq/neteq.gypi b/webrtc/modules/audio_coding/neteq/neteq.gypi
index 5e3f250..a301c37 100644
--- a/webrtc/modules/audio_coding/neteq/neteq.gypi
+++ b/webrtc/modules/audio_coding/neteq/neteq.gypi
@@ -26,7 +26,7 @@
     ],
     'neteq_dependencies': [
       '<@(codecs)',
-      '<(DEPTH)/third_party/opus/opus.gyp:opus',
+      '<(opus_dir)/opus.gyp:opus',
       '<(webrtc_root)/common_audio/common_audio.gyp:common_audio',
       '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
       'audio_decoder_interface',
@@ -55,7 +55,7 @@
         ],
       },
       'export_dependent_settings': [
-        '<(DEPTH)/third_party/opus/opus.gyp:opus',
+        '<(opus_dir)/opus.gyp:opus',
       ],
       'sources': [
         'interface/neteq.h',
diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp
index 4a92d21..8c7526f 100644
--- a/webrtc/modules/modules.gyp
+++ b/webrtc/modules/modules.gyp
@@ -326,7 +326,7 @@
             }],
             ['build_libvpx==1', {
               'dependencies': [
-                '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx',
+                '<(libvpx_dir)/libvpx.gyp:libvpx',
               ],
             }],
             ['OS=="android"', {
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8.gyp b/webrtc/modules/video_coding/codecs/vp8/vp8.gyp
index 63cc854..3401f48 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8.gyp
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8.gyp
@@ -22,7 +22,7 @@
       'conditions': [
         ['build_libvpx==1', {
           'dependencies': [
-            '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx',
+            '<(libvpx_dir)/libvpx.gyp:libvpx',
           ],
         }],
       ],
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9.gyp b/webrtc/modules/video_coding/codecs/vp9/vp9.gyp
index c4c93c9..795db62 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9.gyp
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9.gyp
@@ -22,14 +22,20 @@
       'conditions': [
         ['build_libvpx==1', {
           'dependencies': [
-            '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx',
+            '<(libvpx_dir)/libvpx.gyp:libvpx',
           ],
         }],
-      ],
-      'sources': [
-        'include/vp9.h',
-        'vp9_impl.cc',
-        'vp9_impl.h',
+        ['build_vp9==1', {
+          'sources': [
+            'include/vp9.h',
+            'vp9_impl.cc',
+            'vp9_impl.h',
+          ],
+        }, {
+          'sources': [
+            'vp9_dummy_impl.cc',
+          ],
+        }],
       ],
     },
   ],
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_dummy_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_dummy_impl.cc
new file mode 100644
index 0000000..491ccbe
--- /dev/null
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_dummy_impl.cc
@@ -0,0 +1,19 @@
+/*
+ *  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.
+ *
+ */
+
+// This file contains an implementation of empty webrtc VP9 encoder/decoder
+// factories so it is possible to build webrtc without linking with vp9.
+#include "webrtc/modules/video_coding/codecs/vp9/vp9_impl.h"
+
+namespace webrtc {
+VP9Encoder* VP9Encoder::Create() { return nullptr; }
+VP9Decoder* VP9Decoder::Create() { return nullptr; }
+}
diff --git a/webrtc/system_wrappers/system_wrappers.gyp b/webrtc/system_wrappers/system_wrappers.gyp
index 3af8897..50801de 100644
--- a/webrtc/system_wrappers/system_wrappers.gyp
+++ b/webrtc/system_wrappers/system_wrappers.gyp
@@ -115,6 +115,11 @@
         }, {
           'sources!': [ 'source/data_log.cc', ],
         },],
+        ['rtc_use_direct_trace==1', {
+          'defines': [
+            'WEBRTC_DIRECT_TRACE',
+          ],
+        }],
         ['OS=="android"', {
           'defines': [
             'WEBRTC_THREAD_RR',