# Copyright (C) 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")

BT_PART_DIR = "../../../../.."
BT_NAPI_DIR = "$BT_PART_DIR/frameworks/js/napi"

ohos_shared_library("map") {
  branch_protector_ret = "pac_ret"  # Enable PAC CFI

  include_dirs = [
    "$BT_NAPI_DIR/include",
    "$BT_PART_DIR/frameworks/inner/include",
  ]

  defines = [
    "BT_LOG_TAG = \"bluetooth_napi\"",
    "BT_LOG_DOMAIN = 0xD000100",
    "ENABLE_NAPI_BLUETOOTH_MANAGER",
    "BLUETOOTH_API_SINCE_10",
    "BT_MODULE_NAME = \"bluetooth.map\"",
  ]

  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 = [
    "napi_bluetooth_map_mse.cpp",
    "napi_bluetooth_map_mse_observer.cpp",
    "native_module_map.cpp",
  ]

  deps = [ "$BT_PART_DIR/frameworks/inner:btframework" ]

  external_deps = [
    "ability_base:want",
    "ability_runtime:ability_manager",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "ipc:ipc_single",
    "libuv:uv",
    "napi:ace_napi",
  ]

  relative_install_dir = "module/bluetooth"
  part_name = "bluetooth"
  subsystem_name = "communication"
}