# 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/aafwk/standard/aafwk.gni")
import("//foundation/aafwk/standard/services/abilitymgr/abilitymgr.gni")

group("abilityms_target") {
  deps = [
    ":abilityms",
    ":ams_service_config",
  ]
}

config("abilityms_config") {
  include_dirs = [
    "include/",
    "${innerkits_path}/ability_manager/include",
    "${innerkits_path}/app_manager/include",
    "${ability_base_innerapi_path}/base/include",
    "${ability_base_innerapi_path}/uri/include",
    "${ability_base_innerapi_path}/want/include",
    "${services_path}/common/include",
    "//utils/native/base/include",
    "//prebuilts/jdk/jdk8/linux-x86/include",
    "//prebuilts/jdk/jdk8/linux-x86/include/linux",
    "//third_party/json/include",
    "${kits_path}/ability/native/include",
    "${distributeddatamgr_path}/appdatamgr/interfaces/inner_api/native/rdb/include",
    "${distributeddatamgr_path}/appdatamgr/interfaces/inner_api/native/appdatafwk/include",
    "${distributeddatamgr_path}/appdatamgr/interfaces/inner_api/native/dataability/include",
    "${innerkits_path}/dataobs_manager/include",
    "${aafwk_path}/tools/aa/include",
    "//base/hiviewdfx/hiview/adapter/utility/include",
    "//base/account/os_account/frameworks/common/account_error/include",
    "//base/account/os_account/frameworks/common/database/include",
    "//base/account/os_account/interfaces/innerkits/osaccount/native/include",
    "//base/hiviewdfx/hicollie/interfaces/native/innerkits/include",
    "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
  ]

  defines = [ "ABILITY_COMMAND_FOR_TEST" ]

  if (ability_runtime_graphics) {
    include_dirs += [
      "${graphic_path}/interfaces/inner_api",
      "${multimedia_path}/interfaces/innerkits/include",
      "${graphic_path}/interfaces/inner_api/wmservice",
      "${global_path}/i18n/frameworks/intl/include",
    ]

    defines += [ "SUPPORT_GRAPHICS" ]
  }

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

ohos_shared_library("abilityms") {
  sources = abilityms_files
  sources += [ "src/sa_mgr_client.cpp" ]
  cflags_cc = []
  configs = [ ":abilityms_config" ]
  deps = [
    "${innerkits_path}/uri_permission:uri_permission_mgr",
    "${services_path}/common:perm_verification",
    "//base/hiviewdfx/hiview/adapter/utility:hiview_adapter_utility",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:configuration",
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:ability_context_native",
    "ability_runtime:abilitykit_native",
    "ability_runtime:app_manager",
    "access_token:libaccesstoken_sdk",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "common_event_service:cesfwk_core",
    "common_event_service:cesfwk_innerkits",
    "dataability:native_dataability",
    "dsoftbus_standard:softbus_client",
    "eventhandler:libeventhandler",
    "hicollie_native:libhicollie",
    "hisysevent_native:libhisysevent",
    "hitrace_native:hitrace_meter",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "relational_store:native_rdb",
    "resource_management:global_resmgr",
    "safwk:system_ability_fwk",
    "samgr_standard:samgr_proxy",
    "startup_l2:syspara",
    "utils_base:utils",
  ]

  if (os_account_part_enabled) {
    cflags_cc += [ "-DOS_ACCOUNT_PART_ENABLED" ]
    external_deps += [ "os_account:os_account_innerkits" ]
  }

  if (ability_runtime_graphics) {
    deps += [
      "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr",
      "//third_party/libpng:libpng",
    ]
    public_deps = [
      "${global_path}/resource_management/frameworks/resmgr:global_resmgr",
      "${graphic_path}:libwmservice",
    ]
    external_deps += [
      "i18n:intl_util",
      "multimedia_image_standard:image_native",
      "window_manager:libdm",
      "window_manager:libwm",
    ]
  }

  subsystem_name = "aafwk"
  part_name = "ability_runtime"
}

ohos_prebuilt_etc("ams_service_config.json") {
  source = "resource/ams_service_config.json"
  subsystem_name = "aafwk"
  part_name = "ability_runtime"
}

group("ams_service_config") {
  deps = [ ":ams_service_config.json" ]
}
