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

config("ability_command_config") {
  include_dirs = [
    "include",
    "${innerkits_path}/app_manager/include/appmgr",
    "${innerkits_path}/uri/include",
    "${services_path}/abilitymgr/include",
    "${bundlefwk_inner_api_path}/appexecfwk_base/include",
    "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include",
    "//third_party/jsoncpp/include",
  ]
}

ohos_source_set("tools_aa_source_set") {
  sources = [
    "src/ability_command.cpp",
    "src/ability_tool_command.cpp",
    "src/shell_command.cpp",
    "src/shell_command_executor.cpp",
    "src/shell_command_result.cpp",
    "src/system_time.cpp",
    "src/test_observer.cpp",
    "src/test_observer_proxy.cpp",
    "src/test_observer_stub.cpp",
  ]

  public_configs = [
    ":ability_command_config",
    "${services_path}/abilitymgr:abilityms_config",
    "${services_path}/common:common_config",
  ]

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

  deps = [
    "${aafwk_path}/interfaces/innerkits/ability_manager:ability_manager",
    "${aafwk_path}/interfaces/innerkits/app_manager:app_manager",
    "${services_path}/abilitymgr:abilityms",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "eventhandler:libeventhandler",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "samgr_standard:samgr_proxy",
    "utils_base:utils",
  ]

  subsystem_name = "aafwk"
  part_name = "ability_tools"
}

ohos_executable("aa") {
  sources = [ "src/main.cpp" ]

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

  deps = [ ":tools_aa_source_set" ]

  external_deps = [
    "ability_base:base",
    "ability_base:configuration",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
  ]

  symlink_target_name = [ "ability_tool" ]

  install_enable = true

  subsystem_name = "aafwk"
  part_name = "ability_tools"
}

group("tools_aa") {
  deps = [ ":aa" ]
}
