# 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")

config("runtime_config") {
  visibility = [ ":*" ]

  defines = [
    "AMS_LOG_TAG = \"Runtime\"",
    "AMS_LOG_DOMAIN = 0xD002200",
  ]

  if (target_cpu == "arm64") {
    defines += [ "_ARM64_" ]
  }

  include_dirs = []
}

config("runtime_public_config") {
  visibility = [ ":*" ]
  include_dirs = [ "include" ]
}

ohos_shared_library("runtime") {
  sources = [
    "${kits_path}/runtime/native/js_data_struct_converter.cpp",
    "${kits_path}/runtime/native/js_runtime.cpp",
    "${kits_path}/runtime/native/js_runtime_utils.cpp",
    "${kits_path}/runtime/native/runtime.cpp",
  ]

  configs = [
    ":runtime_config",
    "//ark/js_runtime:ark_jsruntime_public_config",
    "${services_path}/common:common_config",
  ]

  public_configs = [ ":runtime_public_config" ]

  deps = [
    "//ark/js_runtime:libark_jsruntime",
    "//foundation/arkui/napi:ace_napi_ark",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:configuration",
    "ability_base:want",
    "ability_base:zuri",
    "ability_runtime:ability_manager",
    "ability_runtime:app_manager",
    "bundle_framework:appexecfwk_base",
    "eventhandler:libeventhandler",
    "hiviewdfx_hilog_native:libhilog",
    "init:libbegetutil",
    "napi:ace_napi",
    "resource_management:global_resmgr",
    "utils_base:utils",
  ]

  if (is_standard_system) {
    defines = [ "ENABLE_HITRACE" ]
    external_deps += [
      "hitrace_native:libhitrace",
      "startup_l2:syspara",
    ]
  } else {
    external_deps += [ "startup:syspara" ]
  }

  if (ability_runtime_graphics) {
    external_deps += [
      "ace_engine_standard:ace_uicontent",
      "napi:ace_container_scope",
    ]
  }

  subsystem_name = "aafwk"
  part_name = "ability_runtime"
}
