Don't link with audio codecs that we don't use

We used to link with all audio codecs unconditionally (except Opus);
this patch makes gyp and gn only link to the ones that are used.

(This unfortunately fails to have a measurable impact on Chromium
binary size, at least on x86_64 Linux; it turns out that iLBC and iSAC
fix were already being excluded from Chromium by some other means
(likely just the linker omitting compilation units with no incoming
references).)

BUG=webrtc:4557

Review URL: https://codereview.webrtc.org/1349393003

Cr-Commit-Position: refs/heads/master@{#10046}
diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn
index 5725ec0..b1d8ceb 100644
--- a/webrtc/modules/audio_coding/BUILD.gn
+++ b/webrtc/modules/audio_coding/BUILD.gn
@@ -67,13 +67,8 @@
   deps = [
     ":cng",
     ":g711",
-    ":g722",
-    ":ilbc",
-    ":isac",
-    ":isac_fix",
     ":neteq",
     ":pcm16b",
-    ":red",
     "../..:rtc_event_log",
     "../..:webrtc_common",
     "../../common_audio",
@@ -84,6 +79,27 @@
     defines += [ "WEBRTC_CODEC_OPUS" ]
     deps += [ ":webrtc_opus" ]
   }
+  if (!build_with_mozilla) {
+    if (current_cpu == "arm") {
+      defines += [ "WEBRTC_CODEC_ISACFX" ]
+      deps += [ ":isac_fix" ]
+    } else {
+      defines += [ "WEBRTC_CODEC_ISAC" ]
+      deps += [ ":isac" ]
+    }
+    defines += [ "WEBRTC_CODEC_G722" ]
+    deps += [ ":g722" ]
+  }
+  if (!build_with_mozilla && !build_with_chromium) {
+    defines += [
+      "WEBRTC_CODEC_ILBC",
+      "WEBRTC_CODEC_RED",
+    ]
+    deps += [
+      ":ilbc",
+      ":red",
+    ]
+  }
 }
 
 source_set("audio_decoder_interface") {
@@ -788,10 +804,6 @@
     ":audio_decoder_interface",
     ":cng",
     ":g711",
-    ":g722",
-    ":ilbc",
-    ":isac",
-    ":isac_fix",
     ":pcm16b",
     "../..:webrtc_common",
     "../../common_audio",
@@ -804,4 +816,19 @@
     defines += [ "WEBRTC_CODEC_OPUS" ]
     deps += [ ":webrtc_opus" ]
   }
+  if (!build_with_mozilla) {
+    if (current_cpu == "arm") {
+      defines += [ "WEBRTC_CODEC_ISACFX" ]
+      deps += [ ":isac_fix" ]
+    } else {
+      defines += [ "WEBRTC_CODEC_ISAC" ]
+      deps += [ ":isac" ]
+    }
+    defines += [ "WEBRTC_CODEC_G722" ]
+    deps += [ ":g722" ]
+  }
+  if (!build_with_mozilla && !build_with_chromium) {
+    defines += [ "WEBRTC_CODEC_ILBC" ]
+    deps += [ ":ilbc" ]
+  }
 }