1# Copyright (c) 2021-2022 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("//foundation/arkui/ace_engine/ace_config.gni")
16
17template("bridge_common") {
18  forward_variables_from(invoker, "*")
19
20  ohos_source_set(target_name) {
21    subsystem_name = ace_engine_subsystem
22    part_name = ace_engine_part
23    defines += invoker.defines
24
25    configs = [ "$ace_root:ace_config" ]
26
27    sources = [
28      # dom
29      "dom/dom_badge.cpp",
30      "dom/dom_button.cpp",
31      "dom/dom_calendar.cpp",
32      "dom/dom_canvas.cpp",
33      "dom/dom_chart.cpp",
34      "dom/dom_clock.cpp",
35      "dom/dom_dialog.cpp",
36      "dom/dom_div.cpp",
37      "dom/dom_divider.cpp",
38      "dom/dom_document.cpp",
39      "dom/dom_form.cpp",
40      "dom/dom_grid_column.cpp",
41      "dom/dom_grid_container.cpp",
42      "dom/dom_grid_row.cpp",
43      "dom/dom_image.cpp",
44      "dom/dom_image_animator.cpp",
45      "dom/dom_input.cpp",
46      "dom/dom_label.cpp",
47      "dom/dom_list.cpp",
48      "dom/dom_list_item.cpp",
49      "dom/dom_list_item_group.cpp",
50      "dom/dom_marquee.cpp",
51      "dom/dom_navigation_bar.cpp",
52      "dom/dom_node.cpp",
53      "dom/dom_panel.cpp",
54      "dom/dom_picker_base.cpp",
55      "dom/dom_picker_view.cpp",
56      "dom/dom_progress.cpp",
57      "dom/dom_proxy.cpp",
58      "dom/dom_qrcode.cpp",
59      "dom/dom_refresh.cpp",
60      "dom/dom_search.cpp",
61      "dom/dom_slider.cpp",
62      "dom/dom_span.cpp",
63      "dom/dom_stack.cpp",
64      "dom/dom_svg.cpp",
65      "dom/dom_svg_animate.cpp",
66      "dom/dom_svg_animate_motion.cpp",
67      "dom/dom_svg_animate_transform.cpp",
68      "dom/dom_svg_base.cpp",
69      "dom/dom_svg_circle.cpp",
70      "dom/dom_svg_defs.cpp",
71      "dom/dom_svg_ellipse.cpp",
72      "dom/dom_svg_fe_colormatrix.cpp",
73      "dom/dom_svg_fe_composite.cpp",
74      "dom/dom_svg_fe_gaussianblur.cpp",
75      "dom/dom_svg_fe_offset.cpp",
76      "dom/dom_svg_filter.cpp",
77      "dom/dom_svg_g.cpp",
78      "dom/dom_svg_line.cpp",
79      "dom/dom_svg_mask.cpp",
80      "dom/dom_svg_path.cpp",
81      "dom/dom_svg_polygon.cpp",
82      "dom/dom_svg_polyline.cpp",
83      "dom/dom_svg_rect.cpp",
84      "dom/dom_svg_text.cpp",
85      "dom/dom_svg_text_path.cpp",
86      "dom/dom_svg_tspan.cpp",
87      "dom/dom_svg_use.cpp",
88      "dom/dom_swiper.cpp",
89      "dom/dom_switch.cpp",
90      "dom/dom_tab_bar.cpp",
91      "dom/dom_tab_content.cpp",
92      "dom/dom_tabs.cpp",
93      "dom/dom_text.cpp",
94      "dom/dom_textarea.cpp",
95      "dom/dom_toggle.cpp",
96      "dom/dom_type.cpp",
97      "dom/input/dom_button_util.cpp",
98      "dom/input/dom_checkbox_util.cpp",
99      "dom/input/dom_radio_util.cpp",
100      "dom/input/dom_textfield_util.cpp",
101
102      # manifest
103      "manifest/manifest_appinfo.cpp",
104      "manifest/manifest_parser.cpp",
105      "manifest/manifest_router.cpp",
106      "manifest/manifest_widget.cpp",
107      "manifest/manifest_window.cpp",
108
109      # media query
110      "media_query/media_query_info.cpp",
111      "media_query/media_queryer.cpp",
112
113      # plugin adapter
114      "plugin_adapter/plugin_bridge.cpp",
115
116      # utils
117      "utils/engine_helper.cpp",
118      "utils/source_map.cpp",
119      "utils/transform_convertor.cpp",
120      "utils/utils.cpp",
121    ]
122
123    # rich components needed by phone and TV. wearable like watch do not need them
124    if (defined(config.rich_components_support) &&
125        config.rich_components_support) {
126      sources += [
127        "dom/dom_camera.cpp",
128        "dom/dom_menu.cpp",
129        "dom/dom_navigation_menu.cpp",
130        "dom/dom_option.cpp",
131        "dom/dom_picker_dialog.cpp",
132        "dom/dom_piece.cpp",
133        "dom/dom_popup.cpp",
134        "dom/dom_rating.cpp",
135        "dom/dom_select.cpp",
136        "dom/dom_stepper.cpp",
137        "dom/dom_stepper_item.cpp",
138        "dom/dom_tool_bar.cpp",
139        "dom/dom_tool_bar_item.cpp",
140        "dom/dom_video.cpp",
141      ]
142    }
143
144    # xcomponent components supports phone, TV and wearable except PC Preview
145    if (defined(config.xcomponent_components_support) &&
146        config.xcomponent_components_support) {
147      sources += [ "dom/dom_xcomponent.cpp" ]
148    }
149
150    # advance components using web or native plugins
151    if (defined(config.advance_components_support) &&
152        config.advance_components_support && !is_arkui_x) {
153      sources += [
154        "dom/dom_rich_text.cpp",
155        "dom/dom_web.cpp",
156      ]
157    }
158
159    if (defined(config.web_components_support) &&
160        config.web_components_support && !is_arkui_x) {
161      sources += [
162        "dom/dom_rich_text.cpp",
163        "dom/dom_web.cpp",
164      ]
165    }
166
167    deps = [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
168    if (use_hilog) {
169      external_deps = [ "hilog:libhilog" ]
170    }
171  }
172}
173
174template("bridge_common_ng") {
175  forward_variables_from(invoker, "*")
176
177  ohos_source_set(target_name) {
178    subsystem_name = ace_engine_subsystem
179    part_name = ace_engine_part
180    defines += invoker.defines
181
182    configs = [ "$ace_root:ace_config" ]
183
184    sources = [
185      # manifest
186      "dom/dom_type.cpp",
187      "manifest/manifest_appinfo.cpp",
188      "manifest/manifest_parser.cpp",
189      "manifest/manifest_router.cpp",
190      "manifest/manifest_widget.cpp",
191      "manifest/manifest_window.cpp",
192
193      # media query
194      "media_query/media_query_info.cpp",
195      "media_query/media_queryer.cpp",
196
197      # plugin adapter
198      "plugin_adapter/plugin_bridge.cpp",
199
200      # utils
201      "../js_frontend/engine/common/js_constants.cpp",
202      "../js_frontend/frontend_delegate.cpp",
203      "../js_frontend/js_ace_page.cpp",
204      "utils/engine_helper.cpp",
205      "utils/source_map.cpp",
206      "utils/utils.cpp",
207    ]
208
209    deps = [ "$ace_root/frameworks/core/components/theme:build_theme_code" ]
210    if (use_hilog) {
211      external_deps = [ "hilog:libhilog" ]
212    }
213  }
214}
215
216foreach(item, ace_platforms) {
217  bridge_common("bridge_common_" + item.name) {
218    defines = []
219    config = {
220    }
221
222    if (defined(item.config)) {
223      config = item.config
224    }
225
226    if (defined(config.defines)) {
227      defines = config.defines
228    }
229  }
230
231  bridge_common_ng("bridge_common_ng_" + item.name) {
232    defines = []
233    config = {
234    }
235
236    if (defined(item.config)) {
237      config = item.config
238    }
239
240    if (defined(config.defines)) {
241      defines = config.defines
242    }
243  }
244}
245