1# 2# Copyright (C) 2015 Google 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at: 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17LOCAL_PATH:= $(call my-dir) 18 19# 20# Workaround for libchrome and -DNDEBUG usage. 21# 22# Test whether the original HOST_GLOBAL_CFLAGS and 23# TARGET_GLOBAL_CFLAGS contain -DNDEBUG . 24# This is needed as a workaround to make sure that 25# libchrome and local files calling logging::InitLogging() 26# are consistent with the usage of -DNDEBUG . 27# ======================================================== 28ifneq (,$(findstring NDEBUG,$(HOST_GLOBAL_CFLAGS))) 29 btservice_orig_HOST_NDEBUG := -DBT_LIBCHROME_NDEBUG 30else 31 btservice_orig_HOST_NDEBUG := 32endif 33ifneq (,$(findstring NDEBUG,$(TARGET_GLOBAL_CFLAGS))) 34 btservice_orig_TARGET_NDEBUG := -DBT_LIBCHROME_NDEBUG 35else 36 btservice_orig_TARGET_NDEBUG := 37endif 38 39# Source variables 40# ======================================================== 41btserviceCommonSrc := \ 42 common/bluetooth/adapter_state.cpp \ 43 common/bluetooth/advertise_data.cpp \ 44 common/bluetooth/advertise_settings.cpp \ 45 common/bluetooth/gatt_identifier.cpp \ 46 common/bluetooth/scan_filter.cpp \ 47 common/bluetooth/scan_result.cpp \ 48 common/bluetooth/scan_settings.cpp \ 49 common/bluetooth/util/address_helper.cpp \ 50 common/bluetooth/util/atomic_string.cpp \ 51 common/bluetooth/uuid.cpp 52 53btserviceCommonBinderSrc := \ 54 common/bluetooth/binder/IBluetooth.cpp \ 55 common/bluetooth/binder/IBluetoothCallback.cpp \ 56 common/bluetooth/binder/IBluetoothGattClient.cpp \ 57 common/bluetooth/binder/IBluetoothGattClientCallback.cpp \ 58 common/bluetooth/binder/IBluetoothGattServer.cpp \ 59 common/bluetooth/binder/IBluetoothGattServerCallback.cpp \ 60 common/bluetooth/binder/IBluetoothLowEnergy.cpp \ 61 common/bluetooth/binder/IBluetoothLowEnergyCallback.cpp \ 62 common/bluetooth/binder/parcel_helpers.cpp 63 64btserviceDaemonSrc := \ 65 adapter.cpp \ 66 daemon.cpp \ 67 gatt_client.cpp \ 68 gatt_server.cpp \ 69 gatt_server_old.cpp \ 70 hal/gatt_helpers.cpp \ 71 hal/bluetooth_gatt_interface.cpp \ 72 hal/bluetooth_interface.cpp \ 73 ipc/ipc_handler.cpp \ 74 ipc/ipc_manager.cpp \ 75 logging_helpers.cpp \ 76 low_energy_client.cpp \ 77 settings.cpp 78 79btserviceLinuxSrc := \ 80 ipc/ipc_handler_linux.cpp \ 81 ipc/linux_ipc_host.cpp 82 83btserviceBinderDaemonImplSrc := \ 84 ipc/binder/bluetooth_binder_server.cpp \ 85 ipc/binder/bluetooth_gatt_client_binder_server.cpp \ 86 ipc/binder/bluetooth_gatt_server_binder_server.cpp \ 87 ipc/binder/bluetooth_low_energy_binder_server.cpp \ 88 ipc/binder/interface_with_instances_base.cpp \ 89 ipc/binder/ipc_handler_binder.cpp \ 90 91btserviceBinderDaemonSrc := \ 92 $(btserviceCommonBinderSrc) \ 93 $(btserviceBinderDaemonImplSrc) 94 95btserviceCommonIncludes := \ 96 $(LOCAL_PATH)/../ \ 97 $(LOCAL_PATH)/common 98 99# Main unit test sources. These get built for host and target. 100# ======================================================== 101btserviceBaseTestSrc := \ 102 hal/fake_bluetooth_gatt_interface.cpp \ 103 hal/fake_bluetooth_interface.cpp \ 104 test/adapter_unittest.cpp \ 105 test/advertise_data_unittest.cpp \ 106 test/fake_hal_util.cpp \ 107 test/gatt_client_unittest.cpp \ 108 test/gatt_identifier_unittest.cpp \ 109 test/gatt_server_unittest.cpp \ 110 test/low_energy_client_unittest.cpp \ 111 test/settings_unittest.cpp \ 112 test/util_unittest.cpp \ 113 test/uuid_unittest.cpp 114 115# Native system service for target 116# ======================================================== 117include $(CLEAR_VARS) 118LOCAL_SRC_FILES := \ 119 $(btserviceBinderDaemonSrc) \ 120 $(btserviceCommonSrc) \ 121 $(btserviceLinuxSrc) \ 122 $(btserviceDaemonSrc) \ 123 main.cpp 124LOCAL_C_INCLUDES += $(btserviceCommonIncludes) 125LOCAL_MODULE_TAGS := optional 126LOCAL_MODULE := bluetoothtbd 127LOCAL_REQUIRED_MODULES = bluetooth.default 128LOCAL_STATIC_LIBRARIES += libbtcore 129LOCAL_SHARED_LIBRARIES += \ 130 libbinder \ 131 libchrome \ 132 libcutils \ 133 libhardware \ 134 liblog \ 135 libutils 136LOCAL_INIT_RC := bluetoothtbd.rc 137 138LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG) 139LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 140LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 141 142include $(BUILD_EXECUTABLE) 143 144# Native system service unit tests for host 145# ======================================================== 146include $(CLEAR_VARS) 147LOCAL_SRC_FILES := \ 148 $(btserviceBaseTestSrc) \ 149 $(btserviceCommonSrc) \ 150 $(btserviceDaemonSrc) \ 151 test/main.cpp \ 152 test/stub_ipc_handler_binder.cpp 153ifeq ($(HOST_OS),linux) 154LOCAL_SRC_FILES += \ 155 $(btserviceLinuxSrc) \ 156 test/ipc_linux_unittest.cpp 157LOCAL_LDLIBS += -lrt 158else 159LOCAL_SRC_FILES += \ 160 test/stub_ipc_handler_linux.cpp 161endif 162LOCAL_C_INCLUDES += $(btserviceCommonIncludes) 163LOCAL_MODULE_TAGS := debug tests 164LOCAL_MODULE := bluetoothtbd-host_test 165LOCAL_SHARED_LIBRARIES += libchrome 166LOCAL_STATIC_LIBRARIES += libgmock_host libgtest_host liblog 167 168LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_HOST_NDEBUG) 169LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 170LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 171 172include $(BUILD_HOST_NATIVE_TEST) 173 174# Native system service unit tests for target. 175# This includes Binder related tests that can only be run 176# on target. 177# ======================================================== 178include $(CLEAR_VARS) 179LOCAL_SRC_FILES := \ 180 $(btserviceBaseTestSrc) \ 181 $(btserviceBinderDaemonSrc) \ 182 $(btserviceCommonSrc) \ 183 $(btserviceDaemonSrc) \ 184 test/main.cpp \ 185 test/parcel_helpers_unittest.cpp 186LOCAL_C_INCLUDES += $(btserviceCommonIncludes) 187LOCAL_MODULE_TAGS := debug tests 188LOCAL_MODULE := bluetoothtbd_test 189LOCAL_SHARED_LIBRARIES += \ 190 libbinder \ 191 libchrome \ 192 libutils 193LOCAL_STATIC_LIBRARIES += libgmock libgtest liblog 194 195LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG) 196LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 197LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 198 199include $(BUILD_NATIVE_TEST) 200 201# Client library for interacting with Bluetooth daemon 202# This is a static library for target. 203# ======================================================== 204include $(CLEAR_VARS) 205LOCAL_SRC_FILES := \ 206 $(btserviceCommonSrc) \ 207 $(btserviceCommonBinderSrc) 208LOCAL_C_INCLUDES += $(btserviceCommonIncludes) 209LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/common 210LOCAL_MODULE := libbluetooth-client 211LOCAL_SHARED_LIBRARIES += libbinder libchrome libutils 212 213LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG) 214LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 215LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 216 217include $(BUILD_STATIC_LIBRARY) 218 219# Native system service CLI for target 220# ======================================================== 221include $(CLEAR_VARS) 222LOCAL_SRC_FILES := client/main.cpp 223LOCAL_MODULE_TAGS := optional 224LOCAL_MODULE := bluetooth-cli 225LOCAL_STATIC_LIBRARIES += libbluetooth-client 226LOCAL_SHARED_LIBRARIES += \ 227 libbinder \ 228 libchrome \ 229 libutils 230 231LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG) 232LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 233LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 234 235include $(BUILD_EXECUTABLE) 236 237# Heart Rate GATT service example for target 238# ======================================================== 239# TODO(armansito): Move this into a new makefile under examples/ once we build 240# a client static library that the examples can depend on. 241include $(CLEAR_VARS) 242LOCAL_SRC_FILES := \ 243 example/heart_rate/heart_rate_server.cpp \ 244 example/heart_rate/server_main.cpp 245LOCAL_C_INCLUDES += $(LOCAL_PATH)/../ 246LOCAL_MODULE_TAGS := optional 247LOCAL_MODULE := bt-example-hr-server 248LOCAL_STATIC_LIBRARIES += libbluetooth-client 249LOCAL_SHARED_LIBRARIES += \ 250 libbinder \ 251 libchrome \ 252 libutils 253 254LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG) 255LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS) 256LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS) 257 258include $(BUILD_EXECUTABLE) 259