# Copyright (C) 2021-2023 Huawei Device Co., Ltd. # 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. import("//build/ohos.gni") import("//build/ohos_var.gni") import("//foundation/communication/bluetooth/bluetooth.gni") SUBSYSTEM_DIR = "//foundation/communication" JS_NAPI_DIR = "$SUBSYSTEM_DIR/bluetooth/frameworks/js/napi" FwkCAdapterSrc = [ "c_adapter/ohos_bt_adapter_utils.cpp", "c_adapter/ohos_bt_gap.cpp", "c_adapter/ohos_bt_gatt.cpp", "c_adapter/ohos_bt_gatt_utils.cpp", "c_adapter/ohos_bt_gatt_client.cpp", "c_adapter/ohos_bt_gatt_server.cpp", "c_adapter/ohos_bt_spp.cpp", "c_adapter/ohos_bt_socket.cpp", ] FwkSrc = [ "src/bluetooth_a2dp_snk.cpp", "src/bluetooth_a2dp_src.cpp", "src/bluetooth_avrcp_ct.cpp", "src/bluetooth_avrcp_tg.cpp", "src/bluetooth_ble_advertiser.cpp", "src/bluetooth_ble_central_manager.cpp", "src/bluetooth_device_class.cpp", "src/bluetooth_gatt_characteristic.cpp", "src/bluetooth_gatt_client.cpp", "src/bluetooth_gatt_descriptor.cpp", "src/bluetooth_gatt_manager.cpp", "src/bluetooth_gatt_server.cpp", "src/bluetooth_gatt_service.cpp", "src/bluetooth_hfp_ag.cpp", "src/bluetooth_hfp_hf.cpp", "src/bluetooth_hid_host.cpp", "src/bluetooth_host.cpp", "src/bluetooth_map_mse.cpp", "src/bluetooth_opp.cpp", "src/bluetooth_pan.cpp", "src/bluetooth_profile_manager.cpp", "src/bluetooth_pbap_pse.cpp", "src/bluetooth_proxy_manager.cpp", "src/bluetooth_remote_device.cpp", "src/bluetooth_socket.cpp", "src/bluetooth_socket_inputstream.cpp", "src/bluetooth_socket_outputstream.cpp", "src/bluetooth_timer.cpp", "src/bluetooth_utils.cpp", "src/bluetooth_host_load_callback.cpp", "src/bluetooth_audio_manager.cpp", "src/uuid.cpp", "src/bluetooth_switch_module.cpp", "$JS_NAPI_DIR/src/common/napi_async_callback.cpp", "$JS_NAPI_DIR/src/common/napi_async_work.cpp", "$JS_NAPI_DIR/src/common/napi_bluetooth_error.cpp", "$JS_NAPI_DIR/src/common/napi_bluetooth_event.cpp", "$JS_NAPI_DIR/src/common/napi_bluetooth_utils.cpp", "$JS_NAPI_DIR/src/common/napi_event_subscribe_module.cpp", "$JS_NAPI_DIR/src/common/napi_native_object.cpp", "$JS_NAPI_DIR/src/common/napi_timer.cpp", "$JS_NAPI_DIR/src/parser/napi_parser_utils.cpp", ] BT_IPCSRC_DIR = "ipc/src" FwkIpcSrc = [ "$BT_IPCSRC_DIR/bluetooth_a2dp_sink_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_a2dp_sink_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_a2dp_src_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_a2dp_src_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_avrcp_ct_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_avrcp_ct_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_avrcp_tg_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_avrcp_tg_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_ble_advertise_callback_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_ble_advertiser_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_ble_central_manager_callback_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_ble_central_manager_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_ble_peripheral_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_gatt_client_callback_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_gatt_client_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_gatt_server_callback_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_gatt_server_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_hfp_ag_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_hfp_ag_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_hfp_hf_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_hfp_hf_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_hid_host_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_hid_host_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_opp_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_opp_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_host_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_host_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_map_mse_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_map_mse_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_pan_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_pan_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_pbap_pse_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_pbap_pse_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_remote_device_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_socket_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_socket_observer_stub.cpp", "$BT_IPCSRC_DIR/bluetooth_audio_manager_proxy.cpp", "$BT_IPCSRC_DIR/bluetooth_resource_manager_observer_stub.cpp", ] config("btframework_config") { cflags_cc = [ "-fPIC", "-Wno-unused-parameter", "-Wno-return-type-c-linkage", "-Wunused-private-field", ] include_dirs = [ "include", "ipc/include", "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include/c_header", "$JS_NAPI_DIR/include", ] defines = [] if (is_asan) { defines += [ "DTFUZZ_TEST" ] } if (bluetooth_service_resourceschedule) { defines += [ "RES_SCHED_SUPPORT" ] } } config("btframework_public_config") { visibility = [ "*" ] include_dirs = [ "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include", "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include/c_header", ] } ohos_shared_library("btframework") { branch_protector_ret = "pac_ret" # Enable PAC CFI configs = [ ":btframework_config" ] public_configs = [ ":btframework_public_config" ] innerapi_tags = [ "platformsdk" ] sources = FwkSrc sources += FwkCAdapterSrc sources += FwkIpcSrc deps = [ ":btcommon" ] external_deps = [ "ability_base:want", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", "ipc:ipc_core", "libuv:uv", "napi:ace_napi", "samgr:samgr_proxy", ] if (bluetooth_service_resourceschedule) { external_deps += [ "resource_schedule_service:ressched_client" ] } sanitize = { cfi = true # Enable/disable control flow integrity detection boundary_sanitize = true # Enable boundary san detection cfi_cross_dso = true # Cross-SO CFI Checks integer_overflow = true # Enable integer overflow detection ubsan = true # Enable some Ubsan options debug = false } subsystem_name = "communication" part_name = "bluetooth" } config("btcommon_config") { include_dirs = [ "include" ] } config("btcommon_public_config") { include_dirs = [ "ipc/common", "ipc/interface", "ipc/parcel", ] } ohos_shared_library("btcommon") { branch_protector_ret = "pac_ret" # Enable PAC CFI configs = [ ":btcommon_config" ] public_configs = [ ":btcommon_public_config" ] innerapi_tags = [ "chipsetsdk" ] sanitize = { cfi = true # Enable/disable control flow integrity detection boundary_sanitize = true # Enable boundary san detection cfi_cross_dso = true # Cross-SO CFI Checks integer_overflow = true # Enable integer overflow detection ubsan = true # Enable some Ubsan options debug = false } sources = [ "ipc/common/avrcp_media.cpp", "ipc/common/ble_parcel_data.cpp", "ipc/common/ble_service_data.cpp", "ipc/common/bt_uuid.cpp", "ipc/common/gatt_data.cpp", "ipc/common/hands_free_unit_calls.cpp", "ipc/common/opp_transfer_information.cpp", "ipc/common/raw_address.cpp", "ipc/parcel/bluetooth_a2dp_a2dpCodecInfo.cpp", "ipc/parcel/bluetooth_a2dp_a2dpCodecStatus.cpp", "ipc/parcel/bluetooth_avrcp_meItem.cpp", "ipc/parcel/bluetooth_avrcp_mpItem.cpp", "ipc/parcel/bluetooth_ble_advertiser_data.cpp", "ipc/parcel/bluetooth_ble_advertiser_settings.cpp", "ipc/parcel/bluetooth_ble_scan_filter.cpp", "ipc/parcel/bluetooth_ble_scan_result.cpp", "ipc/parcel/bluetooth_ble_scan_settings.cpp", "ipc/parcel/bluetooth_bt_uuid.cpp", "ipc/parcel/bluetooth_device_battery_info.cpp", "ipc/parcel/bluetooth_gatt_characteristic_parcel.cpp", "ipc/parcel/bluetooth_gatt_descriptor_parcel.cpp", "ipc/parcel/bluetooth_gatt_device.cpp", "ipc/parcel/bluetooth_gatt_service_parcel.cpp", "ipc/parcel/bluetooth_hfp_hf_call.cpp", "ipc/parcel/bluetooth_opp_transfer_information.cpp", "ipc/parcel/bluetooth_phone_state.cpp", "ipc/parcel/bluetooth_raw_address.cpp", "ipc/parcel/bluetooth_remote_device_info.cpp", "ipc/parcel/bluetooth_sensing_info.cpp", "ipc/parcel/bluetooth_socket_coc.cpp", "ipc/parcel/parcel_bt_uuid.cpp", ] deps = [] external_deps = [ "c_utils:utils", "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", ] subsystem_name = "communication" part_name = "bluetooth" }