1# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//foundation/arkui/ace_engine/ace_config.gni")
17import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
18
19base_output_path = get_label_info(":gen_abc_proxyclass", "target_out_dir")
20abcproxyclass_obj_path = base_output_path + "/abc_pamgmt_class.o"
21
22es2abc_gen_abc("gen_paMgmt_abc") {
23  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
24  src_js = rebase_path(
25          "//foundation/arkui/ace_engine/adapter/ohos/entrance/pa_engine/engine/jsi/paMgmt.js")
26  dst_file = rebase_path(base_output_path + "/paMgmt.abc")
27
28  in_puts = [ "//foundation/arkui/ace_engine/adapter/ohos/entrance/pa_engine/engine/jsi/paMgmt.js" ]
29  out_puts = [ base_output_path + "/paMgmt.abc" ]
30}
31
32gen_obj("abc_proxyclass") {
33  input = base_output_path + "/paMgmt.abc"
34  if (use_mac) {
35    abcproxyclass_obj_path = base_output_path + "/abc_pamgmt_class.c"
36  }
37  output = abcproxyclass_obj_path
38  snapshot_dep = [ ":gen_paMgmt_abc" ]
39}
40
41template("js_pa_engine_ark") {
42  forward_variables_from(invoker, "*")
43
44  ohos_source_set(target_name) {
45    subsystem_name = ace_engine_subsystem
46    part_name = ace_engine_part
47    defines += invoker.defines
48
49    configs = [ "$ace_root:ace_config" ]
50
51    include_dirs = [ "$ace_root/adapter/ohos/entrance/pa_engine/engine/common" ]
52    deps = []
53    external_deps = [
54      "ability_base:want",
55      "ability_base:zuri",
56      "ability_runtime:abilitykit_native",
57      "ability_runtime:appkit_native",
58      "ability_runtime:js_environment",
59      "ability_runtime:napi_ability_common",
60      "ability_runtime:napi_common",
61      "ability_runtime:runtime",
62      "bundle_framework:appexecfwk_base",
63      "bundle_framework:appexecfwk_core",
64      "c_utils:utils",
65      "ets_runtime:libark_jsruntime",
66      "eventhandler:libeventhandler",
67      "ffrt:libffrt",
68      "form_fwk:form_manager",
69      "hilog:libhilog",
70      "hisysevent:libhisysevent",
71      "ipc:ipc_core",
72      "ipc:ipc_napi",
73      "napi:ace_napi",
74      "relational_store:native_dataability",
75      "relational_store:native_rdb",
76      "resource_management:global_resmgr",
77      "safwk:system_ability_fwk",
78      "samgr:samgr_proxy",
79    ]
80
81    if (is_standard_system) {
82      defines += [ "ENABLE_HITRACE" ]
83      external_deps += [ "hitrace:libhitracechain" ]
84    }
85
86    sources = [
87      "$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_asset_manager.cpp",
88      "$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_timer_module.cpp",
89      "$ace_root/adapter/ohos/osal/log_wrapper.cpp",
90      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp",
91      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp",
92      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp",
93      "jsi_pa_engine.cpp",
94      "jsi_pa_engine_loader.cpp",
95    ]
96
97    if (defined(config.hdc_register_support) && config.hdc_register_support) {
98      sources += [ "$ace_root/frameworks/core/common/hdc_register.cpp" ]
99    }
100
101    defines += [ "PA_SUPPORT" ]
102
103    deps += [
104      ":gen_obj_src_abc_proxyclass",
105      "$ace_root/frameworks/base:ace_memory_monitor_ohos",
106    ]
107
108    if (target_cpu == "arm64") {
109      defines += [ "APP_USE_ARM64" ]
110    } else if (target_cpu == "arm") {
111      defines += [ "APP_USE_ARM" ]
112    }
113  }
114}
115
116foreach(item, ace_platforms) {
117  platform = item.name
118  engine_config = {
119  }
120  engine_config = item.config
121  support_engines = []
122  support_engines = engine_config.js_engines
123  foreach(engine, support_engines) {
124    if (engine.engine_name == "ark") {
125      js_pa_engine_ark("js_pa_engine_bridge_ark_$platform") {
126        defines = engine.engine_defines
127        config = {
128        }
129
130        if (defined(item.config)) {
131          config = item.config
132        }
133        if (defined(config.defines)) {
134          defines += config.defines
135        }
136      }
137    }
138  }
139}
140