Convert sound_trigger_hal/Android.mk to Android.bp am: aadb1dc327

Original change: https://android-review.googlesource.com/c/platform/hardware/knowles/athletico/sound_trigger_hal/+/1964939

Change-Id: Idf7308a3736e597077c22ffd0f347afeea67d752
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..30c2b42
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,393 @@
+// Copyright (C) 2018 Knowles Electronics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: [
+        "Android-Apache-2.0",
+    ],
+}
+
+soong_config_string_variable {
+    name: "use_sound_trigger_hal",
+    values: [
+        "iaxxx",
+    ],
+}
+
+soong_config_string_variable {
+    name: "platform_version_use_sound_trigger_hal",
+    values: [
+        "P",
+    ],
+}
+
+soong_config_module_type {
+    name: "use_sound_trigger_hal_cc_defaults",
+    module_type: "cc_defaults",
+    config_namespace: "knowles",
+    variables: [
+        "use_sound_trigger_hal",
+        "platform_version_use_sound_trigger_hal",
+    ],
+    properties: [
+        "enabled",
+        "proprietary",
+        "cflags",
+    ],
+}
+
+use_sound_trigger_hal_cc_defaults {
+    name: "use_sound_trigger_hal_defaults",
+    header_libs: ["device_kernel_headers"],
+    soong_config_variables: {
+        use_sound_trigger_hal: {
+            iaxxx: {
+                enabled: true,
+            },
+            conditions_default: {
+                enabled: false,
+            }
+        },
+        platform_version_use_sound_trigger_hal: {
+            p: {
+                proprietary: true,
+                cflags: ["-DANDROID_P"],
+            },
+            conditions_default: {
+            },
+        }
+    },
+}
+
+cc_library_shared {
+    name: "sound_trigger.primary.msmnile",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    relative_install_path: "hw",
+    srcs: [
+        "sound_trigger_hw_iaxxx.c",
+        "cvq_util.c",
+    ],
+    vendor: true,
+    include_dirs: [
+        "external/tinyalsa/include",
+        "system/media/audio_route/include",
+    ],
+    header_libs: ["libhardware_headers"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libtinyalsa",
+        "libaudioroute",
+        "libodsp",
+        "libhardware_legacy",
+    ],
+}
+
+cc_library_shared {
+    name: "adnc_strm.primary.default",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    relative_install_path: "hw",
+    vendor: true,
+    srcs: ["adnc_strm.c"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libtinyalsa",
+        "libtunnel",
+    ],
+}
+
+cc_library_shared {
+    name: "libtunnel",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: ["tunnel.c"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+    ],
+}
+
+cc_library_shared {
+    name: "libodsp",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: ["iaxxx_odsp_hw.c"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+    ],
+}
+
+cc_binary {
+    name: "tunneling_hal_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: [
+        "tests/tunnel_test.c",
+        "tests/conversion_routines.c",
+    ],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libtunnel",
+    ],
+    cflags: ["-DFILENAME_ASSIGN"],
+}
+
+cc_binary {
+    name: "sensor_param_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: ["tests/sensor_param_test.c"],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libtinyalsa",
+    ],
+    include_dirs: ["external/tinyalsa/include"],
+}
+
+cc_library_shared {
+    name: "libosloutils",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: [
+        "tests/oslo_sound_model_control.cpp",
+        "tests/oslo_iaxxx_sensor_control.c",
+    ],
+    include_dirs: [
+        "external/tinyalsa/include",
+        "system/media/audio_route/include",
+    ],
+    header_libs: ["libhardware_headers"],
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libtinyalsa",
+        "libhidlbase",
+        "libodsp",
+        "android.hardware.soundtrigger@2.0",
+    ],
+    proprietary: true,
+}
+
+cc_binary {
+    name: "oslo_data_injection_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/oslo_data_injection_test.c"],
+    compile_multilib: "32",
+    header_libs: ["libhardware_headers"],
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libosloutils",
+    ],
+    proprietary: true,
+}
+
+cc_binary {
+    name: "oslo_config_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/oslo_config_test.c"],
+    compile_multilib: "32",
+    header_libs: ["libhardware_headers"],
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libosloutils",
+    ],
+    proprietary: true,
+}
+
+cc_binary {
+    name: "oslo_get_stats",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/oslo_get_stats.c"],
+    header_libs: ["libhardware_headers"],
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libosloutils",
+    ],
+    proprietary: true,
+}
+
+cc_binary {
+    name: "spi_reliability_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/spi_reliability_test.c"],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libcutils",
+    ],
+    vendor: true,
+}
+
+cc_binary {
+    name: "oslo_package_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["./tests/oslo_package_test.c"],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libtinyalsa",
+    ],
+    vendor: true,
+}
+
+cc_binary {
+    name: "tunneling_hal_test_sensor",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/tunnel_test_sensor.c"],
+    compile_multilib: "32",
+    shared_libs: ["liblog"],
+    vendor: true,
+}
+
+cc_binary {
+    name: "odsp_api_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: ["tests/odsp_api_test.c"],
+    include_dirs: ["hardware/knowles/athletico/sound_trigger_hal/tests"],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libodsp",
+    ],
+}
+
+cc_binary {
+    name: "dump_debug_info",
+    vendor: true,
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/dump_debug_info.c"],
+    compile_multilib: "32",
+    shared_libs: ["liblog"],
+}
+
+cc_binary {
+    name: "crash_event_logger",
+    vendor: true,
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: [
+        "tests/crash_event_logger.c",
+        "tests/crash_analyzer.c",
+    ],
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libcutils",
+    ],
+}
+
+cc_binary {
+    vendor: true,
+    name: "setparamblk_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/setparamblk_test.c"],
+    compile_multilib: "32",
+    shared_libs: [
+        "libcutils",
+        "libodsp",
+    ],
+}
+
+cc_binary {
+    name: "crash_trigger_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/crash_trigger_test.c"],
+    vendor: true,
+    compile_multilib: "32",
+    shared_libs: [
+        "liblog",
+        "libodsp",
+    ],
+}
+
+cc_binary {
+    name: "plugin_status_test",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    srcs: ["tests/plugin_status_test.c"],
+    vendor: true,
+    local_include_dirs: [""],
+    compile_multilib: "32",
+    shared_libs: [
+        "libcutils",
+        "libodsp",
+    ],
+}
+
+cc_binary {
+    name: "get_pwr_stats",
+    defaults: [
+        "use_sound_trigger_hal_defaults",
+    ],
+    vendor: true,
+    srcs: ["tests/get_pwr_stats.c"],
+    local_include_dirs: [""],
+    compile_multilib: "32",
+    shared_libs: [
+        "libcutils",
+        "liblog",
+    ],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 53c27d7..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,316 +0,0 @@
-# Copyright (C) 2018 Knowles Electronics
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-ifneq (,$(findstring $(USE_SOUND_TRIGGER_HAL),iaxxx))
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := sound_trigger.primary.$(TARGET_BOARD_PLATFORM)
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := sound_trigger_hw_iaxxx.c cvq_util.c
-LOCAL_VENDOR_MODULE := true
-LOCAL_C_INCLUDES += external/tinyalsa/include \
-			$(call include-path-for, audio-route)
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils \
-			libtinyalsa \
-			libaudioroute \
-			libodsp \
-			libhardware_legacy
-LOCAL_MODULE_TAGS := optional
-ifneq (,$(findstring $(PLATFORM_VERSION), P))
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_CFLAGS += -DANDROID_P
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := adnc_strm.primary.default
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := adnc_strm.c
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils \
-			libtinyalsa \
-			libtunnel
-LOCAL_MODULE_TAGS := optional
-ifneq (,$(findstring $(PLATFORM_VERSION), P))
-LOCAL_PROPRIETARY_MODULE := true
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libtunnel
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := tunnel.c
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libodsp
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := iaxxx_odsp_hw.c
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := tunneling_hal_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := tests/tunnel_test.c \
-			tests/conversion_routines.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils \
-			libtunnel
-LOCAL_CFLAGS += -DFILENAME_ASSIGN
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE := sensor_param_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/sensor_param_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog \
-			libutils \
-			libcutils \
-			libtinyalsa
-LOCAL_C_INCLUDES += external/tinyalsa/include \
-		      $(LOCAL_PATH)/../hal
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libosloutils
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/oslo_sound_model_control.cpp \
-			tests/oslo_iaxxx_sensor_control.c
-LOCAL_C_INCLUDES += external/tinyalsa/include \
-			$(call include-path-for, audio-route)
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := liblog \
-			libutils \
-			libcutils \
-			libtinyalsa \
-			libhidlbase \
-			libodsp \
-			android.hardware.soundtrigger@2.0
-LOCAL_MODULE_TAGS := optional
-LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := oslo_data_injection_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/oslo_data_injection_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := liblog \
-			libutils \
-			libcutils \
-			libosloutils
-LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := oslo_config_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/oslo_config_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := liblog \
-			libutils \
-			libcutils \
-			libosloutils
-LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := oslo_get_stats
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/oslo_get_stats.c
-LOCAL_HEADER_LIBRARIES := libhardware_headers
-LOCAL_SHARED_LIBRARIES := liblog \
-			libutils \
-			libcutils \
-			libosloutils
-LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := spi_reliability_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/spi_reliability_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := oslo_package_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := ./tests/oslo_package_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils \
-			libtinyalsa
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := tunneling_hal_test_sensor
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/tunnel_test_sensor.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE := odsp_api_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := tests/odsp_api_test.c
-LOCAL_C_INCLUDES += ./tests/
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog \
-			libcutils \
-			libodsp
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE := dump_debug_info
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/dump_debug_info.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE := crash_event_logger
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/crash_event_logger.c tests/crash_analyzer.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_PRELINK_MODULE := false
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE := setparamblk_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/setparamblk_test.c
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := libcutils \
-			libodsp
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := crash_trigger_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/crash_trigger_test.c
-LOCAL_VENDOR_MODULE := true
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../hal
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := liblog libodsp
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := plugin_status_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_SRC_FILES := tests/plugin_status_test.c
-LOCAL_VENDOR_MODULE := true
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := libcutils libodsp
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := get_pwr_stats
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_VENDOR_MODULE := true
-LOCAL_SRC_FILES := tests/get_pwr_stats.c
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/
-LOCAL_32_BIT_ONLY := true
-LOCAL_SHARED_LIBRARIES := libcutils liblog
-
-include $(BUILD_EXECUTABLE)
-endif