# Copyright (c) 2026 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("//foundation/ability/ability_runtime/ability_runtime.gni")

config("clisa_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "include",
    "../common/include",
    "${ability_runtime_services_path}/common/include",
    "${cli_tool_framework_path}/interfaces/cli_tool/include",
    "${cli_tool_framework_path}/interfaces/function/include",
  ]

  cflags = []
  if (target_cpu == "arm") {
    cflags += [ "-BINDER_IPC_32BIT" ]
  }
}

ohos_shared_library("climgr") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  branch_protector_ret = "pac_ret"
  shlib_type = "sa"
  configs = [ ":clisa_config" ]
  include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ]
  sources = [
    "src/cli_tool_app_state_observer.cpp",
    "src/cli_tool_data_manager.cpp",
    "src/cli_tool_manager_service.cpp",
    "src/permission_query_util.cpp",
    "src/process_manager.cpp",
    "src/session_record.cpp",
    "src/tool_util.cpp",
    "../common/src/ccm_util.cpp",
    "../common/src/permission_util.cpp",
    "src/event_dispatcher.cpp",
    "src/io_monitor.cpp",
    "src/cli_function_data_manager.cpp",
  ]
  defines = [ "AMS_LOG_TAG = \"CliToolManager\"" ]

  deps = [
    "${ability_runtime_innerkits_path}/ability_manager:ability_manager",
    "${ability_runtime_innerkits_path}/app_manager:app_manager",
    "${ability_runtime_native_path}/appkit:appkit_manager_helper",
    "${cli_tool_framework_path}/interfaces/cli_tool:cli_tool_client",
    "${cli_tool_framework_path}/interfaces/function:function_info",
    "${ability_runtime_services_path}/common:hisysevent_report",
    "../common:cli_common",
  ]

  external_deps = [
    "ability_base:want",
    "access_token:libaccesstoken_sdk",
    "access_token:libtokenid_sdk",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "c_utils:utils",
    "ffrt:libffrt",
    "hilog:libhilog",
    "hisysevent:libhisysevent",
    "init:libbegetutil",
    "ipc:ipc_single",
    "json:nlohmann_json_static",
    "kv_store:distributeddata_inner",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
  ]

  innerapi_tags = [ "platformsdk" ]
  subsystem_name = "ability"
  part_name = "ability_runtime"
}