# Copyright (c) 2021-2022 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("ability_manager_public_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "include/",
    "//base/notification/eventhandler/interfaces/inner_api",
    "${ability_base_kits_path}/configuration/include",
    "${ability_base_kits_path}/uri/include",
    "${ability_base_kits_path}/want/include",
    "${ability_runtime_path}/interfaces/kits/native/ability/native",
    "${bundlefwk_inner_api_path}/appexecfwk_base/include",
    "${bundlefwk_inner_api_path}/appexecfwk_core/include/bundlemgr",
    "${ability_runtime_innerkits_path}/app_manager/include/appmgr",
    "${ability_runtime_path}/interfaces/kits/native/appkit/app",
    "${ability_runtime_innerkits_path}/dataobs_manager/include",
    "//third_party/jsoncpp/include",
  ]

  defines = []

  if (ability_command_for_test) {
    defines += [ "ABILITY_COMMAND_FOR_TEST" ]
  }

  if (ability_runtime_graphics) {
    include_dirs += [ "${multimedia_path}/interfaces/innerkits/include" ]

    defines += [ "SUPPORT_GRAPHICS" ]
  }

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

ohos_shared_library("ability_manager") {
  sources = [
    "${ability_runtime_native_path}/ability/native/data_ability_operation.cpp",
    "${ability_runtime_native_path}/ability/native/data_ability_operation_builder.cpp",
    "${ability_runtime_native_path}/ability/native/data_ability_result.cpp",
    "${ability_runtime_native_path}/ability/native/task_handler.cpp",
    "${ability_runtime_native_path}/ability/native/task_handler_client.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_manager_client.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_manager_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_manager_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_running_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/caller_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/extension_running_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/image_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/launch_param.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/lifecycle_state_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/mission_listener_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/mission_listener_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/mission_snapshot.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/stop_user_callback_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/stop_user_callback_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/want_receiver_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/want_sender_info.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/want_sender_proxy.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/want_sender_stub.cpp",
    "${ability_runtime_services_path}/abilitymgr/src/wants_info.cpp",
    "src/window_manager_service_handler_proxy.cpp",
    "src/window_manager_service_handler_stub.cpp",
  ]

  public_configs = [
    ":ability_manager_public_config",
    "${ability_runtime_services_path}/abilitymgr:abilityms_config",
  ]

  deps = [ "//third_party/jsoncpp:jsoncpp" ]

  external_deps = [
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:app_manager",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hitrace_native:hitrace_meter",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "relational_store:native_dataability",
    "relational_store:native_rdb",
    "samgr:samgr_proxy",
  ]

  if (ability_runtime_graphics) {
    deps += []
    external_deps += [ "multimedia_image_standard:image_native" ]
  }

  cflags_cc = []
  if (os_dlp_part_enabled) {
    cflags_cc += [ "-DWITH_DLP" ]
    external_deps += [ "dlp_permission_service:libdlpparse" ]
  }

  subsystem_name = "ability"
  part_name = "ability_runtime"
}
