# 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/lite/config/component/lite_component.gni")
import("//build/lite/config/subsystem/aafwk/config.gni")

lite_component("appspawn_lite") {
  features = [ ":appspawn" ]
}

# feature: appspawn
executable("appspawn") {
  sources = [
    "../common/appspawn_server.c",
    "../common/appspawn_trace.cpp",
    "appspawn_message.c",
    "appspawn_process.c",
    "appspawn_service.c",
    "main.c",
  ]

  ldflags = [
    "-lstdc++",
    "-ldl",
  ]

  cflags = [
    "-Wall",
    "-Wno-format",
    "-Wno-format-extra-args",
  ]

  defines = [
    "_GNU_SOURCE",
    "OHOS_LITE",
  ]

  include_dirs = [
    ".",
    "../common",
    "//base/startup/appspawn/interfaces/innerkits/include",
    "//base/startup/appspawn/util/include",
    "//base/startup/init/interfaces/innerkits/include",
    "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
    "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/registry",
    "${aafwk_lite_path}/interfaces/inner_api/abilitymgr_lite",
    "//third_party/bounds_checking_function/include/",
    "//third_party/cJSON",
    "//commonlibrary/utils_lite/include",
  ]

  deps = [
    "${aafwk_lite_path}/frameworks/ability_lite:aafwk_abilitykit_lite",
    "//base/startup/init/interfaces/innerkits:libbegetutil",
    "//build/lite/config/component/cJSON:cjson_shared",
    "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
    "//foundation/distributeddatamgr/kv_store/interfaces/inner_api/kv_store:kv_store",
    "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
    "//third_party/bounds_checking_function:libsec_shared",
  ]

  if (ability_lite_enable_ohos_appexecfwk_feature_ability == true) {
    deps += [
      "//foundation/arkui/ace_engine_lite/frameworks:ace_lite",
      "//foundation/arkui/ui_lite:ui_lite",
      "//foundation/graphic/graphic_utils_lite:utils_lite",
      "//foundation/graphic/surface_lite:surface_lite",
    ]
  }

  if (ohos_kernel_type == "liteos_a") {
    deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ]
  }

  if (ohos_kernel_type == "linux") {
    defines += [ "__LINUX__" ]
  }
}

if (ohos_build_type == "debug") {
  group("unittest") {
    deps =
        [ "//base/startup/appspawn/test/unittest/app_spawn_lite_test:unittest" ]
  }
}