Home | History | Annotate | Download | only in service
      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 
     17 LOCAL_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 # ========================================================
     28 ifneq (,$(findstring NDEBUG,$(HOST_GLOBAL_CFLAGS)))
     29   btservice_orig_HOST_NDEBUG := -DBT_LIBCHROME_NDEBUG
     30 else
     31   btservice_orig_HOST_NDEBUG :=
     32 endif
     33 ifneq (,$(findstring NDEBUG,$(TARGET_GLOBAL_CFLAGS)))
     34   btservice_orig_TARGET_NDEBUG := -DBT_LIBCHROME_NDEBUG
     35 else
     36   btservice_orig_TARGET_NDEBUG :=
     37 endif
     38 
     39 # Source variables
     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
     52 
     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
     63 
     64 btserviceDaemonSrc := \
     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 
     79 btserviceLinuxSrc := \
     80 	ipc/ipc_handler_linux.cpp \
     81 	ipc/linux_ipc_host.cpp
     82 
     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 \
     90 
     91 btserviceBinderDaemonSrc := \
     92 	$(btserviceCommonBinderSrc) \
     93 	$(btserviceBinderDaemonImplSrc)
     94 
     95 btserviceCommonIncludes := \
     96 	$(LOCAL_PATH)/../ \
     97 	$(LOCAL_PATH)/common
     98 
     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
    114 
    115 # Native system service for target
    116 # ========================================================
    117 include $(CLEAR_VARS)
    118 LOCAL_SRC_FILES := \
    119 	$(btserviceBinderDaemonSrc) \
    120 	$(btserviceCommonSrc) \
    121 	$(btserviceLinuxSrc) \
    122 	$(btserviceDaemonSrc) \
    123 	main.cpp
    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 += \
    130 	libbinder \
    131 	libchrome \
    132 	libcutils \
    133 	libhardware \
    134 	liblog \
    135 	libutils
    136 LOCAL_INIT_RC := bluetoothtbd.rc
    137 
    138 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
    139 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    140 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    141 
    142 include $(BUILD_EXECUTABLE)
    143 
    144 # Native system service unit tests for host
    145 # ========================================================
    146 include $(CLEAR_VARS)
    147 LOCAL_SRC_FILES := \
    148 	$(btserviceBaseTestSrc) \
    149 	$(btserviceCommonSrc) \
    150 	$(btserviceDaemonSrc) \
    151 	test/main.cpp \
    152 	test/stub_ipc_handler_binder.cpp
    153 ifeq ($(HOST_OS),linux)
    154 LOCAL_SRC_FILES += \
    155 	$(btserviceLinuxSrc) \
    156 	test/ipc_linux_unittest.cpp
    157 LOCAL_LDLIBS += -lrt
    158 else
    159 LOCAL_SRC_FILES += \
    160 	test/stub_ipc_handler_linux.cpp
    161 endif
    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
    167 
    168 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_HOST_NDEBUG)
    169 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    170 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    171 
    172 include $(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 # ========================================================
    178 include $(CLEAR_VARS)
    179 LOCAL_SRC_FILES := \
    180 	$(btserviceBaseTestSrc) \
    181 	$(btserviceBinderDaemonSrc) \
    182 	$(btserviceCommonSrc) \
    183 	$(btserviceDaemonSrc) \
    184 	test/main.cpp \
    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 += \
    190 	libbinder \
    191 	libchrome \
    192 	libutils
    193 LOCAL_STATIC_LIBRARIES += libgmock libgtest liblog
    194 
    195 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
    196 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    197 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    198 
    199 include $(BUILD_NATIVE_TEST)
    200 
    201 # Client library for interacting with Bluetooth daemon
    202 # This is a static library for target.
    203 # ========================================================
    204 include $(CLEAR_VARS)
    205 LOCAL_SRC_FILES := \
    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
    212 
    213 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
    214 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    215 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    216 
    217 include $(BUILD_STATIC_LIBRARY)
    218 
    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 += \
    227 	libbinder \
    228 	libchrome \
    229 	libutils
    230 
    231 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
    232 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    233 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    234 
    235 include $(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.
    241 include $(CLEAR_VARS)
    242 LOCAL_SRC_FILES := \
    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 += \
    250 	libbinder \
    251 	libchrome \
    252 	libutils
    253 
    254 LOCAL_CFLAGS += $(bluetooth_CFLAGS) $(btservice_orig_TARGET_NDEBUG)
    255 LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
    256 LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
    257 
    258 include $(BUILD_EXECUTABLE)
    259