resolve merge conflicts of 99b39aa to nyc-mr1-dev-plus-aosp

Change-Id: Ic05b48ec1ae8b1110c231d1bc28a0e05ff38ebc1
diff --git a/audio_utils/Android.bp b/audio_utils/Android.bp
new file mode 100644
index 0000000..c198d7a
--- /dev/null
+++ b/audio_utils/Android.bp
@@ -0,0 +1,102 @@
+subdirs = ["tests"]
+
+cc_defaults {
+    name: "audio_utils_defaults",
+
+    local_include_dirs: ["include"],
+    export_include_dirs: ["include"],
+
+    cflags: [
+        "-Werror",
+        "-Wall",
+    ],
+}
+
+cc_library {
+    name: "libaudioutils",
+    host_supported: true,
+    defaults: ["audio_utils_defaults"],
+
+    srcs: [
+        "channels.c",
+        "fifo.c",
+        "format.c",
+        "limiter.c",
+        "minifloat.c",
+        "primitives.c",
+        "roundup.c",
+    ],
+
+    shared_libs: [
+        "libcutils",
+        "liblog",
+    ],
+
+    target: {
+        android: {
+            srcs: [
+                "conversion.cpp",
+                "resampler.c",
+                "echo_reference.c",
+            ],
+            whole_static_libs: ["libaudioutils_fixedfft"],
+            shared_libs: [
+                "libspeexresampler",
+            ],
+        },
+        host: {
+            cflags: ["-D__unused='__attribute__((unused))'"],
+        },
+    },
+}
+
+cc_library_static {
+    name: "libaudioutils_fixedfft",
+    defaults: ["audio_utils_defaults"],
+
+    arch: {
+        arm: {
+            instruction_set: "arm",
+        },
+    },
+
+    srcs: ["fixedfft.cpp"],
+}
+
+cc_library_static {
+    name: "libsndfile",
+    defaults: ["audio_utils_defaults"],
+    host_supported: true,
+    srcs: ["tinysndfile.c"],
+    cflags: [
+        "-UHAVE_STDERR",
+    ],
+}
+
+cc_library_static {
+    name: "libfifo",
+    defaults: ["audio_utils_defaults"],
+    srcs: [
+        "fifo.c",
+        "primitives.c",
+        "roundup.c",
+    ],
+}
+
+cc_library_shared {
+    name: "libaudiospdif",
+    defaults: ["audio_utils_defaults"],
+
+    srcs: [
+        "spdif/BitFieldParser.cpp",
+        "spdif/FrameScanner.cpp",
+        "spdif/AC3FrameScanner.cpp",
+        "spdif/DTSFrameScanner.cpp",
+        "spdif/SPDIFEncoder.cpp",
+    ],
+
+    shared_libs: [
+        "libcutils",
+        "liblog",
+    ],
+}
diff --git a/audio_utils/Android.mk b/audio_utils/Android.mk
deleted file mode 100644
index 32c94e2..0000000
--- a/audio_utils/Android.mk
+++ /dev/null
@@ -1,104 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libaudioutils
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES:= \
-	channels.c \
-	conversion.cpp \
-	fifo.c \
-	fixedfft.cpp.arm \
-	format.c \
-	limiter.c \
-	minifloat.c \
-	primitives.c \
-	resampler.c \
-	roundup.c \
-	echo_reference.c
-
-LOCAL_CFLAGS := -Wno-unused-parameter
-LOCAL_C_INCLUDES += $(call include-path-for, speex)
-LOCAL_C_INCLUDES += \
-	$(call include-path-for, speex) \
-	$(call include-path-for, audio-utils)
-
-LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	liblog \
-	libspeexresampler
-
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libaudioutils
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := \
-	channels.c \
-	fifo.c \
-	format.c \
-	limiter.c \
-	minifloat.c \
-	primitives.c \
-	roundup.c
-LOCAL_C_INCLUDES += \
-	$(call include-path-for, audio-utils)
-LOCAL_CFLAGS := -Werror -Wall
-LOCAL_CFLAGS += -D__unused='__attribute__((unused))'
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libsndfile
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-	tinysndfile.c
-
-LOCAL_C_INCLUDES += \
-	$(call include-path-for, audio-utils)
-
-LOCAL_CFLAGS := -Werror -Wall
-LOCAL_CFLAGS += -UHAVE_STDERR
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libsndfile
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-	tinysndfile.c
-
-LOCAL_C_INCLUDES += \
-	$(call include-path-for, audio-utils)
-
-#LOCAL_SHARED_LIBRARIES := libaudioutils
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libfifo
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-	fifo.c \
-	primitives.c \
-	roundup.c
-
-LOCAL_CFLAGS := -Wno-unused-parameter
-LOCAL_C_INCLUDES += \
-	$(call include-path-for, audio-utils)
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/audio_utils/spdif/Android.mk b/audio_utils/spdif/Android.mk
deleted file mode 100644
index b218bd3..0000000
--- a/audio_utils/spdif/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libaudiospdif
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES:= \
-	BitFieldParser.cpp \
-	FrameScanner.cpp \
-	AC3FrameScanner.cpp \
-	DTSFrameScanner.cpp \
-	SPDIFEncoder.cpp
-
-LOCAL_C_INCLUDES += $(call include-path-for, audio-utils)
-
-LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	liblog
-
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_utils/tests/Android.bp b/audio_utils/tests/Android.bp
new file mode 100644
index 0000000..2d5f1a4
--- /dev/null
+++ b/audio_utils/tests/Android.bp
@@ -0,0 +1,46 @@
+// Build the unit tests for audio_utils
+
+cc_test {
+    name: "primitives_tests",
+    host_supported: true,
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+    ],
+    srcs: ["primitives_tests.cpp"],
+    cflags: [
+        "-Werror",
+        "-Wall",
+    ],
+    target: {
+        android: {
+            shared_libs: ["libaudioutils"],
+        },
+        host: {
+            static_libs: ["libaudioutils"],
+        },
+    }
+}
+
+cc_binary {
+    name: "fifo_tests",
+    host_supported: true,
+    srcs: ["fifo_tests.cpp"],
+    shared_libs: ["libaudioutils"],
+    static_libs: ["libsndfile"],
+    cflags: [
+        "-Werror",
+        "-Wall",
+    ],
+}
+
+cc_binary_host {
+    name: "limiter_tests",
+    srcs: ["limiter_tests.c"],
+    static_libs: ["libaudioutils"],
+    cflags: [
+        "-Werror",
+        "-Wall",
+    ],
+}
diff --git a/audio_utils/tests/Android.mk b/audio_utils/tests/Android.mk
deleted file mode 100644
index cd76cf0..0000000
--- a/audio_utils/tests/Android.mk
+++ /dev/null
@@ -1,59 +0,0 @@
-# Build the unit tests for audio_utils
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := \
-	liblog \
-	libcutils \
-	libaudioutils
-LOCAL_C_INCLUDES := \
-	$(call include-path-for, audio-utils)
-LOCAL_SRC_FILES := \
-	primitives_tests.cpp
-LOCAL_MODULE := primitives_tests
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := \
-	liblog \
-	libcutils
-LOCAL_STATIC_LIBRARIES := \
-	libaudioutils
-LOCAL_C_INCLUDES := \
-	$(call include-path-for, audio-utils)
-LOCAL_SRC_FILES := \
-	primitives_tests.cpp
-LOCAL_MODULE := primitives_tests
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_HOST_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := fifo_tests.cpp
-LOCAL_MODULE := fifo_tests
-LOCAL_C_INCLUDES := $(call include-path-for, audio-utils)
-LOCAL_SHARED_LIBRARIES := libaudioutils
-# libmedia libbinder libcutils libutils
-LOCAL_STATIC_LIBRARIES := libsndfile
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := fifo_tests.cpp
-LOCAL_MODULE := fifo_tests
-LOCAL_C_INCLUDES := $(call include-path-for, audio-utils)
-# libmedia libbinder libcutils libutils
-LOCAL_STATIC_LIBRARIES := libsndfile libaudioutils liblog
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := limiter_tests.c
-LOCAL_MODULE := limiter_tests
-LOCAL_C_INCLUDES := $(call include-path-for, audio-utils)
-LOCAL_STATIC_LIBRARIES := libaudioutils
-LOCAL_CFLAGS := -Werror -Wall
-include $(BUILD_HOST_EXECUTABLE)