Split aec and aecm into separate build targets

This clarifies dependencies and makes it easier to customize builds
for different binaries.

Also adds BUILD files in aec/ and aecm/.

Moves unit tests to their own target, which subjects them to Chromium
Clang style checks.
The CL contains a fix for a thusly induced warning.

Bug: webrtc:9488
Change-Id: I77b680b42a4dccc5f025005e0890f60b4eaf2961
Reviewed-on: https://webrtc-review.googlesource.com/87304
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23887}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index b43a98b..4be7d8f 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -30,10 +30,6 @@
   visibility = [ "*" ]
   configs += [ ":apm_debug_dump" ]
   sources = [
-    "aec/aec_resampler.cc",
-    "aec/aec_resampler.h",
-    "aec/echo_cancellation.cc",
-    "aec/echo_cancellation.h",
     "audio_buffer.cc",
     "audio_buffer.h",
     "audio_processing_impl.cc",
@@ -99,7 +95,6 @@
 
   defines = []
   deps = [
-    ":aec_core",
     ":apm_logging",
     ":audio_frame_view",
     ":audio_generator_interface",
@@ -123,6 +118,9 @@
     "../../system_wrappers:cpu_features_api",
     "../../system_wrappers:field_trial_api",
     "../../system_wrappers:metrics_api",
+    "aec:aec",
+    "aec:aec_core",
+    "aecm:aecm_core",
     "agc",
     "agc:agc_legacy_c",
     "agc2:adaptive_digital",
@@ -317,81 +315,6 @@
   defines = []
 }
 
-rtc_source_set("aec_core") {
-  configs += [ ":apm_debug_dump" ]
-  sources = [
-    "aec/aec_common.h",
-    "aec/aec_core.cc",
-    "aec/aec_core.h",
-    "aec/aec_core_optimized_methods.h",
-    "aecm/aecm_core.cc",
-    "aecm/aecm_core.h",
-    "aecm/aecm_defines.h",
-    "aecm/echo_control_mobile.cc",
-    "aecm/echo_control_mobile.h",
-  ]
-  deps = [
-    ":apm_logging",
-    ":audio_processing_statistics",
-    "../..:typedefs",
-    "../..:webrtc_common",
-    "../../common_audio:common_audio",
-    "../../common_audio:common_audio_c",
-    "../../rtc_base:checks",
-    "../../rtc_base:rtc_base_approved",
-    "../../rtc_base:sanitizer",
-    "../../system_wrappers:cpu_features_api",
-    "../../system_wrappers:metrics_api",
-    "utility:block_mean_calculator",
-    "utility:legacy_delay_estimator",
-    "utility:ooura_fft",
-  ]
-  cflags = []
-  defines = []
-
-  if (current_cpu == "x86" || current_cpu == "x64") {
-    sources += [ "aec/aec_core_sse2.cc" ]
-    if (is_posix || is_fuchsia) {
-      cflags += [ "-msse2" ]
-    }
-  }
-
-  if (rtc_build_with_neon) {
-    sources += [
-      "aec/aec_core_neon.cc",
-      "aecm/aecm_core_neon.cc",
-    ]
-
-    if (current_cpu != "arm64") {
-      # Enable compilation for the NEON instruction set. This is needed
-      # since //build/config/arm.gni only enables NEON for iOS, not Android.
-      # This provides the same functionality as webrtc/build/arm_neon.gypi.
-      suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
-      cflags += [ "-mfpu=neon" ]
-    }
-
-    # Disable LTO on NEON targets due to compiler bug.
-    # TODO(fdegans): Enable this. See crbug.com/408997.
-    if (rtc_use_lto) {
-      cflags -= [
-        "-flto",
-        "-ffat-lto-objects",
-      ]
-    }
-
-    deps += [ "../../common_audio" ]
-  }
-
-  if (current_cpu == "mipsel") {
-    sources += [ "aecm/aecm_core_mips.cc" ]
-    if (mips_float_abi == "hard") {
-      sources += [ "aec/aec_core_mips.cc" ]
-    }
-  } else {
-    sources += [ "aecm/aecm_core_c.cc" ]
-  }
-}
-
 if (rtc_include_tests) {
   rtc_source_set("mocks") {
     testonly = true
@@ -433,8 +356,6 @@
 
     configs += [ ":apm_debug_dump" ]
     sources = [
-      "aec/echo_cancellation_unittest.cc",
-      "aec/system_delay_unittest.cc",
       "audio_buffer_unittest.cc",
       "audio_frame_view_unittest.cc",
       "config_unittest.cc",
@@ -454,7 +375,6 @@
     ]
 
     deps = [
-      ":aec_core",
       ":analog_mic_simulation",
       ":apm_logging",
       ":audio_frame_view",
@@ -481,6 +401,8 @@
       "../../test:fileutils",
       "../../test:test_support",
       "../audio_coding:neteq_input_audio_tools",
+      "aec:aec_core",
+      "aec:aec_unittests",
       "aec_dump:mock_aec_dump_unittests",
       "agc:agc_unittests",
       "agc2:adaptive_digital_unittests",