# 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("//ark/ts2abc/ts2panda/ts2abc_config.gni")
import("//build/ohos.gni")
import("//foundation/aafwk/standard/form_runtime/form_runtime.gni")

################################### formbindingdata_napi ########################################
ohos_shared_library("formbindingdata_napi") {
  include_dirs = []

  sources = [
    "form_binding_data/form_binding_data.cpp",
    "form_binding_data/form_binding_data_module.cpp",
  ]

  configs = []

  deps = []

  external_deps = [
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "form_runtime:form_manager",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
    "utils_base:utils",
  ]

  relative_install_dir = "module/application"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### gen_form_extension_abc ########################################
ts2abc_gen_abc("gen_form_extension_abc") {
  src_js = rebase_path("form_extension/form_extension.js")
  dst_file = rebase_path(target_out_dir + "/form_extension.abc")
  in_puts = [ "form_extension/form_extension.js" ]
  out_puts = [ target_out_dir + "/form_extension.abc" ]
  extra_args = [ "--module" ]
}

gen_js_obj("form_extension_js") {
  input = "form_extension/form_extension.js"
  output = target_out_dir + "/form_extension.o"
}

gen_js_obj("form_extension_abc") {
  input = get_label_info(":gen_form_extension_abc", "target_out_dir") +
          "/form_extension.abc"
  output = target_out_dir + "/form_extension_abc.o"
  dep = ":gen_form_extension_abc"
}

ohos_shared_library("formextension_napi") {
  sources = [ "form_extension/form_extension_module.cpp" ]

  deps = [
    ":form_extension_abc",
    ":form_extension_js",
  ]

  external_deps = [ "napi:ace_napi" ]

  relative_install_dir = "module/application"
  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### gen_form_extension_context_abc ########################################
ts2abc_gen_abc("gen_form_extension_context_abc") {
  src_js = rebase_path("form_extension_context/form_extension_context.js")
  dst_file = rebase_path(target_out_dir + "/form_extension_context.abc")
  in_puts = [ "form_extension_context/form_extension_context.js" ]
  out_puts = [ target_out_dir + "/form_extension_context.abc" ]
  extra_args = [ "--module" ]
}

gen_js_obj("form_extension_context_js") {
  input = "form_extension_context/form_extension_context.js"
  output = target_out_dir + "/form_extension_context.o"
}

gen_js_obj("form_extension_context_abc") {
  input = get_label_info(":gen_form_extension_context_abc", "target_out_dir") +
          "/form_extension_context.abc"
  output = target_out_dir + "/form_extension_context_abc.o"
  dep = ":gen_form_extension_context_abc"
}

ohos_shared_library("formextensioncontext_napi") {
  sources = [ "form_extension_context/form_extension_context_module.cpp" ]

  deps = [
    ":form_extension_context_abc",
    ":form_extension_context_js",
  ]

  external_deps = [ "napi:ace_napi" ]

  relative_install_dir = "module/application"
  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### forminfo_napi ########################################
ohos_shared_library("forminfo_napi") {
  include_dirs = []

  sources = [
    "form_info/form_info_module.cpp",
    "form_info/js_form_info.cpp",
  ]

  configs = []

  deps = []

  external_deps = [
    "ability_base:want",
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "form_runtime:form_manager",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
    "utils_base:utils",
  ]

  relative_install_dir = "module/application"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### formhost_napi ########################################
ohos_shared_library("formhost_napi") {
  include_dirs = []

  sources = [
    "formHost/napi_form_host.cpp",
    "formHost/native_module.cpp",
  ]

  deps = [
    ":formutil_napi",
    "${ability_runtime_kits_path}/appkit:appkit_native",
    "${ability_runtime_path}/interfaces/kits/napi/aafwk/inner/napi_common:napi_common",
    "${form_runtime_path}:fmskit_native",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_runtime:ability_manager",
    "ability_runtime:abilitykit_native",
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
  ]

  relative_install_dir = "module/application"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### formmanager ########################################
ohos_shared_library("formmanager") {
  include_dirs = []

  sources = [
    "formManager/napi_form_manager.cpp",
    "formManager/native_module.cpp",
  ]

  deps = [
    "${ability_runtime_kits_path}/appkit:appkit_native",
    "${ability_runtime_path}/interfaces/kits/napi/aafwk/inner/napi_common:napi_common",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:want",
    "ability_runtime:ability_manager",
    "ability_runtime:abilitykit_native",
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "form_runtime:form_manager",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
  ]

  relative_install_dir = "module/ability"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### formprovider_napi ########################################
ohos_shared_library("formprovider_napi") {
  include_dirs = []

  sources = [
    "formProvider/napi_form_provider.cpp",
    "formProvider/native_module.cpp",
  ]

  deps = [
    ":formutil_napi",
    "${ability_runtime_kits_path}/appkit:appkit_native",
  ]

  external_deps = [
    "ability_base:base",
    "ability_runtime:ability_manager",
    "ability_runtime:abilitykit_native",
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "form_runtime:form_manager",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
  ]

  relative_install_dir = "module/application"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### formutil_napi_public_config ########################################
config("formutil_napi_public_config") {
  include_dirs = [ "formUtil/" ]
}

ohos_shared_library("formutil_napi") {
  include_dirs = []

  public_configs = [ ":formutil_napi_public_config" ]

  sources = [ "formUtil/napi_form_util.cpp" ]

  deps = [ "${ability_runtime_path}/frameworks/kits/appkit:appkit_native" ]

  external_deps = [
    "ability_base:base",
    "ability_runtime:ability_manager",
    "ability_runtime:abilitykit_native",
    "ability_runtime:runtime",
    "bundle_framework:appexecfwk_base",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "napi:ace_napi",
  ]

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}

################################### formerror_napi ########################################
ohos_shared_library("formerror_napi") {
  include_dirs = []

  sources = [
    "form_error/form_error_module.cpp",
    "form_error/js_form_error.cpp",
  ]

  configs = []

  deps = [ ":formutil_napi" ]

  external_deps = [
    "ability_runtime:ability_manager",
    "ability_runtime:abilitykit_native",
    "ability_runtime:runtime",
    "form_runtime:form_manager",
    "hiviewdfx_hilog_native:libhilog",
  ]

  relative_install_dir = "module/application"

  subsystem_name = "aafwk"
  part_name = "form_runtime"
}
