# 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("//base/location/location/config.gni")
import("//build/ohos.gni")

config("locator_agent_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "$LOCATION_ROOT_DIR/interfaces/inner_api/native/include",
    "$LOCATION_ROOT_DIR/interfaces/inner_api/include",
    "$LOCATION_ROOT_DIR/frameworks/native/locator_agent/include",
    "$LOCATION_ROOT_DIR/frameworks/base_module/include",
  ]
}

ohos_shared_library("locator_agent") {
  public_configs = [
    ":locator_agent_config",
    "$LOCATION_NATIVE_DIR/locator_sdk:locator_interface_config",
  ]

  sources = [
    "$LOCATION_ROOT_DIR/frameworks/native/locator_agent/source/locator_agent.cpp",
    "$LOCATION_ROOT_DIR/frameworks/native/locator_agent/source/native_location_callback_host.cpp",
    "$LOCATION_ROOT_DIR/frameworks/native/locator_agent/source/native_nmea_callback_host.cpp",
    "$LOCATION_ROOT_DIR/frameworks/native/locator_agent/source/native_sv_callback_host.cpp",
  ]

  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  branch_protector_ret = "pac_ret"

  deps = [
    "$LOCATION_COMMON_DIR:lbsservice_common",
    "$LOCATION_NATIVE_DIR/locator_sdk:liblocator_interface_proxy",
    "$LOCATION_ROOT_DIR/frameworks/base_module:lbsbase_module",
  ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
  ]

  cflags_cc = [
    "-ffunction-sections",
    "-fdata-sections",
  ]

  defines = []
  if (is_emulator) {
    defines += [ "EMULATOR_ENABLED" ]
  }

  innerapi_tags = [ "platformsdk" ]
  part_name = "location"
  subsystem_name = "location"
}