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_ext.gni") 18import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") 19 20base_output_path = get_label_info(":gen_abc_proxyclass", "target_out_dir") 21abcproxyclass_obj_path = base_output_path + "/abc_proxy_class.o" 22abcenumstyle_obj_path = base_output_path + "/abc_enum_style.o" 23abcuicontext_obj_path = base_output_path + "/abc_uicontext.o" 24jsmocksystemplugin_obj_path = base_output_path + "/abc_js_mock_system_plugin.o" 25 26es2abc_gen_abc("gen_stateMgmt_abc") { 27 extra_visibility = [ ":*" ] # Only targets in this file can depend on this. 28 src_js = rebase_path( 29 "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js") 30 dst_file = rebase_path(base_output_path + "/stateMgmt.abc") 31 32 in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js" ] 33 out_puts = [ base_output_path + "/stateMgmt.abc" ] 34} 35 36es2abc_gen_abc("gen_jsEnumStyle_abc") { 37 extra_visibility = [ ":*" ] # Only targets in this file can depend on this. 38 src_js = rebase_path( 39 "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js") 40 dst_file = rebase_path(base_output_path + "/jsEnumStyle.abc") 41 42 in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js" ] 43 out_puts = [ base_output_path + "/jsEnumStyle.abc" ] 44} 45 46es2abc_gen_abc("gen_jsUIContext_abc") { 47 extra_visibility = [ ":*" ] # Only targets in this file can depend on this. 48 src_js = rebase_path( 49 "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsUIContext.js") 50 dst_file = rebase_path(base_output_path + "/jsUIContext.abc") 51 52 in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsUIContext.js" ] 53 out_puts = [ base_output_path + "/jsUIContext.abc" ] 54} 55 56if (!is_arkui_x) { 57 es2abc_gen_abc("gen_js_mock_system_plugin_abc") { 58 extra_visibility = [ ":*" ] # Only targets in this file can depend on this. 59 src_js = rebase_path( 60 "$root_out_dir/obj/ide/tools/previewer/automock/dist/jsMockSystemPlugin.js") 61 dst_file = rebase_path(base_output_path + "/jsMockSystemPlugin.abc") 62 63 in_puts = [ rebase_path( 64 "$root_out_dir/obj/ide/tools/previewer/automock/dist/jsMockSystemPlugin.js") ] 65 out_puts = [ base_output_path + "/jsMockSystemPlugin.abc" ] 66 extra_dependencies = 67 [ "//ide/tools/previewer/automock:gen_snapshot_jsmock" ] 68 } 69} 70 71gen_obj("abc_proxyclass") { 72 input = base_output_path + "/stateMgmt.abc" 73 if (use_mac || use_mingw_win || use_ios || use_linux) { 74 abcproxyclass_obj_path = base_output_path + "/js_proxy_class.c" 75 } 76 output = abcproxyclass_obj_path 77 snapshot_dep = [ ":gen_stateMgmt_abc" ] 78} 79 80gen_obj("abc_enum_style") { 81 input = base_output_path + "/jsEnumStyle.abc" 82 if (use_mac || use_mingw_win || use_linux || use_ios) { 83 abcenumstyle_obj_path = base_output_path + "/jsEnumStyle.c" 84 } 85 output = abcenumstyle_obj_path 86 snapshot_dep = [ ":gen_jsEnumStyle_abc" ] 87} 88 89gen_obj("abc_uicontext") { 90 input = base_output_path + "/jsUIContext.abc" 91 if (use_mac || use_mingw_win || use_linux || use_ios) { 92 abcuicontext_obj_path = base_output_path + "/jsUIContext.c" 93 } 94 output = abcuicontext_obj_path 95 snapshot_dep = [ ":gen_jsUIContext_abc" ] 96} 97 98if (!is_arkui_x) { 99 gen_obj("abc_mock_system_plugin") { 100 input = base_output_path + "/jsMockSystemPlugin.abc" 101 if (use_mac || use_mingw_win || use_linux) { 102 jsmocksystemplugin_obj_path = 103 base_output_path + "/js_mock_system_plugin.c" 104 } 105 output = jsmocksystemplugin_obj_path 106 snapshot_dep = [ ":gen_js_mock_system_plugin_abc" ] 107 } 108} 109 110template("declarative_js_engine_ark") { 111 forward_variables_from(invoker, "*") 112 113 ohos_source_set(target_name) { 114 subsystem_name = ace_engine_subsystem 115 part_name = ace_engine_part 116 defines += invoker.defines 117 if (target_cpu == "arm64") { 118 defines += [ "APP_USE_ARM64" ] 119 } else if (target_cpu == "arm") { 120 defines += [ "APP_USE_ARM" ] 121 } 122 123 configs = [ "$ace_root:ace_config" ] 124 125 sources = [ 126 "js_converter.cpp", 127 "jsi_declarative_engine.cpp", 128 "jsi_declarative_group_js_bridge.cpp", 129 "jsi_object_template.cpp", 130 "jsi_types.cpp", 131 "jsi_view_register.cpp", 132 "modules/jsi_app_module.cpp", 133 "modules/jsi_context_module.cpp", 134 "modules/jsi_curves_module.cpp", 135 "modules/jsi_matrix4_module.cpp", 136 "modules/jsi_module_manager.cpp", 137 "modules/jsi_router_module.cpp", 138 "modules/jsi_syscap_module.cpp", 139 "modules/jsi_timer_module.cpp", 140 ] 141 142 if (defined(vendor_configs.extra_view_register_sources)) { 143 include_dirs = vendor_configs.ace_advance_dirs 144 sources += vendor_configs.extra_view_register_sources 145 } else { 146 sources += [ "jsi_extra_view_register.cpp" ] 147 } 148 149 deps = [] 150 151 if (enable_ng_build) { 152 sources += [ 153 "jsi_animator_model_ng_build_impl.cpp", 154 "jsi_view_register_impl_ng.cpp", 155 ] 156 } else { 157 sources += [ 158 "jsi_animator_model_ng_impl.cpp", 159 "jsi_view_register_impl.cpp", 160 ] 161 deps += [ "$ace_root/frameworks/core/components/theme:build_theme_code" ] 162 } 163 164 external_deps = [] 165 166 # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported 167 if (is_arkui_x) { 168 configs += [ "$ark_ets_path:ark_jsruntime_public_config" ] 169 deps += [ "$ark_ets_path:libark_jsruntime_static" ] 170 public_deps = [ "//foundation/arkui/napi:ace_napi" ] 171 } else { 172 external_deps += [ 173 "ets_runtime:libark_jsruntime", 174 "napi:ace_napi", 175 "napi:ace_napi_ark", 176 ] 177 } 178 179 deps = [] 180 if (is_arkui_x) { 181 deps += [ "//foundation/arkui/napi:ace_napi_ark" ] 182 } 183 184 if (defined(config.build_for_preview) && config.build_for_preview) { 185 deps += [ ":gen_obj_src_abc_mock_system_plugin" ] 186 sources += [ "utils/jsi_module_searcher.cpp" ] 187 } else if (defined(config.use_build_in_js_engine) && 188 config.use_build_in_js_engine) { 189 if (enable_ng_build) { 190 sources += [ 191 "$ace_root/frameworks/bridge/js_frontend/engine/common/js_api_perf.cpp", 192 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp", 193 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp", 194 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp", 195 ] 196 } 197 } else { 198 sources += [ 199 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp", 200 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp", 201 "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp", 202 ] 203 } 204 205 deps += [ 206 ":gen_obj_src_abc_enum_style", 207 ":gen_obj_src_abc_proxyclass", 208 ":gen_obj_src_abc_uicontext", 209 ] 210 } 211} 212 213foreach(item, ace_platforms) { 214 platform = item.name 215 engine_config = { 216 } 217 engine_config = item.config 218 support_engines = [] 219 support_engines = engine_config.js_engines 220 foreach(engine, support_engines) { 221 if (engine.engine_name == "ark") { 222 declarative_js_engine_ark("declarative_js_engine_bridge_ark_$platform") { 223 defines = engine.engine_defines 224 config = { 225 } 226 227 if (defined(item.config)) { 228 config = item.config 229 } 230 if (defined(config.defines)) { 231 defines += config.defines 232 } 233 } 234 } 235 } 236} 237