1# Copyright (c) 2020-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#     http://www.apache.org/licenses/LICENSE-2.0
6# Unless required by applicable law or agreed to in writing, software
7# distributed under the License is distributed on an "AS IS" BASIS,
8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9# See the License for the specific language governing permissions and
10# limitations under the License.
11
12if (os_level != "standard") {
13  defines = []
14  import("//build/lite/config/component/lite_component.gni")
15  import("//build/lite/config/subsystem/graphic/config.gni")
16  import("//build/lite/ndk/ndk.gni")
17
18  lite_component("ui_lite") {
19    features = [ ":ui" ]
20    public_deps = features
21  }
22
23  config("graphic_define_config") {
24    include_dirs = [
25      "interfaces/kits",
26      "interfaces/innerkits",
27    ]
28    defines += [
29      "GRAPHIC_ENABLE_ELLIPSE_FLAG=1",
30      "GRAPHIC_ENABLE_BEZIER_ARC_FLAG=1",
31      "GRAPHIC_ENABLE_LINECAP_FLAG=1",
32      "GRAPHIC_ENABLE_LINEJOIN_FLAG=1",
33      "GRAPHIC_ENABLE_ARC_FLAG=1",
34      "GRAPHIC_ENABLE_ROUNDEDRECT_FLAG=1",
35      "GRAPHIC_ENABLE_GRADIENT_FILL_FLAG=1",
36      "GRAPHIC_ENABLE_SHADOW_EFFECT_FLAG=1",
37      "GRAPHIC_ENABLE_DRAW_TEXT_FLAG=1",
38    ]
39    if (defined(board_toolchain_type) && board_toolchain_type == "iccarm") {
40      cflags = [
41        "--diag_suppress",
42        "Pa084,Pa093,Pa137,Pe161,Pe177,Pe186,Pe223,Pe226,Pe366,Pe367,Pe550,Pe940,Pe068",
43      ]
44      cflags_cc = cflags
45    }
46    if (ohos_kernel_type != "liteos_m") {
47      defines += [
48        "ENABLE_VECTOR_FONT=1",
49        "ENABLE_BITMAP_FONT=0",
50        "ENABLE_SHAPING=0",
51        "ENABLE_ICU=1",
52        "ENABLE_MULTI_FONT=1",
53        "DEFAULT_ANIMATION=1",
54      ]
55      if (ohos_kernel_type == "linux") {
56        defines += [ "RESOURCE_DIR=\"/storage/data/\"" ]
57      } else {
58        defines += [ "RESOURCE_DIR=\"/user/data/\"" ]
59      }
60    }
61
62    if (ohos_kernel_type == "liteos_a") {
63      defines += [
64        "GRAPHIC_ENABLE_DASH_GENERATE_FLAG=1",
65        "GRAPHIC_ENABLE_BLUR_EFFECT_FLAG=1",
66        "GRAPHIC_ENABLE_PATTERN_FILL_FLAG=1",
67        "GRAPHIC_ENABLE_DRAW_IMAGE_FLAG=1",
68      ]
69    } else if (ohos_kernel_type == "liteos_m") {
70      include_dirs += [ "//third_party/freetype/include" ]
71      if (enable_canvas_extend) {
72        defines += [ "ENABLE_CANVAS_EXTEND=1" ]
73      } else {
74        defines += [ "ENABLE_CANVAS_EXTEND=0" ]
75      }
76      defines += [
77        "GRAPHIC_ENABLE_DASH_GENERATE_FLAG=1",
78        "GRAPHIC_ENABLE_BLUR_EFFECT_FLAG=1",
79        "GRAPHIC_ENABLE_PATTERN_FILL_FLAG=1",
80        "GRAPHIC_ENABLE_DRAW_IMAGE_FLAG=1",
81      ]
82    } else {
83      defines += [
84        "GRAPHIC_ENABLE_DASH_GENERATE_FLAG=1",
85        "GRAPHIC_ENABLE_BLUR_EFFECT_FLAG=1",
86        "GRAPHIC_ENABLE_PATTERN_FILL_FLAG=1",
87        "GRAPHIC_ENABLE_DRAW_IMAGE_FLAG=1",
88      ]
89    }
90  }
91
92  if (enable_graphic_font) {
93    copy("utils_config") {
94      sources = [
95        "tools/qt/simulator/font/SourceHanSansSC-Regular.otf",
96        "tools/qt/simulator/font/line_cj.brk",
97      ]
98      outputs = [ "$root_out_dir/data/{{source_file_part}}" ]
99    }
100  }
101
102  lite_library("ui") {
103    sources = [
104      "frameworks/animator/animator.cpp",
105      "frameworks/animator/animator_manager.cpp",
106      "frameworks/animator/easing_equation.cpp",
107      "frameworks/animator/interpolation.cpp",
108      "frameworks/common/graphic_startup.cpp",
109      "frameworks/common/image.cpp",
110      "frameworks/common/image_decode_ability.cpp",
111      "frameworks/common/input_device_manager.cpp",
112      "frameworks/common/screen.cpp",
113      "frameworks/common/spannable_string.cpp",
114      "frameworks/common/task.cpp",
115      "frameworks/common/text.cpp",
116      "frameworks/common/typed_text.cpp",
117      "frameworks/components/root_view.cpp",
118      "frameworks/components/text_adapter.cpp",
119      "frameworks/components/ui_abstract_clock.cpp",
120      "frameworks/components/ui_abstract_progress.cpp",
121      "frameworks/components/ui_abstract_scroll.cpp",
122      "frameworks/components/ui_abstract_scroll_bar.cpp",
123      "frameworks/components/ui_analog_clock.cpp",
124      "frameworks/components/ui_arc_label.cpp",
125      "frameworks/components/ui_arc_scroll_bar.cpp",
126      "frameworks/components/ui_axis.cpp",
127      "frameworks/components/ui_box_progress.cpp",
128      "frameworks/components/ui_box_scroll_bar.cpp",
129      "frameworks/components/ui_button.cpp",
130      "frameworks/components/ui_canvas.cpp",
131      "frameworks/components/ui_chart.cpp",
132      "frameworks/components/ui_checkbox.cpp",
133      "frameworks/components/ui_circle_progress.cpp",
134      "frameworks/components/ui_dialog.cpp",
135      "frameworks/components/ui_digital_clock.cpp",
136      "frameworks/components/ui_edit_text.cpp",
137      "frameworks/components/ui_extend_image_view.cpp",
138      "frameworks/components/ui_image_animator.cpp",
139      "frameworks/components/ui_image_view.cpp",
140      "frameworks/components/ui_label.cpp",
141      "frameworks/components/ui_label_button.cpp",
142      "frameworks/components/ui_list.cpp",
143      "frameworks/components/ui_picker.cpp",
144      "frameworks/components/ui_qrcode.cpp",
145      "frameworks/components/ui_radio_button.cpp",
146      "frameworks/components/ui_repeat_button.cpp",
147      "frameworks/components/ui_scroll_view.cpp",
148      "frameworks/components/ui_slider.cpp",
149      "frameworks/components/ui_surface_view.cpp",
150      "frameworks/components/ui_swipe_view.cpp",
151      "frameworks/components/ui_texture_mapper.cpp",
152      "frameworks/components/ui_time_picker.cpp",
153      "frameworks/components/ui_toggle_button.cpp",
154      "frameworks/components/ui_tree_manager.cpp",
155      "frameworks/components/ui_view.cpp",
156      "frameworks/components/ui_view_group.cpp",
157      "frameworks/core/input_method_manager.cpp",
158      "frameworks/core/render_manager.cpp",
159      "frameworks/core/task_manager.cpp",
160      "frameworks/default_resource/check_box_res.cpp",
161      "frameworks/dfx/event_injector.cpp",
162      "frameworks/dfx/key_event_injector.cpp",
163      "frameworks/dfx/performance_task.cpp",
164      "frameworks/dfx/point_event_injector.cpp",
165      "frameworks/dfx/ui_dump_dom_tree.cpp",
166      "frameworks/dfx/ui_screenshot.cpp",
167      "frameworks/dfx/ui_view_bounds.cpp",
168      "frameworks/dock/focus_manager.cpp",
169      "frameworks/dock/input_device.cpp",
170      "frameworks/dock/key_input_device.cpp",
171      "frameworks/dock/ohos/ohos_input_device.cpp",
172      "frameworks/dock/pointer_input_device.cpp",
173      "frameworks/dock/rotate_input_device.cpp",
174      "frameworks/dock/screen_device_proxy.cpp",
175      "frameworks/dock/vibrator_manager.cpp",
176      "frameworks/dock/virtual_input_device.cpp",
177      "frameworks/draw/clip_utils.cpp",
178      "frameworks/draw/draw_arc.cpp",
179      "frameworks/draw/draw_canvas.cpp",
180      "frameworks/draw/draw_curve.cpp",
181      "frameworks/draw/draw_image.cpp",
182      "frameworks/draw/draw_label.cpp",
183      "frameworks/draw/draw_line.cpp",
184      "frameworks/draw/draw_rect.cpp",
185      "frameworks/draw/draw_triangle.cpp",
186      "frameworks/draw/draw_utils.cpp",
187      "frameworks/engines/gfx/gfx_engine_manager.cpp",
188      "frameworks/engines/gfx/hi3516/hi3516_engine.cpp",
189      "frameworks/engines/gfx/soft_engine.cpp",
190      "frameworks/events/event.cpp",
191      "frameworks/font/base_font.cpp",
192      "frameworks/font/font_ram_allocator.cpp",
193      "frameworks/font/glyphs_cache.cpp",
194      "frameworks/font/glyphs_file.cpp",
195      "frameworks/font/glyphs_manager.cpp",
196      "frameworks/font/ui_font.cpp",
197      "frameworks/font/ui_font_adaptor.cpp",
198      "frameworks/font/ui_font_allocator.cpp",
199      "frameworks/font/ui_font_bitmap.cpp",
200      "frameworks/font/ui_font_builder.cpp",
201      "frameworks/font/ui_font_cache.cpp",
202      "frameworks/font/ui_font_cache_manager.cpp",
203      "frameworks/font/ui_font_vector.cpp",
204      "frameworks/font/ui_line_break.cpp",
205      "frameworks/font/ui_multi_font_manager.cpp",
206      "frameworks/font/ui_text_shaping.cpp",
207      "frameworks/imgdecode/cache_manager.cpp",
208      "frameworks/imgdecode/file_img_decoder.cpp",
209      "frameworks/imgdecode/image_load.cpp",
210      "frameworks/layout/flex_layout.cpp",
211      "frameworks/layout/grid_layout.cpp",
212      "frameworks/layout/list_layout.cpp",
213      "frameworks/render/render_base.cpp",
214      "frameworks/render/render_pixfmt_rgba_blend.cpp",
215      "frameworks/render/render_scanline.cpp",
216      "frameworks/themes/theme.cpp",
217      "frameworks/themes/theme_manager.cpp",
218      "frameworks/window/window.cpp",
219      "frameworks/window/window_impl.cpp",
220    ]
221
222    if (ohos_kernel_type == "liteos_m") {
223      target_type = "static_library"
224      include_dirs = [
225        "frameworks",
226        "//third_party/freetype/include",
227      ]
228      sources -= [
229        "frameworks/components/ui_surface_view.cpp",
230        "frameworks/dfx/ui_dump_dom_tree.cpp",
231        "frameworks/dfx/ui_screenshot.cpp",
232        "frameworks/engines/gfx/hi3516/hi3516_engine.cpp",
233        "frameworks/window/window.cpp",
234        "frameworks/window/window_impl.cpp",
235      ]
236      deps = [
237        "//build/lite/config/component/cJSON:cjson_static",
238        "//third_party/bounds_checking_function:libsec_static",
239        "//third_party/freetype:freetype",
240        "//third_party/icu/icu4c/source/common:icu_font",
241        "//third_party/libjpeg-turbo:libjpeg",
242        "//third_party/libpng:libpng",
243        "//third_party/qrcodegen:qrcodegen",
244      ]
245    } else {
246      target_type = "shared_library"
247      include_dirs = [ "frameworks" ]
248      deps = [
249        "//build/lite/config/component/cJSON:cjson_shared",
250        "//foundation/graphic/graphic_utils_lite:lite_graphic_hals",
251        "//foundation/graphic/surface_lite:surface_lite",
252        "//foundation/window/window_manager_lite:window_manager_lite",
253        "//third_party/bounds_checking_function:libsec_shared",
254        "//third_party/freetype:freetype",
255        "//third_party/icu/icu4c/source/common:icu_font",
256        "//third_party/libjpeg-turbo:libjpeg",
257        "//third_party/libpng:libpng",
258        "//third_party/qrcodegen:qrcodegen",
259      ]
260
261      if (enable_video_component) {
262        defines += [ "ENABLE_VIDEO_COMPONENT=1" ]
263        source += [ "frameworks/components/ui_video.cpp" ]
264
265        deps += [ "//foundation/multimedia/media_lite/frameworks/player_lite:player_lite" ]
266      }
267
268      if (enable_graphic_font) {
269        deps += [ "//foundation/arkui/ui_lite:utils_config" ]
270      }
271
272      ldflags = [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ]
273    }
274    defines += [ "ENABLE_GIF=0" ]
275
276    public_deps = [ "//foundation/graphic/graphic_utils_lite:utils_lite" ]
277    public_configs = [ ":graphic_define_config" ]
278    if (board_toolchain_type != "iccarm") {
279      cflags = [
280        "-Wall",
281        "-fno-exceptions",
282      ]
283      cflags_cc = cflags
284    } else {
285      defines += [ "ENABLE_ICU=1" ]
286      include_dirs +=
287          [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite" ]
288    }
289  }
290} else {
291  group("ui_lite") {
292  }
293}
294