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