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("//build/config/components/ets_frontend/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:extensionkit_native",
59      "ability_runtime:js_environment",
60      "ability_runtime:napi_ability_common",
61      "ability_runtime:napi_common",
62      "ability_runtime:runtime",
63      "bundle_framework:appexecfwk_base",
64      "bundle_framework:appexecfwk_core",
65      "c_utils:utils",
66      "ets_runtime:libark_jsruntime",
67      "eventhandler:libeventhandler",
68      "ffrt:libffrt",
69      "form_fwk:form_manager",
70      "hilog:libhilog",
71      "hisysevent:libhisysevent",
72      "ipc:ipc_core",
73      "ipc:ipc_napi",
74      "napi:ace_napi",
75      "relational_store:native_dataability",
76      "relational_store:native_rdb",
77      "resource_management:global_resmgr",
78      "safwk:system_ability_fwk",
79      "samgr:samgr_proxy",
80    ]
81
82    if (is_standard_system) {
83      defines += [ "ENABLE_HITRACE" ]
84      external_deps += [ "hitrace:libhitracechain" ]
85    }
86
87    sources = [
88      "$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_asset_manager.cpp",
89      "$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_timer_module.cpp",
90      "$ace_root/adapter/ohos/osal/log_wrapper.cpp",
91      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp",
92      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp",
93      "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp",
94      "jsi_pa_engine.cpp",
95      "jsi_pa_engine_loader.cpp",
96    ]
97
98    if (defined(config.hdc_register_support) && config.hdc_register_support) {
99      sources += [ "$ace_root/frameworks/core/common/hdc_register.cpp" ]
100    }
101
102    defines += [ "PA_SUPPORT" ]
103
104    deps += [
105      ":gen_obj_src_abc_proxyclass",
106      "$ace_root/frameworks/base:ace_memory_monitor_ohos",
107    ]
108
109    if (target_cpu == "arm64") {
110      defines += [ "APP_USE_ARM64" ]
111    } else if (target_cpu == "arm") {
112      defines += [ "APP_USE_ARM" ]
113    }
114  }
115}
116
117foreach(item, ace_platforms) {
118  platform = item.name
119  engine_config = {
120  }
121  engine_config = item.config
122  support_engines = []
123  support_engines = engine_config.js_engines
124  foreach(engine, support_engines) {
125    if (engine.engine_name == "ark") {
126      js_pa_engine_ark("js_pa_engine_bridge_ark_$platform") {
127        defines = engine.engine_defines
128        config = {
129        }
130
131        if (defined(item.config)) {
132          config = item.config
133        }
134        if (defined(config.defines)) {
135          defines += config.defines
136        }
137      }
138    }
139  }
140}
141