# 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("runtime_config") {
  visibility = [ ":*" ]

  defines = [ "AMS_LOG_TAG = \"Runtime\"" ]

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

  include_dirs = []
}

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

ohos_shared_library("runtime") {
  sources = [
    "${ability_runtime_native_path}/runtime/connect_server_manager.cpp",
    "${ability_runtime_native_path}/runtime/hdc_register.cpp",
    "${ability_runtime_native_path}/runtime/js_console_log.cpp",
    "${ability_runtime_native_path}/runtime/js_data_struct_converter.cpp",
    "${ability_runtime_native_path}/runtime/js_module_reader.cpp",
    "${ability_runtime_native_path}/runtime/js_module_searcher.cpp",
    "${ability_runtime_native_path}/runtime/js_runtime.cpp",
    "${ability_runtime_native_path}/runtime/js_runtime_utils.cpp",
    "${ability_runtime_native_path}/runtime/js_timer.cpp",
    "${ability_runtime_native_path}/runtime/js_worker.cpp",
    "${ability_runtime_native_path}/runtime/runtime.cpp",
  ]

  configs = [
    ":runtime_config",
    "//arkcompiler/ets_runtime:ark_jsruntime_public_config",
  ]

  public_configs = [
    ":runtime_public_config",
    "${ability_runtime_services_path}/common:common_config",
  ]

  deps = [
    "${ability_runtime_native_path}/runtime:runtime_extractor",
    "${ability_runtime_native_path}/runtime:string_utils",
    "//arkcompiler/ets_runtime:libark_jsruntime",
    "//foundation/arkui/napi:ace_napi_ark",
  ]

  external_deps = [
    "ability_base:configuration",
    "ability_base:want",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hiviewdfx_hilog_native:libhilog",
    "napi:ace_napi",
    "resource_management:global_resmgr",
  ]

  if (is_standard_system) {
    defines = [ "ENABLE_HITRACE" ]
    external_deps += [
      "hitrace_native:libhitrace",
      "init:libbegetutil",
    ]
  }

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

  subsystem_name = "ability"
  part_name = "ability_runtime"
}
