#Copyright (c) 2021 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("//foundation/arkui/ace_engine_lite/ace_lite.gni")

ace_frameworks_root = "//foundation/arkui/ace_engine_lite/frameworks"
ace_interface_root =
    "//foundation/arkui/ace_engine_lite/interfaces/inner_api/builtin"
ace_target_root = "//foundation/arkui/ace_engine_lite/frameworks/targets"

lite_component("ace_module_manager_lite") {
  features = [ ":ace_module_manager" ]
}

lite_library("ace_module_manager") {
  if (ohos_kernel_type == "liteos_m") {
    target_type = "static_library"
  } else {
    target_type = "shared_library"
    cflags = [ "-Wall" ]
    cflags_cc = cflags
  }

  include_dirs = [
    "$ace_frameworks_root/common/log",
    "$ace_frameworks_root/common/utils",
    "$ace_frameworks_root/include/base",
    "$ace_frameworks_root/native_engine/jsi",
    "$ace_interface_root/base",
    "$ace_interface_root/jsi",
    "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
    "//third_party/jerryscript/jerry-core/include",
    "//third_party/bounds_checking_function/include",
  ]
  deps = [ "$ace_target_root" ]

  sources = [ "$ace_frameworks_root/module_manager/module_manager.cpp" ]

  public_deps = [
    "$ace_frameworks_root/common:ace_common_lite",
    "$ace_frameworks_root/native_engine:ace_native_engine_lite",
    "//commonlibrary/utils_lite/js/builtin:ace_utils_kits",
  ]

  defines = ace_lite_common_defines

  if (ohos_kernel_type == "liteos_m") {
    public_deps += [
      "//foundation/arkui/ui_lite:ui",
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/jerryscript:jerry_engine",
    ]
    if (defined(board_toolchain_type) && board_toolchain_type == "iccarm") {
      public_deps -= [ "//commonlibrary/utils_lite/js/builtin:ace_utils_kits" ]
      cflags = [
        "--diag_suppress",
        "Pa137,Pe226",
      ]
      cflags_cc = cflags
    }
    if (defined(global_parts_info.security_huks)) {
      defines += [ "ENABLE_HUKS_ACE_LITE_FEATURE" ]
    }
  } else {
    public_deps += [
      "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/js/builtin:capability_api",
      "//base/hiviewdfx/hilog_lite/frameworks/js/builtin:ace_kit_hilog",
      "//base/security/huks/frameworks/crypto_lite/js/builtin:ace_kit_cipher",
      "//foundation/communication/netstack/frameworks/js/builtin:http_lite_shared",
      "//test/xts/device_attest_lite/interfaces/kit/js:kit_device_attest",
      "//third_party/bounds_checking_function:libsec_shared",
      "//third_party/jerryscript/jerry-core:jerry-core_shared",
    ]

    if (ace_engine_lite_battery_lite_enable) {
      public_deps +=
          [ "//base/powermgr/battery_lite/frameworks/js:ace_battery_kits" ]
    }

    if (ace_engine_lite_media_lite_enable) {
      public_deps += [ "//foundation/multimedia/media_lite/interfaces/kits/player_lite/js/builtin:audio_lite_api" ]
    }
  }
}