• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 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_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"
24abcpreload_obj_path = base_output_path + "/abc_preload.o"
25jsmocksystemplugin_obj_path = base_output_path + "/abc_js_mock_system_plugin.o"
26arkTheme_obj_path = base_output_path + "/abc_ark_theme.o"
27arkcomponent_obj_path = base_output_path + "/abc_ark_component.o"
28
29es2abc_gen_abc("gen_stateMgmt_abc") {
30  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
31  src_js = rebase_path(base_output_path + "../../../stateMgmt.js")
32  dst_file = rebase_path(base_output_path + "/stateMgmt.abc")
33  in_puts = [ rebase_path(base_output_path + "../../../stateMgmt.js") ]
34  out_puts = [ base_output_path + "/stateMgmt.abc" ]
35
36  extra_dependencies = [
37    "$ace_root/frameworks/bridge/declarative_frontend:run_state_mgmt_build",
38  ]
39}
40
41es2abc_gen_abc("gen_jsEnumStyle_abc") {
42  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
43  src_js = rebase_path(
44          "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js")
45  dst_file = rebase_path(base_output_path + "/jsEnumStyle.abc")
46
47  in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js" ]
48  out_puts = [ base_output_path + "/jsEnumStyle.abc" ]
49}
50
51es2abc_gen_abc("gen_arkTheme_abc") {
52  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
53  src_js = rebase_path(
54          "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/arkTheme.js")
55  dst_file = rebase_path(base_output_path + "/arkTheme.abc")
56
57  in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/arkTheme.js" ]
58  out_puts = [ base_output_path + "/arkTheme.abc" ]
59}
60
61es2abc_gen_abc("gen_jsUIContext_abc") {
62  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
63  src_js = rebase_path(
64          "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsUIContext.js")
65  dst_file = rebase_path(base_output_path + "/jsUIContext.abc")
66
67  in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsUIContext.js" ]
68  out_puts = [ base_output_path + "/jsUIContext.abc" ]
69}
70
71es2abc_gen_abc("gen_jsPreload_abc") {
72  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
73  src_js = rebase_path(
74          "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsPreload.js")
75  dst_file = rebase_path(base_output_path + "/jsPreload.abc")
76
77  in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsPreload.js" ]
78  out_puts = [ base_output_path + "/jsPreload.abc" ]
79}
80
81es2abc_gen_abc("gen_arkComponent_abc") {
82  extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
83  src_js = rebase_path(
84          "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/arkComponent.js")
85  dst_file = rebase_path(base_output_path + "/arkComponent.abc")
86
87  in_puts = [ "//foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/arkComponent.js" ]
88  out_puts = [ base_output_path + "/arkComponent.abc" ]
89}
90
91if (!is_arkui_x && (use_mac || use_mingw_win || use_linux)) {
92  es2abc_gen_abc("gen_js_mock_system_plugin_abc") {
93    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
94    src_js = rebase_path(
95            "$root_out_dir/obj/ide/tools/previewer/automock/dist/jsMockSystemPlugin.js")
96    dst_file = rebase_path(base_output_path + "/jsMockSystemPlugin.abc")
97
98    in_puts = [ rebase_path(
99            "$root_out_dir/obj/ide/tools/previewer/automock/dist/jsMockSystemPlugin.js") ]
100    out_puts = [ base_output_path + "/jsMockSystemPlugin.abc" ]
101    extra_dependencies =
102        [ "//ide/tools/previewer/automock:gen_snapshot_jsmock" ]
103  }
104}
105
106gen_obj("abc_proxyclass") {
107  input = base_output_path + "/stateMgmt.abc"
108  if (use_mac || use_mingw_win || use_ios || use_linux) {
109    abcproxyclass_obj_path = base_output_path + "/js_proxy_class.c"
110  }
111  output = abcproxyclass_obj_path
112  snapshot_dep = [ ":gen_stateMgmt_abc" ]
113}
114
115gen_obj("abc_enum_style") {
116  input = base_output_path + "/jsEnumStyle.abc"
117  if (use_mac || use_mingw_win || use_linux || use_ios) {
118    abcenumstyle_obj_path = base_output_path + "/jsEnumStyle.c"
119  }
120  output = abcenumstyle_obj_path
121  snapshot_dep = [ ":gen_jsEnumStyle_abc" ]
122}
123
124gen_obj("abc_ark_theme") {
125  input = base_output_path + "/arkTheme.abc"
126  if (use_mac || use_mingw_win || use_ios || use_linux) {
127    arkTheme_obj_path = base_output_path + "/arkTheme.c"
128  }
129  output = arkTheme_obj_path
130  snapshot_dep = [ ":gen_arkTheme_abc" ]
131}
132
133gen_obj("abc_uicontext") {
134  input = base_output_path + "/jsUIContext.abc"
135  if (use_mac || use_mingw_win || use_linux || use_ios) {
136    abcuicontext_obj_path = base_output_path + "/jsUIContext.c"
137  }
138  output = abcuicontext_obj_path
139  snapshot_dep = [ ":gen_jsUIContext_abc" ]
140}
141
142gen_obj("abc_preload") {
143  input = base_output_path + "/jsPreload.abc"
144  if (use_mac || use_mingw_win || use_linux || use_ios) {
145    abcpreload_obj_path = base_output_path + "/jsPreload.c"
146  }
147  output = abcpreload_obj_path
148  snapshot_dep = [ ":gen_jsPreload_abc" ]
149}
150
151gen_obj("abc_ark_component") {
152  input = base_output_path + "/arkComponent.abc"
153  if (use_mac || use_mingw_win || use_ios || use_linux) {
154    arkcomponent_obj_path = base_output_path + "/arkComponent.c"
155  }
156  output = arkcomponent_obj_path
157  snapshot_dep = [ ":gen_arkComponent_abc" ]
158}
159
160if (!is_arkui_x && (use_mac || use_mingw_win || use_linux)) {
161  gen_obj("abc_mock_system_plugin") {
162    input = base_output_path + "/jsMockSystemPlugin.abc"
163    if (use_mac || use_mingw_win || use_linux) {
164      jsmocksystemplugin_obj_path =
165          base_output_path + "/js_mock_system_plugin.c"
166    }
167    output = jsmocksystemplugin_obj_path
168    snapshot_dep = [ ":gen_js_mock_system_plugin_abc" ]
169  }
170}
171
172if (!is_arkui_x) {
173  abc_sources = [ "stateMgmt" ]
174} else {
175  abc_sources = []
176}
177
178foreach(item, abc_sources) {
179  ohos_prebuilt_etc("copy_" + item + "_abc") {
180    source = base_output_path + "/" + item + ".abc"
181    deps = [ ":gen_" + item + "_abc" ]
182    subsystem_name = ace_engine_subsystem
183    part_name = ace_engine_part
184    module_install_dir = "etc/abc/framework"
185  }
186}
187
188template("declarative_js_engine_ark") {
189  forward_variables_from(invoker, "*")
190  platform = invoker.platform
191
192  ohos_source_set(target_name) {
193    subsystem_name = ace_engine_subsystem
194    part_name = ace_engine_part
195    defines += invoker.defines
196    if (target_cpu == "arm64") {
197      defines += [ "APP_USE_ARM64" ]
198    } else if (target_cpu == "arm") {
199      defines += [ "APP_USE_ARM" ]
200    }
201
202    configs = [ "$ace_root:ace_config" ]
203
204    if (ace_engine_feature_enable_point_light) {
205      defines += [ "POINT_LIGHT_ENABLE" ]
206    }
207
208    sources = [
209      "js_converter.cpp",
210      "jsi_container_app_bar_register.cpp",
211      "jsi_container_modal_view_register.cpp",
212      "jsi_declarative_engine.cpp",
213      "jsi_declarative_group_js_bridge.cpp",
214      "jsi_object_template.cpp",
215      "jsi_types.cpp",
216      "jsi_view_register.cpp",
217      "modules/jsi_app_module.cpp",
218      "modules/jsi_context_module.cpp",
219      "modules/jsi_curves_module.cpp",
220      "modules/jsi_matrix4_module.cpp",
221      "modules/jsi_module_manager.cpp",
222      "modules/jsi_router_module.cpp",
223      "modules/jsi_syscap_module.cpp",
224      "modules/jsi_timer_module.cpp",
225      "nativeModule/arkts_native_alphabet_indexer_bridge.cpp",
226      "nativeModule/arkts_native_api_impl_bridge.cpp",
227      "nativeModule/arkts_native_badge_bridge.cpp",
228      "nativeModule/arkts_native_blank_bridge.cpp",
229      "nativeModule/arkts_native_button_bridge.cpp",
230      "nativeModule/arkts_native_calendar_picker_bridge.cpp",
231      "nativeModule/arkts_native_checkbox_bridge.cpp",
232      "nativeModule/arkts_native_checkboxgroup_bridge.cpp",
233      "nativeModule/arkts_native_column_bridge.cpp",
234      "nativeModule/arkts_native_common_bridge.cpp",
235      "nativeModule/arkts_native_common_shape_bridge.cpp",
236      "nativeModule/arkts_native_container_span_bridge.cpp",
237      "nativeModule/arkts_native_counter_bridge.cpp",
238      "nativeModule/arkts_native_data_panel_bridge.cpp",
239      "nativeModule/arkts_native_date_picker_bridge.cpp",
240      "nativeModule/arkts_native_divider_bridge.cpp",
241      "nativeModule/arkts_native_flex_bridge.cpp",
242      "nativeModule/arkts_native_frame_node_bridge.cpp",
243      "nativeModule/arkts_native_gauge_bridge.cpp",
244      "nativeModule/arkts_native_grid_bridge.cpp",
245      "nativeModule/arkts_native_grid_col_bridge.cpp",
246      "nativeModule/arkts_native_grid_item_bridge.cpp",
247      "nativeModule/arkts_native_grid_row_bridge.cpp",
248      "nativeModule/arkts_native_hyperlink_bridge.cpp",
249      "nativeModule/arkts_native_image_animator_bridge.cpp",
250      "nativeModule/arkts_native_image_bridge.cpp",
251      "nativeModule/arkts_native_image_span_bridge.cpp",
252      "nativeModule/arkts_native_indicator_component_bridge.cpp",
253      "nativeModule/arkts_native_lazy_grid_layout_bridge.cpp",
254      "nativeModule/arkts_native_line_bridge.cpp",
255      "nativeModule/arkts_native_linear_indicator.cpp",
256      "nativeModule/arkts_native_list_bridge.cpp",
257      "nativeModule/arkts_native_list_item_bridge.cpp",
258      "nativeModule/arkts_native_list_item_group_bridge.cpp",
259      "nativeModule/arkts_native_loading_progress_bridge.cpp",
260      "nativeModule/arkts_native_marquee_bridge.cpp",
261      "nativeModule/arkts_native_menu_bridge.cpp",
262      "nativeModule/arkts_native_menu_item_bridge.cpp",
263      "nativeModule/arkts_native_nav_destination_bridge.cpp",
264      "nativeModule/arkts_native_nav_router_bridge.cpp",
265      "nativeModule/arkts_native_navigation_bridge.cpp",
266      "nativeModule/arkts_native_navigation_utils.cpp",
267      "nativeModule/arkts_native_navigator_bridge.cpp",
268      "nativeModule/arkts_native_node_adapter_bridge.cpp",
269      "nativeModule/arkts_native_node_container_bridge.cpp",
270      "nativeModule/arkts_native_panel_bridge.cpp",
271      "nativeModule/arkts_native_particle_bridge.cpp",
272      "nativeModule/arkts_native_path_bridge.cpp",
273      "nativeModule/arkts_native_pattern_lock_bridge.cpp",
274      "nativeModule/arkts_native_polygon_bridge.cpp",
275      "nativeModule/arkts_native_polyline_bridge.cpp",
276      "nativeModule/arkts_native_progress_bridge.cpp",
277      "nativeModule/arkts_native_radio_bridge.cpp",
278      "nativeModule/arkts_native_rating_bridge.cpp",
279      "nativeModule/arkts_native_rect_bridge.cpp",
280      "nativeModule/arkts_native_refresh_bridge.cpp",
281      "nativeModule/arkts_native_relative_container_bridge.cpp",
282      "nativeModule/arkts_native_render_node_bridge.cpp",
283      "nativeModule/arkts_native_resource_bridge.cpp",
284      "nativeModule/arkts_native_rich_editor_bridge.cpp",
285      "nativeModule/arkts_native_row_bridge.cpp",
286      "nativeModule/arkts_native_scroll_bridge.cpp",
287      "nativeModule/arkts_native_scrollable_bridge.cpp",
288      "nativeModule/arkts_native_scrollbar_bridge.cpp",
289      "nativeModule/arkts_native_search_bridge.cpp",
290      "nativeModule/arkts_native_shape_bridge.cpp",
291      "nativeModule/arkts_native_side_bar_container_bridge.cpp",
292      "nativeModule/arkts_native_slider_bridge.cpp",
293      "nativeModule/arkts_native_span_bridge.cpp",
294      "nativeModule/arkts_native_stack_bridge.cpp",
295      "nativeModule/arkts_native_swiper_bridge.cpp",
296      "nativeModule/arkts_native_symbol_glyph_bridge.cpp",
297      "nativeModule/arkts_native_symbol_span_bridge.cpp",
298      "nativeModule/arkts_native_tabcontent_bridge.cpp",
299      "nativeModule/arkts_native_tabs_bridge.cpp",
300      "nativeModule/arkts_native_text_area_bridge.cpp",
301      "nativeModule/arkts_native_text_bridge.cpp",
302      "nativeModule/arkts_native_text_clock_bridge.cpp",
303      "nativeModule/arkts_native_text_input_bridge.cpp",
304      "nativeModule/arkts_native_text_timer_bridge.cpp",
305      "nativeModule/arkts_native_textpicker_bridge.cpp",
306      "nativeModule/arkts_native_theme_bridge.cpp",
307      "nativeModule/arkts_native_timepicker_bridge.cpp",
308      "nativeModule/arkts_native_toggle_bridge.cpp",
309      "nativeModule/arkts_native_utils_bridge.cpp",
310      "nativeModule/arkts_native_video_bridge.cpp",
311      "nativeModule/arkts_native_water_flow_bridge.cpp",
312      "nativeModule/arkts_native_web_bridge.cpp",
313      "nativeModule/arkts_utils.cpp",
314      "nativeModule/ui_context_helper.cpp",
315    ]
316
317    if (!ace_engine_feature_wearable) {
318      sources += [
319        "nativeModule/arkts_native_column_split_bridge.cpp",
320        "nativeModule/arkts_native_folder_stack_bridge.cpp",
321        "nativeModule/arkts_native_row_split_bridge.cpp",
322        "nativeModule/arkts_native_select_bridge.cpp",
323        "nativeModule/arkts_native_stepper_item_bridge.cpp",
324      ]
325    }
326
327    if (qrcodegen_support) {
328      sources += [ "nativeModule/arkts_native_qrcode_bridge.cpp" ]
329    }
330
331    deps = [
332      "$ace_root/frameworks/core/components/theme:build_theme_code",
333      "${ace_root}/frameworks/core/interfaces/native:ace_core_interfaces_native_node_$platform",
334    ]
335    if (is_arkui_x) {
336      deps += [ "//foundation/graphic/graphic_2d/interfaces/kits/napi/graphic/drawing:drawing_napi_impl" ]
337    }
338    external_deps = [ "graphic_2d:drawing_napi_impl" ]
339    if (use_hilog) {
340      external_deps += [ "hilog:libhilog" ]
341    }
342    if (defined(config.xcomponent_components_support) &&
343        config.xcomponent_components_support) {
344      sources += [
345        "nativeModule/arkts_native_xcomponent_bridge.cpp",
346        "nativeModule/arkts_native_xcomponent_node_bridge.cpp",
347      ]
348      deps += [ "$ace_root/frameworks/core/components_ng/pattern/xcomponent:ace_core_components_xcomponent_pattern_ng_$platform" ]
349      if (is_ohos_standard_system) {
350        deps += [ "$ace_root/interfaces/inner_api/xcomponent_controller:ace_xcomponent_controller" ]
351        external_deps += [
352          "c_utils:utils",
353          "graphic_2d:librender_service_client",
354        ]
355      }
356    }
357
358    if (defined(config.model_component_support) &&
359        config.model_component_support) {
360      sources += [ "nativeModule/arkts_native_component3d_bridge.cpp" ]
361      deps += [ "$ace_root/frameworks/core/components_ng/pattern/model:ace_core_components_model_pattern_ng_$platform" ]
362    }
363
364    if (defined(config.form_components_support) &&
365        config.form_components_support) {
366      sources += [ "nativeModule/arkts_native_form_component_bridge.cpp" ]
367      deps += [ "${ace_root}/frameworks/core/components_ng/pattern/form:ace_core_components_form_pattern_ng_$platform" ]
368
369      if (is_ohos_standard_system) {
370        external_deps += [
371          "ability_base:want",
372          "ability_runtime:app_manager",
373          "bundle_framework:appexecfwk_core",
374          "form_fwk:fmskit_native",
375          "form_fwk:form_manager",
376          "graphic_2d:librender_service_client",
377          "input:libmmi-client",
378          "ipc:ipc_core",
379        ]
380      }
381    }
382
383    if (defined(config.plugin_components_support) &&
384        config.plugin_components_support) {
385      sources += [ "nativeModule/arkts_native_plugin_bridge.cpp" ]
386      deps += [
387        "${ace_root}/frameworks/core/components_ng/pattern/plugin:ace_core_components_plugin_pattern_ng_$platform",
388        "${ace_root}/interfaces/inner_api/ui_service_manager:ui_service_mgr",
389      ]
390      external_deps += [
391        "ability_base:want",
392        "ability_runtime:app_manager",
393        "bundle_framework:appexecfwk_core",
394        "c_utils:utils",
395        "graphic_2d:librender_service_client",
396        "ipc:ipc_core",
397      ]
398      if (os_account_exists) {
399        external_deps += [ "os_account:os_account_innerkits" ]
400      }
401    }
402
403    include_dirs = []
404    if (defined(vendor_configs.extra_view_register_sources)) {
405      include_dirs += vendor_configs.ace_advance_dirs
406      sources += vendor_configs.extra_view_register_sources
407    } else {
408      sources += [ "jsi_extra_view_register.cpp" ]
409    }
410
411    include_dirs += [ "${ace_root}/interfaces/inner_api/ace" ]
412
413    if (!is_arkui_x) {
414      deps +=
415          [ "${ace_root}/interfaces/inner_api/ace:ace_forward_compatibility" ]
416    }
417
418    if (platform == "ohos_ng" || is_arkui_x) {
419      sources += [
420        "jsi_animator_model_ng_build_impl.cpp",
421        "jsi_view_register_impl_ng.cpp",
422      ]
423      if (is_arkui_x) {
424        defines += [ "CROSS_PLATFORM" ]
425      }
426    } else {
427      sources += [
428        "jsi_animator_model_ng_impl.cpp",
429        "jsi_view_register_impl.cpp",
430      ]
431      deps += [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
432    }
433
434    # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported
435    if (is_arkui_x) {
436      configs += [ "$ark_ets_path:ark_jsruntime_public_config" ]
437      deps += [ "$ark_ets_path:libark_jsruntime_static" ]
438      public_deps = [ "//foundation/arkui/napi:ace_napi" ]
439      include_dirs += [ "//commonlibrary/c_utils/base/include" ]
440    } else {
441      external_deps += [
442        "ets_runtime:libark_jsruntime",
443        "napi:ace_napi",
444      ]
445    }
446
447    if (defined(config.build_for_preview) && config.build_for_preview) {
448      deps += [ ":gen_obj_src_abc_mock_system_plugin" ]
449      sources += [ "utils/jsi_module_searcher.cpp" ]
450      include_dirs += [ "//commonlibrary/c_utils/base/include/" ]
451    } else if (defined(config.use_build_in_js_engine) &&
452               config.use_build_in_js_engine) {
453      if (platform == "ohos_ng" || is_arkui_x) {
454        sources += [
455          "$ace_root/frameworks/bridge/js_frontend/engine/common/js_api_perf.cpp",
456          "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp",
457          "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp",
458          "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp",
459        ]
460      }
461    } else {
462      sources += [
463        "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp",
464        "$ace_root/frameworks/bridge/js_frontend/engine/jsi/ark_js_value.cpp",
465        "$ace_root/frameworks/bridge/js_frontend/engine/jsi/jsi_base_utils.cpp",
466      ]
467    }
468
469    deps += [
470      ":gen_obj_src_abc_ark_component",
471      ":gen_obj_src_abc_ark_theme",
472      ":gen_obj_src_abc_enum_style",
473      ":gen_obj_src_abc_proxyclass",
474    ]
475
476    if (is_arkui_x) {
477      deps += [ ":gen_obj_src_abc_uicontext" ]
478    } else {
479      deps += [ ":gen_obj_src_abc_preload" ]
480    }
481
482    foreach(item, abc_sources) {
483      deps += [ ":copy_" + item + "_abc" ]
484    }
485  }
486}
487
488foreach(item, ace_platforms) {
489  platform = item.name
490  engine_config = {
491  }
492  engine_config = item.config
493  support_engines = []
494  support_engines = engine_config.js_engines
495  foreach(engine, support_engines) {
496    if (engine.engine_name == "ark") {
497      declarative_js_engine_ark("declarative_js_engine_bridge_ark_$platform") {
498        defines = engine.engine_defines
499        config = {
500        }
501
502        if (defined(item.config)) {
503          config = item.config
504        }
505        if (defined(config.defines)) {
506          defines += config.defines
507        }
508      }
509    }
510  }
511}
512