2 # Copyright (C) 2015 Google
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:
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 LOCAL_PATH:= $(call my-dir)
20 # Workaround for libchrome and -DNDEBUG usage.
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 # ========================================================
28 ifneq (,$(findstring NDEBUG,$(HOST_GLOBAL_CFLAGS)))
29 btservice_orig_HOST_NDEBUG := -DBT_LIBCHROME_NDEBUG
31 btservice_orig_HOST_NDEBUG :=
33 ifneq (,$(findstring NDEBUG,$(TARGET_GLOBAL_CFLAGS)))
34 btservice_orig_TARGET_NDEBUG := -DBT_LIBCHROME_NDEBUG
36 btservice_orig_TARGET_NDEBUG :=
40 # ========================================================
41 btserviceCommonSrc := \
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
53 btserviceCommonBinderSrc := \
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
64 btserviceDaemonSrc := \
70 hal/gatt_helpers.cpp \
71 hal/bluetooth_gatt_interface.cpp \
72 hal/bluetooth_interface.cpp \
76 low_energy_client.cpp \
79 btserviceLinuxSrc := \
80 ipc/ipc_handler_linux.cpp \
81 ipc/linux_ipc_host.cpp
83 btserviceBinderDaemonImplSrc := \
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 \
91 btserviceBinderDaemonSrc := \
92 $(btserviceCommonBinderSrc) \
93 $(btserviceBinderDaemonImplSrc)
95 btserviceCommonIncludes := \
99 # Main unit test sources. These get built for host and target.
100 # ========================================================
101 btserviceBaseTestSrc := \
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
115 # Native system service for target
116 # ========================================================
117 include $(CLEAR_VARS)
119 $(btserviceBinderDaemonSrc) \
120 $(btserviceCommonSrc) \
121 $(btserviceLinuxSrc) \
122 $(btserviceDaemonSrc) \
124 LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
125 LOCAL_MODULE_TAGS := optional
126 LOCAL_MODULE := bluetoothtbd
127 LOCAL_REQUIRED_MODULES = bluetooth.default
128 LOCAL_STATIC_LIBRARIES += libbtcore
129 LOCAL_SHARED_LIBRARIES += \
136 LOCAL_INIT_RC := bluetoothtbd.rc
138 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
139 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
140 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
142 include $(BUILD_EXECUTABLE)
144 # Native system service unit tests for host
145 # ========================================================
146 include $(CLEAR_VARS)
148 $(btserviceBaseTestSrc) \
149 $(btserviceCommonSrc) \
150 $(btserviceDaemonSrc) \
152 test/stub_ipc_handler_binder.cpp
153 ifeq ($(HOST_OS),linux)
155 $(btserviceLinuxSrc) \
156 test/ipc_linux_unittest.cpp
160 test/stub_ipc_handler_linux.cpp
162 LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
163 LOCAL_MODULE_TAGS := debug tests
164 LOCAL_MODULE := bluetoothtbd-host_test
165 LOCAL_SHARED_LIBRARIES += libchrome
166 LOCAL_STATIC_LIBRARIES += libgmock_host libgtest_host liblog
168 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_HOST_NDEBUG)
169 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
170 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
172 include $(BUILD_HOST_NATIVE_TEST)
174 # Native system service unit tests for target.
175 # This includes Binder related tests that can only be run
177 # ========================================================
178 include $(CLEAR_VARS)
180 $(btserviceBaseTestSrc) \
181 $(btserviceBinderDaemonSrc) \
182 $(btserviceCommonSrc) \
183 $(btserviceDaemonSrc) \
185 test/parcel_helpers_unittest.cpp
186 LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
187 LOCAL_MODULE_TAGS := debug tests
188 LOCAL_MODULE := bluetoothtbd_test
189 LOCAL_SHARED_LIBRARIES += \
193 LOCAL_STATIC_LIBRARIES += libgmock libgtest liblog
195 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
196 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
197 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
199 include $(BUILD_NATIVE_TEST)
201 # Client library for interacting with Bluetooth daemon
202 # This is a static library for target.
203 # ========================================================
204 include $(CLEAR_VARS)
206 $(btserviceCommonSrc) \
207 $(btserviceCommonBinderSrc)
208 LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
209 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/common
210 LOCAL_MODULE := libbluetooth-client
211 LOCAL_SHARED_LIBRARIES += libbinder libchrome libutils
213 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
214 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
215 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
217 include $(BUILD_STATIC_LIBRARY)
219 # Native system service CLI for target
220 # ========================================================
221 include $(CLEAR_VARS)
222 LOCAL_SRC_FILES := client/main.cpp
223 LOCAL_MODULE_TAGS := optional
224 LOCAL_MODULE := bluetooth-cli
225 LOCAL_STATIC_LIBRARIES += libbluetooth-client
226 LOCAL_SHARED_LIBRARIES += \
231 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
232 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
233 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
235 include $(BUILD_EXECUTABLE)
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.
241 include $(CLEAR_VARS)
243 example/heart_rate/heart_rate_server.cpp \
244 example/heart_rate/server_main.cpp
245 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../
246 LOCAL_MODULE_TAGS := optional
247 LOCAL_MODULE := bt-example-hr-server
248 LOCAL_STATIC_LIBRARIES += libbluetooth-client
249 LOCAL_SHARED_LIBRARIES += \
254 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
255 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
256 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
258 include $(BUILD_EXECUTABLE)