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/ohos.gni")
15import("//build/templates/abc/ohos_abc.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
20# declarative frontend source
21template("declarative_frontend") {
22  forward_variables_from(invoker, "*")
23  platform = invoker.platform
24
25  ohos_source_set(target_name) {
26    subsystem_name = ace_engine_subsystem
27    part_name = ace_engine_part
28    defines += invoker.defines
29    defines += [ "USE_ARK_ENGINE" ]
30    configs = [ "$ace_root:ace_config" ]
31
32    include_dirs =
33        [ "$ace_napi_frameworks/bridge/declarative_frontend/engine/jsi" ]
34    if (platform == "ohos_ng" || is_arkui_x) {
35      sources = [
36        "ng/declarative_frontend_ng.cpp",
37        "ng/frontend_delegate_declarative_ng.cpp",
38        "ng/page_router_manager.cpp",
39      ]
40    } else {
41      sources = [
42        "declarative_frontend.cpp",
43        "frontend_delegate_declarative.cpp",
44        "ng/page_router_manager.cpp",
45      ]
46    }
47
48    if (ace_engine_feature_enable_split_mode &&
49        defined(vendor_configs.ace_engine_advanced_split_mode_dirs)) {
50      include_dirs += vendor_configs.ace_engine_advanced_split_mode_dirs
51    }
52
53    if (ace_engine_feature_enable_split_mode &&
54        defined(vendor_configs.ace_engine_advanced_split_mode_bridge)) {
55      sources += vendor_configs.ace_engine_advanced_split_mode_bridge
56    } else {
57      sources += [ "ng/page_router_manager_factory.cpp" ]
58    }
59
60    deps = [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
61    if (is_arkui_x) {
62      deps += [
63        "//arkcompiler/ets_runtime:libark_jsruntime_static",
64        "//foundation/arkui/napi:ace_napi",
65      ]
66    }
67    external_deps = [
68      "ets_runtime:libark_jsruntime",
69      "napi:ace_napi",
70    ]
71    if (use_hilog) {
72      external_deps += [ "hilog:libhilog" ]
73    }
74  }
75}
76
77foreach(item, ace_platforms) {
78  platform = item.name
79  declarative_frontend("declarative_frontend_" + item.name) {
80    defines = []
81    config = {
82    }
83
84    if (defined(item.config)) {
85      config = item.config
86    }
87
88    if (defined(config.defines)) {
89      defines = config.defines
90    }
91  }
92}
93
94# js resources objects
95base_output_path = get_label_info(":gen_js_proxyclass", "target_out_dir")
96jsproxyclass_obj_path = base_output_path + "/js_proxy_class.o"
97jsenumstyle_obj_path = base_output_path + "/js_enum_style.o"
98jsmocksystemplugin_obj_path = base_output_path + "/js_mock_system_plugin.o"
99ark_theme_obj_path = base_output_path + "/arkTheme.o"
100jsuicontext_obj_path = base_output_path + "/jsUIContext.o"
101arkcomponent_obj_path = base_output_path + "/arkComponent.o"
102
103gen_obj("js_proxyclass") {
104  input = "engine/stateMgmt.js"
105  if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
106    jsproxyclass_obj_path = base_output_path + "/js_proxy_class.c"
107  }
108  output = jsproxyclass_obj_path
109  snapshot_dep = []
110}
111
112gen_obj("js_enum_style") {
113  input = "engine/jsEnumStyle.js"
114  if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
115    jsenumstyle_obj_path = base_output_path + "/js_enum_style.c"
116  }
117  output = jsenumstyle_obj_path
118  snapshot_dep = []
119}
120
121gen_obj("ark_theme") {
122  input = "engine/arkTheme.js"
123  if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
124    ark_theme_obj_path = base_output_path + "/ark_theme.c"
125  }
126  output = ark_theme_obj_path
127  snapshot_dep = []
128}
129
130gen_obj("ark_component") {
131  input = "engine/arkComponent.js"
132  if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
133    arkcomponent_obj_path = base_output_path + "/ark_component.c"
134  }
135  output = arkcomponent_obj_path
136  snapshot_dep = []
137}
138
139if (!is_arkui_x) {
140  gen_obj("js_mock_system_plugin") {
141    input = "$root_out_dir/obj/ide/tools/previewer/automock/dist/jsMockSystemPlugin.js"
142    if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
143      jsmocksystemplugin_obj_path =
144          base_output_path + "/js_mock_system_plugin.c"
145    }
146    output = jsmocksystemplugin_obj_path
147    snapshot_dep = [ "//ide/tools/previewer/automock:gen_snapshot_jsmock" ]
148  }
149}
150
151gen_obj("js_uicontext") {
152  input = "engine/jsUIContext.js"
153  if (use_mac || use_mingw_win || use_linux || target_os == "ios") {
154    jsuicontext_obj_path = base_output_path + "/jsUIContext.c"
155  }
156  output = jsuicontext_obj_path
157  snapshot_dep = []
158}
159
160# build declarative javascript engine source
161template("declarative_js_engine") {
162  forward_variables_from(invoker, "*")
163
164  ohos_source_set(target_name) {
165    subsystem_name = ace_engine_subsystem
166    part_name = ace_engine_part
167    defines += invoker.defines
168    if (target_cpu == "arm64") {
169      if (!is_mingw) {
170        defines += [ "_ARM64_" ]
171      }
172    }
173    if (current_os == "ohos" && current_cpu == "x86_64") {
174      defines += [ "SIMULATOR_64" ]
175    }
176
177    deps = [
178      ":ark_modifier",
179      ":ark_theme_control",
180      ":gen_obj_src_ark_component",
181      ":gen_obj_src_ark_theme",
182      ":gen_obj_src_js_enum_style",
183      ":gen_obj_src_js_proxyclass",
184      ":mock",
185      ":prefetcher",
186      ":statemanagement",
187      ":x_node",
188      "engine/$engine_path:declarative_js_engine_bridge_${engine_name}_$platform",
189    ]
190
191    if (!is_arkui_x) {
192      deps += [ ":uicontext" ]
193    } else {
194      deps += [ ":gen_obj_src_js_uicontext" ]
195    }
196
197    configs = [ "$ace_root:ace_config" ]
198    if (ace_engine_feature_enable_point_light) {
199      defines += [ "POINT_LIGHT_ENABLE" ]
200    }
201
202    sources = [
203      "engine/bindings_implementation.cpp",
204      "engine/declarative_engine_loader.cpp",
205      "engine/functions/js_animator_function.cpp",
206      "engine/functions/js_click_function.cpp",
207      "engine/functions/js_clipboard_function.cpp",
208      "engine/functions/js_drag_function.cpp",
209      "engine/functions/js_focus_function.cpp",
210      "engine/functions/js_foreach_function.cpp",
211      "engine/functions/js_function.cpp",
212      "engine/functions/js_gesture_function.cpp",
213      "engine/functions/js_gesture_judge_function.cpp",
214      "engine/functions/js_hover_function.cpp",
215      "engine/functions/js_key_function.cpp",
216      "engine/functions/js_mouse_function.cpp",
217      "engine/functions/js_navigation_function.cpp",
218      "engine/functions/js_on_area_change_function.cpp",
219      "engine/functions/js_on_child_touch_test_function.cpp",
220      "engine/functions/js_on_size_change_function.cpp",
221      "engine/functions/js_page_transition_function.cpp",
222      "engine/functions/js_pan_function.cpp",
223      "engine/functions/js_should_built_in_recognizer_parallel_with_function.cpp",
224      "engine/functions/js_swiper_function.cpp",
225      "engine/functions/js_tabs_function.cpp",
226      "engine/functions/js_touch_function.cpp",
227      "engine/functions/js_touch_intercept_function.cpp",
228      "engine/functions/js_webview_function.cpp",
229      "engine/js_types.cpp",
230      "interfaces/profiler/js_profiler.cpp",
231      "jsview/action_sheet/js_action_sheet.cpp",
232      "jsview/canvas/js_canvas.cpp",
233      "jsview/canvas/js_canvas_gradient.cpp",
234      "jsview/canvas/js_canvas_image_data.cpp",
235      "jsview/canvas/js_canvas_path.cpp",
236      "jsview/canvas/js_canvas_pattern.cpp",
237      "jsview/canvas/js_canvas_renderer.cpp",
238      "jsview/canvas/js_drawing_rendering_context.cpp",
239      "jsview/canvas/js_matrix2d.cpp",
240      "jsview/canvas/js_offscreen_canvas.cpp",
241      "jsview/canvas/js_offscreen_rendering_context.cpp",
242      "jsview/canvas/js_path2d.cpp",
243      "jsview/canvas/js_render_image.cpp",
244      "jsview/canvas/js_rendering_context.cpp",
245      "jsview/canvas/js_rendering_context_settings.cpp",
246      "jsview/dialog/js_alert_dialog.cpp",
247      "jsview/dialog/js_custom_dialog_controller.cpp",
248      "jsview/js_animator.cpp",
249      "jsview/js_badge.cpp",
250      "jsview/js_base_node.cpp",
251      "jsview/js_blank.cpp",
252      "jsview/js_button.cpp",
253      "jsview/js_calendar.cpp",
254      "jsview/js_calendar_controller.cpp",
255      "jsview/js_calendar_picker.cpp",
256      "jsview/js_checkbox.cpp",
257      "jsview/js_checkboxgroup.cpp",
258      "jsview/js_circle.cpp",
259      "jsview/js_circle_shape.cpp",
260      "jsview/js_clipboard.cpp",
261      "jsview/js_column.cpp",
262      "jsview/js_column_split.cpp",
263      "jsview/js_common_view.cpp",
264      "jsview/js_container_base.cpp",
265      "jsview/js_container_span.cpp",
266      "jsview/js_content_slot.cpp",
267      "jsview/js_counter.cpp",
268      "jsview/js_data_panel.cpp",
269      "jsview/js_datepicker.cpp",
270      "jsview/js_divider.cpp",
271      "jsview/js_dump_log.cpp",
272      "jsview/js_ellipse.cpp",
273      "jsview/js_ellipse_shape.cpp",
274      "jsview/js_environment.cpp",
275      "jsview/js_flex.cpp",
276      "jsview/js_flex_impl.cpp",
277      "jsview/js_folder_stack.cpp",
278      "jsview/js_foreach.cpp",
279      "jsview/js_form_link.cpp",
280      "jsview/js_gauge.cpp",
281      "jsview/js_gesture.cpp",
282      "jsview/js_grid.cpp",
283      "jsview/js_grid_col.cpp",
284      "jsview/js_grid_container.cpp",
285      "jsview/js_grid_item.cpp",
286      "jsview/js_grid_row.cpp",
287      "jsview/js_hyperlink.cpp",
288      "jsview/js_if_else.cpp",
289      "jsview/js_image.cpp",
290      "jsview/js_image_animator.cpp",
291      "jsview/js_image_span.cpp",
292      "jsview/js_indexer.cpp",
293      "jsview/js_interactable_view.cpp",
294      "jsview/js_keyboard_avoid.cpp",
295      "jsview/js_layout_manager.cpp",
296      "jsview/js_lazy_foreach.cpp",
297      "jsview/js_line.cpp",
298      "jsview/js_linear_gradient.cpp",
299      "jsview/js_list.cpp",
300      "jsview/js_list_item.cpp",
301      "jsview/js_list_item_group.cpp",
302      "jsview/js_loading_progress.cpp",
303      "jsview/js_local_storage.cpp",
304      "jsview/js_location_button.cpp",
305      "jsview/js_marquee.cpp",
306      "jsview/js_menu.cpp",
307      "jsview/js_menu_item.cpp",
308      "jsview/js_menu_item_group.cpp",
309      "jsview/js_mock.cpp",
310      "jsview/js_nav_path_stack.cpp",
311      "jsview/js_navdestination.cpp",
312      "jsview/js_navdestination_context.cpp",
313      "jsview/js_navdestination_scrollable_processor.cpp",
314      "jsview/js_navigation.cpp",
315      "jsview/js_navigation_stack.cpp",
316      "jsview/js_navigation_utils.cpp",
317      "jsview/js_navigator.cpp",
318      "jsview/js_navrouter.cpp",
319      "jsview/js_node_container.cpp",
320      "jsview/js_page_transition.cpp",
321      "jsview/js_pan_handler.cpp",
322      "jsview/js_particle.cpp",
323      "jsview/js_paste_button.cpp",
324      "jsview/js_path.cpp",
325      "jsview/js_path_shape.cpp",
326      "jsview/js_pattern_lock.cpp",
327      "jsview/js_persistent.cpp",
328      "jsview/js_polygon.cpp",
329      "jsview/js_polyline.cpp",
330      "jsview/js_progress.cpp",
331      "jsview/js_qrcode.cpp",
332      "jsview/js_radio.cpp",
333      "jsview/js_rect.cpp",
334      "jsview/js_rect_shape.cpp",
335      "jsview/js_recycle_view.cpp",
336      "jsview/js_refresh.cpp",
337      "jsview/js_relative_container.cpp",
338      "jsview/js_repeat.cpp",
339      "jsview/js_repeat_virtual_scroll.cpp",
340      "jsview/js_richeditor.cpp",
341      "jsview/js_row.cpp",
342      "jsview/js_row_split.cpp",
343      "jsview/js_save_button.cpp",
344      "jsview/js_scope_util.cpp",
345      "jsview/js_scroll.cpp",
346      "jsview/js_scrollable.cpp",
347      "jsview/js_scrollable_base.cpp",
348      "jsview/js_scroller.cpp",
349      "jsview/js_search.cpp",
350      "jsview/js_sec_button_base.cpp",
351      "jsview/js_select.cpp",
352      "jsview/js_shape.cpp",
353      "jsview/js_shape_abstract.cpp",
354      "jsview/js_sheet.cpp",
355      "jsview/js_side_bar.cpp",
356      "jsview/js_slider.cpp",
357      "jsview/js_sliding_panel.cpp",
358      "jsview/js_span.cpp",
359      "jsview/js_stack.cpp",
360      "jsview/js_state_mgmt_profiler.cpp",
361      "jsview/js_stepper.cpp",
362      "jsview/js_stepper_item.cpp",
363      "jsview/js_swiper.cpp",
364      "jsview/js_symbol.cpp",
365      "jsview/js_symbol_span.cpp",
366      "jsview/js_tab_content.cpp",
367      "jsview/js_tabs.cpp",
368      "jsview/js_tabs_controller.cpp",
369      "jsview/js_tabs_feature.cpp",
370      "jsview/js_text.cpp",
371      "jsview/js_text_clock.cpp",
372      "jsview/js_text_editable_controller.cpp",
373      "jsview/js_textarea.cpp",
374      "jsview/js_textfield.cpp",
375      "jsview/js_textinput.cpp",
376      "jsview/js_textpicker.cpp",
377      "jsview/js_texttimer.cpp",
378      "jsview/js_toggle.cpp",
379      "jsview/js_touch_handler.cpp",
380      "jsview/js_utils.cpp",
381      "jsview/js_view.cpp",
382      "jsview/js_view_abstract.cpp",
383      "jsview/js_view_context.cpp",
384      "jsview/js_view_functions.cpp",
385      "jsview/js_view_measure_layout.cpp",
386      "jsview/js_view_stack_processor.cpp",
387      "jsview/js_water_flow.cpp",
388      "jsview/js_water_flow_item.cpp",
389      "jsview/js_water_flow_sections.cpp",
390      "jsview/menu/js_context_menu.cpp",
391      "jsview/scroll_bar/js_scroll_bar.cpp",
392      "sharedata/js_share_data.cpp",
393      "style_string/js_span_object.cpp",
394      "style_string/js_span_string.cpp",
395      "view_stack_processor.cpp",
396
397      # ark_theme
398      "ark_theme/theme_apply/js_with_theme.cpp",
399
400      # Models implemenations for classic fw
401      "jsview/models/action_sheet_model_impl.cpp",
402      "jsview/models/alert_dialog_model_impl.cpp",
403      "jsview/models/animator_model_impl.cpp",
404      "jsview/models/badge_model_impl.cpp",
405      "jsview/models/blank_model_impl.cpp",
406      "jsview/models/button_model_impl.cpp",
407      "jsview/models/calendar_controller_model_impl.cpp",
408      "jsview/models/calendar_model_impl.cpp",
409      "jsview/models/canvas/canvas_model_impl.cpp",
410      "jsview/models/canvas/canvas_rendering_context_2d_model_impl.cpp",
411      "jsview/models/canvas/offscreen_canvas_rendering_context_2d_model_impl.cpp",
412      "jsview/models/checkbox_model_impl.cpp",
413      "jsview/models/checkboxgroup_model_impl.cpp",
414      "jsview/models/circle_model_impl.cpp",
415      "jsview/models/column_model_impl.cpp",
416      "jsview/models/common_view_model_impl.cpp",
417      "jsview/models/counter_model_impl.cpp",
418      "jsview/models/custom_dialog_controller_model_impl.cpp",
419      "jsview/models/data_panel_model_impl.cpp",
420      "jsview/models/divider_model_impl.cpp",
421      "jsview/models/ellipse_model_impl.cpp",
422      "jsview/models/flex_model_impl.cpp",
423      "jsview/models/for_each_model_impl.cpp",
424      "jsview/models/gauge_model_impl.cpp",
425      "jsview/models/gesture_model_impl.cpp",
426      "jsview/models/grid_col_model_impl.cpp",
427      "jsview/models/grid_container_model_impl.cpp",
428      "jsview/models/grid_item_model_impl.cpp",
429      "jsview/models/grid_model_impl.cpp",
430      "jsview/models/grid_row_model_impl.cpp",
431      "jsview/models/hyperlink_model_impl.cpp",
432      "jsview/models/if_else_model_impl.cpp",
433      "jsview/models/image_animator_model_impl.cpp",
434      "jsview/models/image_model_impl.cpp",
435      "jsview/models/indexer_model_impl.cpp",
436      "jsview/models/lazy_for_each_model_impl.cpp",
437      "jsview/models/line_model_impl.cpp",
438      "jsview/models/linear_split_model_impl.cpp",
439      "jsview/models/list_item_group_model_impl.cpp",
440      "jsview/models/list_item_model_impl.cpp",
441      "jsview/models/list_model_impl.cpp",
442      "jsview/models/loading_progress_model_impl.cpp",
443      "jsview/models/marquee_model_impl.cpp",
444      "jsview/models/menu_item_model_impl.cpp",
445      "jsview/models/menu_model_impl.cpp",
446      "jsview/models/navigation_model_impl.cpp",
447      "jsview/models/navigator_model_impl.cpp",
448      "jsview/models/page_transition_model_impl.cpp",
449      "jsview/models/path_model_impl.cpp",
450      "jsview/models/patternlock_model_impl.cpp",
451      "jsview/models/picker_model_impl.cpp",
452      "jsview/models/polygon_model_impl.cpp",
453      "jsview/models/progress_model_impl.cpp",
454      "jsview/models/qrcode_model_impl.cpp",
455      "jsview/models/radio_model_impl.cpp",
456      "jsview/models/rect_model_impl.cpp",
457      "jsview/models/refresh_model_impl.cpp",
458      "jsview/models/relative_container_model_impl.cpp",
459      "jsview/models/richeditor_model_impl.cpp",
460      "jsview/models/row_model_impl.cpp",
461      "jsview/models/scroll_bar_model_impl.cpp",
462      "jsview/models/scroll_model_impl.cpp",
463      "jsview/models/search_model_impl.cpp",
464      "jsview/models/select_model_impl.cpp",
465      "jsview/models/shape_abstract_model_impl.cpp",
466      "jsview/models/shape_model_impl.cpp",
467      "jsview/models/side_bar_container_model_impl.cpp",
468      "jsview/models/slider_model_impl.cpp",
469      "jsview/models/sliding_panel_model_impl.cpp",
470      "jsview/models/span_model_impl.cpp",
471      "jsview/models/stack_model_impl.cpp",
472      "jsview/models/stepper_item_model_impl.cpp",
473      "jsview/models/stepper_model_impl.cpp",
474      "jsview/models/swiper_model_impl.cpp",
475      "jsview/models/tab_content_model_impl.cpp",
476      "jsview/models/tabs_model_impl.cpp",
477      "jsview/models/text_clock_model_impl.cpp",
478      "jsview/models/text_field_model_impl.cpp",
479      "jsview/models/text_model_impl.cpp",
480      "jsview/models/text_timer_model_impl.cpp",
481      "jsview/models/textpicker_model_impl.cpp",
482      "jsview/models/timepicker_model_impl.cpp",
483      "jsview/models/toggle_model_impl.cpp",
484      "jsview/models/view_abstract_model_impl.cpp",
485      "jsview/models/view_context_model_impl.cpp",
486      "jsview/models/view_full_update_model_impl.cpp",
487      "jsview/models/view_partial_update_model_impl.cpp",
488      "jsview/models/water_flow_item_model_impl.cpp",
489      "jsview/models/water_flow_model_impl.cpp",
490    ]
491
492    external_deps = [ "graphic_2d:drawing_napi_impl" ]
493    if (use_hilog) {
494      external_deps += [ "hilog:libhilog" ]
495    }
496    if (defined(config.enable_drag_framework) && config.enable_drag_framework &&
497        defined(global_parts_info.distributeddatamgr_udmf)) {
498      external_deps += [
499        "udmf:udmf_client",
500        "udmf:udmf_data_napi",
501      ]
502    }
503
504    # rich components needed by phone and TV. wearable like watch do not need them
505    if (defined(config.rich_components_support) &&
506        config.rich_components_support) {
507      sources += [
508        "jsview/js_camera.cpp",
509        "jsview/js_piece.cpp",
510        "jsview/js_rating.cpp",
511        "jsview/models/rating_model_impl.cpp",
512      ]
513      if (defined(config.video_components_support) &&
514          config.video_components_support) {
515        sources += [
516          "jsview/js_video.cpp",
517          "jsview/js_video_controller.cpp",
518          "jsview/models/video_model_impl.cpp",
519        ]
520      }
521      if (defined(config.video_support_jsstack) &&
522          config.video_support_jsstack) {
523        external_deps += [ "hiview:libxpower_event_js" ]
524      }
525    }
526
527    include_dirs = []
528    if (defined(vendor_configs.ace_engine_advanced)) {
529      include_dirs += vendor_configs.ace_advance_dirs
530      sources += vendor_configs.ace_engine_advanced_jsview
531    } else {
532      sources += [ "jsview/js_cached_image.cpp" ]
533    }
534
535    if (defined(config.xcomponent_components_support) &&
536        config.xcomponent_components_support) {
537      sources += [
538        "jsview/js_xcomponent.cpp",
539        "jsview/js_xcomponent_controller.cpp",
540        "jsview/models/xcomponent_model_impl.cpp",
541      ]
542    }
543
544    if (defined(config.enable_ability_component) &&
545        config.enable_ability_component) {
546      sources += [
547        "jsview/js_ability_component.cpp",
548        "jsview/js_ability_component_controller.cpp",
549        "jsview/models/ability_component_model_impl.cpp",
550      ]
551
552      external_deps += [
553        "input:libmmi-client",
554        "window_manager:scene_session",
555      ]
556    }
557
558    if (defined(config.web_components_support) &&
559        config.web_components_support) {
560      if (is_arkui_x) {
561        sources += [
562          "jsview/js_web.cpp",
563          "jsview/models/web_model_impl.cpp",
564        ]
565      } else {
566        sources += [
567          "jsview/js_richtext.cpp",
568          "jsview/js_web.cpp",
569          "jsview/js_web_controller.cpp",
570          "jsview/models/richtext_model_impl.cpp",
571          "jsview/models/web_model_impl.cpp",
572        ]
573      }
574    }
575
576    if (defined(config.form_components_support) &&
577        config.form_components_support) {
578      sources += [
579        "jsview/js_form.cpp",
580        "jsview/js_form_menu_item.cpp",
581        "jsview/models/form_model_impl.cpp",
582      ]
583    }
584
585    if (defined(config.remote_window_support) && config.remote_window_support) {
586      sources += [
587        "jsview/js_remote_window.cpp",
588        "jsview/models/remote_window_model_impl.cpp",
589      ]
590    }
591
592    if (defined(config.effect_component_support) &&
593        config.effect_component_support) {
594      sources += [
595        "jsview/js_effect_component.cpp",
596        "jsview/models/effect_component_model_impl.cpp",
597      ]
598    }
599
600    if (defined(config.plugin_components_support) &&
601        config.plugin_components_support) {
602      sources += [
603        "jsview/js_plugin.cpp",
604        "jsview/models/plugin_model_impl.cpp",
605      ]
606    }
607
608    if (defined(config.preview_support) && config.preview_support) {
609      sources += [ "jsview/js_previewer_mock.cpp" ]
610    }
611
612    if (defined(config.model_component_support) &&
613        config.model_component_support) {
614      sources += [ "jsview/js_sceneview.cpp" ]
615      external_deps += [ "graphic_3d:3dWidgetAdapterInterface" ]
616    }
617
618    if (defined(config.use_build_in_js_engine) &&
619        config.use_build_in_js_engine) {
620      deps += [ "$ace_root/frameworks/bridge:framework_bridge_$platform" ]
621      defines += [ "BUILT_IN_JS_ENGINE" ]
622    } else {
623      sources += [
624        "$ace_root/frameworks/bridge/js_frontend/engine/common/js_engine.cpp",
625      ]
626      deps += [ "$ace_root/build:libace_compatible" ]
627      if (defined(config.build_container_scope_lib) &&
628          config.build_container_scope_lib) {
629        if (is_arkui_x) {
630          deps += [ "$ace_napi:ace_container_scope_static" ]
631        } else {
632          external_deps += [ "napi:ace_container_scope" ]
633        }
634      }
635    }
636
637    deps += [ ":shape" ]
638
639    # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported
640    if (is_arkui_x) {
641      configs += [ "$ark_ets_path:ark_jsruntime_public_config" ]
642      deps += [ "$ark_ets_path:libark_jsruntime_static" ]
643      if (defined(config.pixel_map_support) && config.pixel_map_support) {
644        configs += [ "//foundation/multimedia/image_framework/interfaces/innerkits:image_external_config" ]
645      }
646    } else {
647      external_deps += [
648        "ets_runtime:libark_jsruntime",
649        "napi:ace_napi",
650      ]
651    }
652
653    if (platform == "windows" || platform == "mac" || platform == "linux") {
654      deps += [ ":gen_obj_src_js_mock_system_plugin" ]
655    } else {
656      if (defined(config.plugin_components_support) &&
657          config.plugin_components_support) {
658        if (!use_mingw_win && !use_mac && !use_linux) {
659          external_deps += [
660            "image_framework:image",
661            "image_framework:image_native",
662          ]
663        }
664      } else {
665        external_deps += [
666          "image_framework:image",
667          "image_framework:image_native",
668        ]
669      }
670
671      if (defined(config.window_scene_support) && config.window_scene_support) {
672        sources += [
673          "jsview/js_embedded_component.cpp",
674          "jsview/js_security_ui_extension.cpp",
675          "jsview/js_ui_extension.cpp",
676          "jsview/window_scene/js_root_scene.cpp",
677          "jsview/window_scene/js_screen.cpp",
678          "jsview/window_scene/js_window_scene.cpp",
679        ]
680
681        if (defined(config.dynamic_component_support) &&
682            config.dynamic_component_support && !build_ohos_sdk) {
683          external_deps += [ "ets_utils:worker" ]
684          sources += [
685            "jsview/js_dynamic_component.cpp",
686            "jsview/js_isolated_component.cpp",
687          ]
688        }
689      }
690    }
691  }
692}
693
694# build ng declarative javascript engine source
695template("declarative_js_engine_ng") {
696  forward_variables_from(invoker, "*")
697
698  ohos_source_set(target_name) {
699    subsystem_name = ace_engine_subsystem
700    part_name = ace_engine_part
701    defines += invoker.defines
702    if (target_cpu == "arm64") {
703      if (!is_mingw) {
704        defines += [ "_ARM64_" ]
705      }
706    }
707    if (current_os == "ohos" && current_cpu == "x86_64") {
708      defines += [ "SIMULATOR_64" ]
709    }
710
711    deps = [
712      ":ark_modifier",
713      ":ark_theme_control",
714      ":gen_obj_src_ark_component",
715      ":gen_obj_src_ark_theme",
716      ":gen_obj_src_js_enum_style",
717      ":gen_obj_src_js_proxyclass",
718      ":mock",
719      ":prefetcher",
720      ":statemanagement",
721      ":x_node",
722      "engine/$engine_path:declarative_js_engine_bridge_${engine_name}_$platform",
723    ]
724
725    if (!is_arkui_x) {
726      deps += [ ":uicontext" ]
727    } else {
728      deps += [ ":gen_obj_src_js_uicontext" ]
729    }
730
731    configs = [ "$ace_root:ace_config" ]
732
733    sources = [
734      "engine/bindings_implementation.cpp",
735      "engine/declarative_engine_loader.cpp",
736      "engine/functions/js_animator_function.cpp",
737      "engine/functions/js_click_function.cpp",
738      "engine/functions/js_clipboard_function.cpp",
739      "engine/functions/js_drag_function.cpp",
740      "engine/functions/js_focus_function.cpp",
741      "engine/functions/js_foreach_function.cpp",
742      "engine/functions/js_function.cpp",
743      "engine/functions/js_gesture_function.cpp",
744      "engine/functions/js_gesture_judge_function.cpp",
745      "engine/functions/js_hover_function.cpp",
746      "engine/functions/js_key_function.cpp",
747      "engine/functions/js_mouse_function.cpp",
748      "engine/functions/js_navigation_function.cpp",
749      "engine/functions/js_on_area_change_function.cpp",
750      "engine/functions/js_on_child_touch_test_function.cpp",
751      "engine/functions/js_on_size_change_function.cpp",
752      "engine/functions/js_page_transition_function.cpp",
753      "engine/functions/js_pan_function.cpp",
754      "engine/functions/js_should_built_in_recognizer_parallel_with_function.cpp",
755      "engine/functions/js_swiper_function.cpp",
756      "engine/functions/js_tabs_function.cpp",
757      "engine/functions/js_touch_function.cpp",
758      "engine/functions/js_touch_intercept_function.cpp",
759      "engine/functions/js_webview_function.cpp",
760      "engine/js_types.cpp",
761      "jsview/js_dump_log.cpp",
762      "jsview/js_environment.cpp",
763      "jsview/js_local_storage.cpp",
764      "jsview/js_persistent.cpp",
765      "jsview/js_state_mgmt_profiler.cpp",
766      "jsview/js_view_functions.cpp",
767      "jsview/js_view_measure_layout.cpp",
768      "jsview/js_view_stack_processor.cpp",
769      "sharedata/js_share_data.cpp",
770      "view_stack_processor.cpp",
771
772      # jsviews
773      "interfaces/profiler/js_profiler.cpp",
774      "jsview/action_sheet/js_action_sheet.cpp",
775      "jsview/canvas/js_canvas.cpp",
776      "jsview/canvas/js_canvas_gradient.cpp",
777      "jsview/canvas/js_canvas_image_data.cpp",
778      "jsview/canvas/js_canvas_path.cpp",
779      "jsview/canvas/js_canvas_pattern.cpp",
780      "jsview/canvas/js_canvas_renderer.cpp",
781      "jsview/canvas/js_drawing_rendering_context.cpp",
782      "jsview/canvas/js_matrix2d.cpp",
783      "jsview/canvas/js_offscreen_canvas.cpp",
784      "jsview/canvas/js_offscreen_rendering_context.cpp",
785      "jsview/canvas/js_path2d.cpp",
786      "jsview/canvas/js_render_image.cpp",
787      "jsview/canvas/js_rendering_context.cpp",
788      "jsview/canvas/js_rendering_context_settings.cpp",
789      "jsview/dialog/js_alert_dialog.cpp",
790      "jsview/dialog/js_custom_dialog_controller.cpp",
791      "jsview/js_animator.cpp",
792      "jsview/js_badge.cpp",
793      "jsview/js_base_node.cpp",
794      "jsview/js_blank.cpp",
795      "jsview/js_button.cpp",
796      "jsview/js_calendar.cpp",
797      "jsview/js_calendar_controller.cpp",
798      "jsview/js_calendar_picker.cpp",
799      "jsview/js_checkbox.cpp",
800      "jsview/js_checkboxgroup.cpp",
801      "jsview/js_circle.cpp",
802      "jsview/js_circle_shape.cpp",
803      "jsview/js_clipboard.cpp",
804      "jsview/js_column.cpp",
805      "jsview/js_column_split.cpp",
806      "jsview/js_common_view.cpp",
807      "jsview/js_container_base.cpp",
808      "jsview/js_container_span.cpp",
809      "jsview/js_content_slot.cpp",
810      "jsview/js_counter.cpp",
811      "jsview/js_data_panel.cpp",
812      "jsview/js_datepicker.cpp",
813      "jsview/js_divider.cpp",
814      "jsview/js_ellipse.cpp",
815      "jsview/js_ellipse_shape.cpp",
816      "jsview/js_flex.cpp",
817      "jsview/js_flex_impl.cpp",
818      "jsview/js_folder_stack.cpp",
819      "jsview/js_foreach.cpp",
820      "jsview/js_form_link.cpp",
821      "jsview/js_gauge.cpp",
822      "jsview/js_gesture.cpp",
823      "jsview/js_grid.cpp",
824      "jsview/js_grid_col.cpp",
825      "jsview/js_grid_container.cpp",
826      "jsview/js_grid_item.cpp",
827      "jsview/js_grid_row.cpp",
828      "jsview/js_hyperlink.cpp",
829      "jsview/js_if_else.cpp",
830      "jsview/js_image.cpp",
831      "jsview/js_image_animator.cpp",
832      "jsview/js_image_span.cpp",
833      "jsview/js_indexer.cpp",
834      "jsview/js_interactable_view.cpp",
835      "jsview/js_keyboard_avoid.cpp",
836      "jsview/js_layout_manager.cpp",
837      "jsview/js_lazy_foreach.cpp",
838      "jsview/js_line.cpp",
839      "jsview/js_linear_gradient.cpp",
840      "jsview/js_list.cpp",
841      "jsview/js_list_item.cpp",
842      "jsview/js_list_item_group.cpp",
843      "jsview/js_loading_progress.cpp",
844      "jsview/js_location_button.cpp",
845      "jsview/js_marquee.cpp",
846      "jsview/js_menu.cpp",
847      "jsview/js_menu_item.cpp",
848      "jsview/js_menu_item_group.cpp",
849      "jsview/js_mock.cpp",
850      "jsview/js_nav_path_stack.cpp",
851      "jsview/js_navdestination.cpp",
852      "jsview/js_navdestination_context.cpp",
853      "jsview/js_navdestination_scrollable_processor.cpp",
854      "jsview/js_navigation.cpp",
855      "jsview/js_navigation_stack.cpp",
856      "jsview/js_navigation_utils.cpp",
857      "jsview/js_navigator.cpp",
858      "jsview/js_navrouter.cpp",
859      "jsview/js_node_container.cpp",
860      "jsview/js_page_transition.cpp",
861      "jsview/js_paste_button.cpp",
862      "jsview/js_path.cpp",
863      "jsview/js_path_shape.cpp",
864      "jsview/js_polygon.cpp",
865      "jsview/js_polyline.cpp",
866      "jsview/js_progress.cpp",
867      "jsview/js_radio.cpp",
868      "jsview/js_rating.cpp",
869      "jsview/js_rect.cpp",
870      "jsview/js_rect_shape.cpp",
871      "jsview/js_recycle_view.cpp",
872      "jsview/js_refresh.cpp",
873      "jsview/js_repeat.cpp",
874      "jsview/js_repeat_virtual_scroll.cpp",
875      "jsview/js_richeditor.cpp",
876      "jsview/js_row.cpp",
877      "jsview/js_row_split.cpp",
878      "jsview/js_save_button.cpp",
879      "jsview/js_scope_util.cpp",
880      "jsview/js_scroll.cpp",
881      "jsview/js_scrollable.cpp",
882      "jsview/js_scrollable_base.cpp",
883      "jsview/js_scroller.cpp",
884      "jsview/js_search.cpp",
885      "jsview/js_sec_button_base.cpp",
886      "jsview/js_select.cpp",
887      "jsview/js_shape.cpp",
888      "jsview/js_shape_abstract.cpp",
889      "jsview/js_side_bar.cpp",
890      "jsview/js_slider.cpp",
891      "jsview/js_sliding_panel.cpp",
892      "jsview/js_span.cpp",
893      "jsview/js_stack.cpp",
894      "jsview/js_stepper.cpp",
895      "jsview/js_stepper_item.cpp",
896      "jsview/js_swiper.cpp",
897      "jsview/js_symbol.cpp",
898      "jsview/js_symbol_span.cpp",
899      "jsview/js_tab_content.cpp",
900      "jsview/js_tabs.cpp",
901      "jsview/js_tabs_controller.cpp",
902      "jsview/js_tabs_feature.cpp",
903      "jsview/js_text.cpp",
904      "jsview/js_text_clock.cpp",
905      "jsview/js_text_editable_controller.cpp",
906      "jsview/js_textarea.cpp",
907      "jsview/js_textfield.cpp",
908      "jsview/js_textinput.cpp",
909      "jsview/js_textpicker.cpp",
910      "jsview/js_texttimer.cpp",
911      "jsview/js_toggle.cpp",
912      "jsview/js_utils.cpp",
913      "jsview/js_view.cpp",
914      "jsview/js_view_abstract.cpp",
915      "jsview/js_view_context.cpp",
916      "jsview/js_water_flow.cpp",
917      "jsview/js_water_flow_item.cpp",
918      "jsview/js_water_flow_sections.cpp",
919      "jsview/menu/js_context_menu.cpp",
920      "jsview/scroll_bar/js_scroll_bar.cpp",
921      "style_string/js_span_object.cpp",
922      "style_string/js_span_string.cpp",
923
924      # ark_theme
925      "ark_theme/theme_apply/js_with_theme.cpp",
926    ]
927
928    sources += [
929      "$ace_root/frameworks/bridge/js_frontend/engine/common/js_engine.cpp",
930    ]
931
932    external_deps = [ "graphic_2d:drawing_napi_impl" ]
933    if (use_hilog) {
934      external_deps += [ "hilog:libhilog" ]
935    }
936
937    if (!defined(config.use_components_lib) || !config.use_components_lib) {
938      sources += [
939        "jsview/js_pattern_lock.cpp",
940        "jsview/js_qrcode.cpp",
941        "jsview/js_relative_container.cpp",
942      ]
943    }
944
945    if (defined(config.video_components_support) &&
946        config.video_components_support) {
947      sources += [
948        "jsview/js_video.cpp",
949        "jsview/js_video_controller.cpp",
950      ]
951      if (defined(config.video_support_jsstack) &&
952          config.video_support_jsstack) {
953        external_deps += [ "hiview:libxpower_event_js" ]
954      }
955    }
956
957    if (defined(config.window_scene_support) && config.window_scene_support) {
958      sources += [
959        "jsview/js_embedded_component.cpp",
960        "jsview/js_security_ui_extension.cpp",
961        "jsview/js_ui_extension.cpp",
962        "jsview/window_scene/js_root_scene.cpp",
963        "jsview/window_scene/js_screen.cpp",
964        "jsview/window_scene/js_window_scene.cpp",
965      ]
966
967      if (defined(config.dynamic_component_support) &&
968          config.dynamic_component_support && !build_ohos_sdk) {
969        external_deps += [ "ets_utils:worker" ]
970
971        sources += [
972          "jsview/js_dynamic_component.cpp",
973          "jsview/js_isolated_component.cpp",
974        ]
975      }
976    }
977
978    if (defined(config.enable_ability_component) &&
979        config.enable_ability_component) {
980      sources += [
981        "jsview/js_ability_component.cpp",
982        "jsview/js_ability_component_controller.cpp",
983      ]
984
985      external_deps += [
986        "input:libmmi-client",
987        "window_manager:scene_session",
988      ]
989    }
990
991    if (defined(config.form_components_support) &&
992        config.form_components_support) {
993      sources += [ "jsview/js_form.cpp" ]
994    }
995
996    if (defined(config.plugin_components_support) &&
997        config.plugin_components_support) {
998      sources += [ "jsview/js_plugin.cpp" ]
999    }
1000
1001    if (defined(config.web_components_support) &&
1002        config.web_components_support) {
1003      sources += [
1004        "jsview/js_richtext.cpp",
1005        "jsview/js_web.cpp",
1006        "jsview/js_web_controller.cpp",
1007      ]
1008    }
1009
1010    if (defined(config.remote_window_support) && config.remote_window_support) {
1011      sources += [ "jsview/js_remote_window.cpp" ]
1012    }
1013
1014    if (!defined(vendor_configs.ace_engine_advanced)) {
1015      sources += [ "jsview/js_cached_image.cpp" ]
1016    }
1017
1018    if (defined(config.xcomponent_components_support) &&
1019        config.xcomponent_components_support) {
1020      sources += [
1021        "jsview/js_xcomponent.cpp",
1022        "jsview/js_xcomponent_controller.cpp",
1023      ]
1024    }
1025
1026    if (defined(config.effect_component_support) &&
1027        config.effect_component_support) {
1028      sources += [
1029        "jsview/js_effect_component.cpp",
1030        #"jsview/models/effect_component_model_impl.cpp",
1031      ]
1032    }
1033
1034    if (defined(config.model_component_support) &&
1035        config.model_component_support) {
1036      sources += [ "jsview/js_sceneview.cpp" ]
1037      external_deps += [ "graphic_3d:3dWidgetAdapterInterface" ]
1038    }
1039
1040    if (defined(config.use_build_in_js_engine) &&
1041        config.use_build_in_js_engine) {
1042      deps += [ "$ace_root/frameworks/bridge:framework_bridge_ng_$platform" ]
1043      defines += [ "BUILT_IN_JS_ENGINE" ]
1044    } else {
1045      if (is_asan || !ace_engine_feature_enable_libace) {
1046        deps += [ "$ace_root/build:libace_compatible" ]
1047      } else {
1048        deps += [ "$ace_root/build:libace" ]
1049      }
1050      if (defined(config.build_container_scope_lib) &&
1051          config.build_container_scope_lib) {
1052        external_deps += [ "napi:ace_container_scope" ]
1053      }
1054    }
1055    include_dirs = []
1056
1057    # add for cross_platfrom_build temporarily, shall be removed after external_deps is supported
1058    if (is_arkui_x) {
1059      sources -= [
1060        "interfaces/profiler/js_profiler.cpp",
1061        "jsview/js_location_button.cpp",
1062        "jsview/js_paste_button.cpp",
1063        "jsview/js_save_button.cpp",
1064        "jsview/js_sec_button_base.cpp",
1065        "jsview/menu/js_context_menu.cpp",
1066      ]
1067      include_dirs += [ "//commonlibrary/c_utils/base/include" ]
1068      configs += [ "$ark_ets_path:ark_jsruntime_public_config" ]
1069      deps += [
1070        "$ark_ets_path:libark_jsruntime_static",
1071        "//foundation/graphic/graphic_2d/interfaces/kits/napi/graphic/drawing:drawing_napi_impl",
1072      ]
1073      if (defined(config.pixel_map_support) && config.pixel_map_support) {
1074        configs += [ "//foundation/multimedia/image_framework/interfaces/innerkits:image_external_config" ]
1075      }
1076    } else {
1077      external_deps += [
1078        "ets_runtime:libark_jsruntime",
1079        "napi:ace_napi",
1080      ]
1081    }
1082
1083    deps += [ ":shape" ]
1084
1085    if (defined(config.enable_drag_framework) && config.enable_drag_framework &&
1086        defined(global_parts_info.distributeddatamgr_udmf)) {
1087      external_deps += [
1088        "udmf:udmf_client",
1089        "udmf:udmf_data_napi",
1090      ]
1091    }
1092
1093    if (!use_mingw_win && !use_mac && !use_linux) {
1094      external_deps += [
1095        "image_framework:image",
1096        "image_framework:image_native",
1097      ]
1098    }
1099  }
1100}
1101
1102# dynamic generate js_engine targets
1103foreach(item, ace_platforms) {
1104  platform = item.name
1105  engine_config = {
1106  }
1107  engine_config = item.config
1108  support_engines = []
1109  support_engines = engine_config.js_engines
1110  foreach(engine, support_engines) {
1111    declarative_js_engine(
1112        "declarative_js_engine_${engine.engine_name}_$platform") {
1113      platform = item.name
1114      engine_name = engine.engine_name
1115      engine_path = engine.engine_path
1116      defines = engine.engine_defines
1117
1118      config = {
1119      }
1120      if (defined(item.config)) {
1121        config = item.config
1122      }
1123      if (defined(config.defines)) {
1124        defines += config.defines
1125      }
1126    }
1127
1128    declarative_js_engine_ng(
1129        "declarative_js_engine_ng_${engine.engine_name}_$platform") {
1130      platform = item.name
1131      engine_name = engine.engine_name
1132      engine_path = engine.engine_path
1133      defines = engine.engine_defines
1134
1135      config = {
1136      }
1137      if (defined(item.config)) {
1138        config = item.config
1139      }
1140      if (defined(config.defines)) {
1141        defines += config.defines
1142      }
1143    }
1144  }
1145}
1146
1147ohos_abc("statemanagement") {
1148  sources = [ "engine/jsStateManagement.js" ]
1149  output_name = "statemanagement"
1150  install_images = [ "system" ]
1151  module_install_dir = "etc/abc/arkui"
1152  subsystem_name = ace_engine_subsystem
1153  part_name = ace_engine_part
1154}
1155
1156ohos_abc("mock") {
1157  sources = [ "engine/jsMock.js" ]
1158  output_name = "mock"
1159  install_images = [ "system" ]
1160  module_install_dir = "etc/abc/arkui"
1161  subsystem_name = ace_engine_subsystem
1162  part_name = ace_engine_part
1163}
1164
1165ohos_abc("x_node") {
1166  sources = [ "engine/jsXNode.js" ]
1167  output_name = "node"
1168  install_images = [ "system" ]
1169  module_install_dir = "etc/abc/arkui"
1170  subsystem_name = ace_engine_subsystem
1171  part_name = ace_engine_part
1172}
1173
1174ohos_abc("prefetcher") {
1175  sources = [ "engine/jsPrefetcher.js" ]
1176  output_name = "prefetcher"
1177  install_images = [ "system" ]
1178  module_install_dir = "etc/abc/arkui"
1179  subsystem_name = ace_engine_subsystem
1180  part_name = ace_engine_part
1181}
1182
1183action("gen_uicontext_ohos") {
1184  script = "$ace_root/build/tools/gen_uicontext_ohos.py"
1185  inputs = [
1186    "$ace_root/frameworks/bridge/declarative_frontend/engine/jsUIContext.js",
1187  ]
1188  outputs = [ "$base_output_path/jsUIContext_ohos.js" ]
1189  args = [
1190    rebase_path(inputs[0]),
1191    rebase_path(outputs[0]),
1192  ]
1193}
1194
1195ohos_abc("uicontext") {
1196  sources = [ "$base_output_path/jsUIContext_ohos.js" ]
1197  output_name = "uicontext"
1198  deps = [ ":gen_uicontext_ohos" ]
1199  install_images = [ "system" ]
1200  module_install_dir = "etc/abc/arkui"
1201  subsystem_name = ace_engine_subsystem
1202  part_name = ace_engine_part
1203}
1204
1205ohos_abc("ark_theme_control") {
1206  sources = [ "engine/arkThemeControl.js" ]
1207  output_name = "theme"
1208  install_images = [ "system" ]
1209  module_install_dir = "etc/abc/arkui"
1210  subsystem_name = ace_engine_subsystem
1211  part_name = ace_engine_part
1212}
1213
1214ohos_abc("ark_modifier") {
1215  sources = [ "engine/arkModifier.js" ]
1216  output_name = "modifier"
1217  install_images = [ "system" ]
1218  module_install_dir = "etc/abc/arkui"
1219  subsystem_name = ace_engine_subsystem
1220  part_name = ace_engine_part
1221}
1222
1223ohos_abc("shape") {
1224  sources = [ "engine/jsShape.js" ]
1225  output_name = "shape"
1226  install_images = [ "system" ]
1227  module_install_dir = "etc/abc/arkui"
1228  subsystem_name = ace_engine_subsystem
1229  part_name = ace_engine_part
1230}
1231