1# Copyright (C) 2021-2023 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//build/ohos_var.gni") 16import("//foundation/communication/bluetooth/bluetooth.gni") 17 18SUBSYSTEM_DIR = "//foundation/communication" 19JS_NAPI_DIR = "$SUBSYSTEM_DIR/bluetooth/frameworks/js/napi" 20 21FwkCAdapterSrc = [ 22 "c_adapter/ohos_bt_adapter_utils.cpp", 23 "c_adapter/ohos_bt_gap.cpp", 24 "c_adapter/ohos_bt_gatt.cpp", 25 "c_adapter/ohos_bt_gatt_utils.cpp", 26 "c_adapter/ohos_bt_gatt_client.cpp", 27 "c_adapter/ohos_bt_gatt_server.cpp", 28 "c_adapter/ohos_bt_spp.cpp", 29 "c_adapter/ohos_bt_socket.cpp", 30] 31 32FwkSrc = [ 33 "src/bluetooth_a2dp_snk.cpp", 34 "src/bluetooth_a2dp_src.cpp", 35 "src/bluetooth_avrcp_ct.cpp", 36 "src/bluetooth_avrcp_tg.cpp", 37 "src/bluetooth_ble_advertiser.cpp", 38 "src/bluetooth_ble_central_manager.cpp", 39 "src/bluetooth_device_class.cpp", 40 "src/bluetooth_gatt_characteristic.cpp", 41 "src/bluetooth_gatt_client.cpp", 42 "src/bluetooth_gatt_descriptor.cpp", 43 "src/bluetooth_gatt_manager.cpp", 44 "src/bluetooth_gatt_server.cpp", 45 "src/bluetooth_gatt_service.cpp", 46 "src/bluetooth_hfp_ag.cpp", 47 "src/bluetooth_hfp_hf.cpp", 48 "src/bluetooth_hid_host.cpp", 49 "src/bluetooth_host.cpp", 50 "src/bluetooth_map_mse.cpp", 51 "src/bluetooth_opp.cpp", 52 "src/bluetooth_pan.cpp", 53 "src/bluetooth_profile_manager.cpp", 54 "src/bluetooth_pbap_pse.cpp", 55 "src/bluetooth_proxy_manager.cpp", 56 "src/bluetooth_remote_device.cpp", 57 "src/bluetooth_socket.cpp", 58 "src/bluetooth_socket_inputstream.cpp", 59 "src/bluetooth_socket_outputstream.cpp", 60 "src/bluetooth_timer.cpp", 61 "src/bluetooth_utils.cpp", 62 "src/bluetooth_host_load_callback.cpp", 63 "src/bluetooth_audio_manager.cpp", 64 "src/uuid.cpp", 65 "src/bluetooth_switch_module.cpp", 66 "$JS_NAPI_DIR/src/common/napi_async_callback.cpp", 67 "$JS_NAPI_DIR/src/common/napi_async_work.cpp", 68 "$JS_NAPI_DIR/src/common/napi_bluetooth_error.cpp", 69 "$JS_NAPI_DIR/src/common/napi_bluetooth_event.cpp", 70 "$JS_NAPI_DIR/src/common/napi_bluetooth_utils.cpp", 71 "$JS_NAPI_DIR/src/common/napi_event_subscribe_module.cpp", 72 "$JS_NAPI_DIR/src/common/napi_native_object.cpp", 73 "$JS_NAPI_DIR/src/common/napi_timer.cpp", 74 "$JS_NAPI_DIR/src/parser/napi_parser_utils.cpp", 75] 76 77BT_IPCSRC_DIR = "ipc/src" 78FwkIpcSrc = [ 79 "$BT_IPCSRC_DIR/bluetooth_a2dp_sink_observer_stub.cpp", 80 "$BT_IPCSRC_DIR/bluetooth_a2dp_sink_proxy.cpp", 81 "$BT_IPCSRC_DIR/bluetooth_a2dp_src_observer_stub.cpp", 82 "$BT_IPCSRC_DIR/bluetooth_a2dp_src_proxy.cpp", 83 "$BT_IPCSRC_DIR/bluetooth_avrcp_ct_observer_stub.cpp", 84 "$BT_IPCSRC_DIR/bluetooth_avrcp_ct_proxy.cpp", 85 "$BT_IPCSRC_DIR/bluetooth_avrcp_tg_observer_stub.cpp", 86 "$BT_IPCSRC_DIR/bluetooth_avrcp_tg_proxy.cpp", 87 "$BT_IPCSRC_DIR/bluetooth_ble_advertise_callback_stub.cpp", 88 "$BT_IPCSRC_DIR/bluetooth_ble_advertiser_proxy.cpp", 89 "$BT_IPCSRC_DIR/bluetooth_ble_central_manager_callback_stub.cpp", 90 "$BT_IPCSRC_DIR/bluetooth_ble_central_manager_proxy.cpp", 91 "$BT_IPCSRC_DIR/bluetooth_ble_peripheral_observer_stub.cpp", 92 "$BT_IPCSRC_DIR/bluetooth_gatt_client_callback_stub.cpp", 93 "$BT_IPCSRC_DIR/bluetooth_gatt_client_proxy.cpp", 94 "$BT_IPCSRC_DIR/bluetooth_gatt_server_callback_stub.cpp", 95 "$BT_IPCSRC_DIR/bluetooth_gatt_server_proxy.cpp", 96 "$BT_IPCSRC_DIR/bluetooth_hfp_ag_observer_stub.cpp", 97 "$BT_IPCSRC_DIR/bluetooth_hfp_ag_proxy.cpp", 98 "$BT_IPCSRC_DIR/bluetooth_hfp_hf_observer_stub.cpp", 99 "$BT_IPCSRC_DIR/bluetooth_hfp_hf_proxy.cpp", 100 "$BT_IPCSRC_DIR/bluetooth_hid_host_observer_stub.cpp", 101 "$BT_IPCSRC_DIR/bluetooth_hid_host_proxy.cpp", 102 "$BT_IPCSRC_DIR/bluetooth_opp_observer_stub.cpp", 103 "$BT_IPCSRC_DIR/bluetooth_opp_proxy.cpp", 104 "$BT_IPCSRC_DIR/bluetooth_host_observer_stub.cpp", 105 "$BT_IPCSRC_DIR/bluetooth_host_proxy.cpp", 106 "$BT_IPCSRC_DIR/bluetooth_map_mse_observer_stub.cpp", 107 "$BT_IPCSRC_DIR/bluetooth_map_mse_proxy.cpp", 108 "$BT_IPCSRC_DIR/bluetooth_pan_observer_stub.cpp", 109 "$BT_IPCSRC_DIR/bluetooth_pan_proxy.cpp", 110 "$BT_IPCSRC_DIR/bluetooth_pbap_pse_observer_stub.cpp", 111 "$BT_IPCSRC_DIR/bluetooth_pbap_pse_proxy.cpp", 112 "$BT_IPCSRC_DIR/bluetooth_remote_device_observer_stub.cpp", 113 "$BT_IPCSRC_DIR/bluetooth_socket_proxy.cpp", 114 "$BT_IPCSRC_DIR/bluetooth_socket_observer_stub.cpp", 115 "$BT_IPCSRC_DIR/bluetooth_audio_manager_proxy.cpp", 116 "$BT_IPCSRC_DIR/bluetooth_resource_manager_observer_stub.cpp", 117] 118 119config("btframework_config") { 120 cflags_cc = [ 121 "-fPIC", 122 "-Wno-unused-parameter", 123 "-Wno-return-type-c-linkage", 124 "-Wunused-private-field", 125 ] 126 include_dirs = [ 127 "include", 128 "ipc/include", 129 "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include/c_header", 130 "$JS_NAPI_DIR/include", 131 ] 132 133 defines = [] 134 if (is_asan) { 135 defines += [ "DTFUZZ_TEST" ] 136 } 137 if (bluetooth_service_resourceschedule) { 138 defines += [ "RES_SCHED_SUPPORT" ] 139 } 140} 141 142config("btframework_public_config") { 143 visibility = [ "*" ] 144 include_dirs = [ 145 "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include", 146 "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include/c_header", 147 ] 148} 149 150ohos_shared_library("btframework") { 151 branch_protector_ret = "pac_ret" # Enable PAC CFI 152 configs = [ ":btframework_config" ] 153 public_configs = [ ":btframework_public_config" ] 154 innerapi_tags = [ "platformsdk" ] 155 sources = FwkSrc 156 sources += FwkCAdapterSrc 157 sources += FwkIpcSrc 158 159 deps = [ ":btcommon" ] 160 161 external_deps = [ 162 "ability_base:want", 163 "c_utils:utils", 164 "common_event_service:cesfwk_innerkits", 165 "eventhandler:libeventhandler", 166 "ffrt:libffrt", 167 "hilog:libhilog", 168 "hisysevent:libhisysevent", 169 "init:libbegetutil", 170 "ipc:ipc_core", 171 "libuv:uv", 172 "napi:ace_napi", 173 "samgr:samgr_proxy", 174 ] 175 176 if (bluetooth_service_resourceschedule) { 177 external_deps += [ "resource_schedule_service:ressched_client" ] 178 } 179 180 sanitize = { 181 cfi = true # Enable/disable control flow integrity detection 182 boundary_sanitize = true # Enable boundary san detection 183 cfi_cross_dso = true # Cross-SO CFI Checks 184 integer_overflow = true # Enable integer overflow detection 185 ubsan = true # Enable some Ubsan options 186 debug = false 187 } 188 subsystem_name = "communication" 189 part_name = "bluetooth" 190} 191 192config("btcommon_config") { 193 include_dirs = [ "include" ] 194} 195 196config("btcommon_public_config") { 197 include_dirs = [ 198 "ipc/common", 199 "ipc/interface", 200 "ipc/parcel", 201 ] 202} 203 204ohos_shared_library("btcommon") { 205 branch_protector_ret = "pac_ret" # Enable PAC CFI 206 configs = [ ":btcommon_config" ] 207 public_configs = [ ":btcommon_public_config" ] 208 innerapi_tags = [ "chipsetsdk" ] 209 sanitize = { 210 cfi = true # Enable/disable control flow integrity detection 211 boundary_sanitize = true # Enable boundary san detection 212 cfi_cross_dso = true # Cross-SO CFI Checks 213 integer_overflow = true # Enable integer overflow detection 214 ubsan = true # Enable some Ubsan options 215 debug = false 216 } 217 sources = [ 218 "ipc/common/avrcp_media.cpp", 219 "ipc/common/ble_parcel_data.cpp", 220 "ipc/common/ble_service_data.cpp", 221 "ipc/common/bt_uuid.cpp", 222 "ipc/common/gatt_data.cpp", 223 "ipc/common/hands_free_unit_calls.cpp", 224 "ipc/common/opp_transfer_information.cpp", 225 "ipc/common/raw_address.cpp", 226 "ipc/parcel/bluetooth_a2dp_a2dpCodecInfo.cpp", 227 "ipc/parcel/bluetooth_a2dp_a2dpCodecStatus.cpp", 228 "ipc/parcel/bluetooth_avrcp_meItem.cpp", 229 "ipc/parcel/bluetooth_avrcp_mpItem.cpp", 230 "ipc/parcel/bluetooth_ble_advertiser_data.cpp", 231 "ipc/parcel/bluetooth_ble_advertiser_settings.cpp", 232 "ipc/parcel/bluetooth_ble_scan_filter.cpp", 233 "ipc/parcel/bluetooth_ble_scan_result.cpp", 234 "ipc/parcel/bluetooth_ble_scan_settings.cpp", 235 "ipc/parcel/bluetooth_bt_uuid.cpp", 236 "ipc/parcel/bluetooth_device_battery_info.cpp", 237 "ipc/parcel/bluetooth_gatt_characteristic_parcel.cpp", 238 "ipc/parcel/bluetooth_gatt_descriptor_parcel.cpp", 239 "ipc/parcel/bluetooth_gatt_device.cpp", 240 "ipc/parcel/bluetooth_gatt_service_parcel.cpp", 241 "ipc/parcel/bluetooth_hfp_hf_call.cpp", 242 "ipc/parcel/bluetooth_opp_transfer_information.cpp", 243 "ipc/parcel/bluetooth_phone_state.cpp", 244 "ipc/parcel/bluetooth_raw_address.cpp", 245 "ipc/parcel/bluetooth_remote_device_info.cpp", 246 "ipc/parcel/bluetooth_sensing_info.cpp", 247 "ipc/parcel/bluetooth_socket_coc.cpp", 248 "ipc/parcel/parcel_bt_uuid.cpp", 249 ] 250 251 deps = [] 252 253 external_deps = [ 254 "c_utils:utils", 255 "hilog:libhilog", 256 "hisysevent:libhisysevent", 257 "ipc:ipc_core", 258 ] 259 260 subsystem_name = "communication" 261 part_name = "bluetooth" 262} 263