Adding build_opus as a switch in GYP.

This is to allow not building Opus. On non-chromium non-gyp chases, one can let WebRTC depend on other Opus builds.

BUG=
R=kjellander@webrtc.org, tina.legrand@webrtc.org

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

Cr-Original-Commit-Position: refs/heads/master@{#8754}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 7c112f3e5ae8b7d807f006c191291e5d4b56a38d
diff --git a/build/common.gypi b/build/common.gypi
index df6c7e3..3c3a94d 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -91,6 +91,7 @@
     'build_vp9%': 1,
     'build_ssl%': 1,
     'build_openmax_dl%': 1,
+    'build_opus%': 1,
 
     # Disable by default
     'have_dbus_glib%': 0,
diff --git a/build/webrtc.gni b/build/webrtc.gni
index a42c932..2315f11 100644
--- a/build/webrtc.gni
+++ b/build/webrtc.gni
@@ -43,6 +43,7 @@
   rtc_build_libvpx = true
   rtc_build_vp9 = true
   rtc_build_ssl = true
+  rtc_build_opus = true
 
   # Disable by default.
   rtc_have_dbus_glib = false
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index b102816..c88653e 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -666,14 +666,14 @@
 
   deps = [ ":audio_encoder_interface" ]
 
-  if (build_with_mozilla) {
-    include_dirs = [ getenv("DIST") + "/include/opus" ]
-  } else {
+  if (rtc_build_opus) {
     configs += [ "../..:common_config" ]
     public_configs = [ "../..:common_inherited_config" ]
 
     deps += [ rtc_opus_dir ]
     forward_dependent_configs_from = [ rtc_opus_dir ]
+  } else if (build_with_mozilla) {
+    include_dirs = [ getenv("DIST") + "/include/opus" ]
   }
 }
 
diff --git a/modules/audio_coding/codecs/opus/opus.gypi b/modules/audio_coding/codecs/opus/opus.gypi
index 48c7bdf..4ae4340 100644
--- a/modules/audio_coding/codecs/opus/opus.gypi
+++ b/modules/audio_coding/codecs/opus/opus.gypi
@@ -12,12 +12,7 @@
       'target_name': 'webrtc_opus',
       'type': 'static_library',
       'conditions': [
-        ['build_with_mozilla==1', {
-          # Mozilla provides its own build of the opus library.
-          'include_dirs': [
-            '$(DIST)/include/opus',
-           ]
-        }, {
+        ['build_opus==1', {
           'dependencies': [
             '<(opus_dir)/opus.gyp:opus'
           ],
@@ -30,6 +25,15 @@
               '<(opus_dir)/src/celt',
             ],
           },
+        }, {
+          'conditions': [
+            ['build_with_mozilla==1', {
+              # Mozilla provides its own build of the opus library.
+              'include_dirs': [
+                '$(DIST)/include/opus',
+              ]
+            }],
+          ],
         }],
       ],
       'dependencies': [