# Copyright (c) 2022-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("../../../user_auth_framework.gni")

config("userauth_client_config") {
  include_dirs = [
    "inc",
    "../../../interfaces/inner_api",
  ]
}

ohos_shared_library("userauth_client") {
  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
    blocklist = "../../../cfi_blocklist.txt"
  }
  branch_protector_ret = "pac_ret"
  include_dirs = [
    "inc",
    "../../../interfaces/inner_api",
    "../../common/inc",
  ]

  sources = [
    "src/auth_message_impl.cpp",
    "src/callback_manager_impl.cpp",
    "src/co_auth_client_impl.cpp",
    "src/event_listener_callback_manager.cpp",
    "src/event_listener_callback_service.cpp",
    "src/executor_callback_service.cpp",
    "src/executor_messenger_client.cpp",
    "src/ipc_client_utils.cpp",
    "src/load_mode_client_util.cpp",
    "src/modal_callback_service.cpp",
    "src/remote_auth_callback_service.cpp",
    "src/set_widget_param_callback.cpp",
    "src/user_access_ctrl_callback_service.cpp",
    "src/user_access_ctrl_client_impl.cpp",
    "src/user_auth_callback_service.cpp",
    "src/user_auth_client_impl.cpp",
    "src/user_auth_modal_inner_callback.cpp",
    "src/user_auth_napi_client_impl.cpp",
    "src/user_idm_callback_service.cpp",
    "src/user_idm_client_impl.cpp",
    "src/widget_callback_service.cpp",
  ]

  defines = []

  if (user_auth_framework_enable_dynamic_load) {
    defines += [ "ENABLE_DYNAMIC_LOAD" ]
  }

  cflags = [ "-Oz" ]

  configs = [
    "../../../common:iam_log_config",
    "../../../common:iam_utils_config",
  ]

  remove_configs = [ "//build/config/compiler:no_exceptions" ]

  public_configs = [
    ":userauth_client_config",
    "../ipc:userauth_client_ipc_config",
  ]

  innerapi_tags = [ "platformsdk" ]

  deps = [
    "../common:attributes",
    "../common:dfx",
    "../ipc:userauth_client_ipc",
  ]

  if (use_musl) {
    version_script = "user_auth_client_map"
  }

  external_deps = [
    "access_token:libaccesstoken_sdk",
    "c_utils:utils",
    "hilog:libhilog",
    "init:libbeget_proxy",
    "init:libbegetutil",
    "ipc:ipc_single",
    "ipc:ipc_single",
    "napi:ace_napi",
    "node:node_header_notice",
    "libuv:uv",
    "samgr:samgr_proxy",
  ]

  subsystem_name = "useriam"
  part_name = "user_auth_framework"
}