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("//foundation/graphic/graphic_2d/graphic_config.gni")
16import("render_service_client.gni")
17
18config("render_service_client_config") {
19  include_dirs = [
20    "$graphic_2d_root/rosen/modules",
21    "$graphic_2d_root/rosen/modules/render_service_client/core",
22    "$graphic_2d_root/rosen/modules/render_service_base/include",
23    "$graphic_2d_root/interfaces/inner_api/common",
24    "$graphic_2d_root/interfaces/inner_api/composer",
25    "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_text/",
26    "$graphic_2d_root/rosen/modules/2d_graphics",
27  ]
28  defines = rs_common_define
29  if (defined(is_arkui_x) && is_arkui_x) {
30    include_dirs += [
31      "$graphic_2d_root/utils/color_manager/export",
32      "//foundation/multimedia/image_framework/interfaces/innerkits/include",
33    ]
34  }
35}
36
37template("render_service_client_source_set") {
38  ohos_source_set(target_name) {
39    branch_protector_ret = "pac_ret"
40    sanitize = {
41      cfi = false
42      cfi_cross_dso = false
43      debug = false
44      blocklist = "./rs_client_blocklist.txt"
45      if (rosen_is_ohos) {
46        boundary_sanitize = true
47        integer_overflow = true
48        ubsan = true
49      }
50    }
51    defines = []
52    defines += gpu_defines
53    defines += [ "MODULE_RSC" ]
54    is_static_lib = invoker.is_static_lib
55    include_dirs = [
56      "$graphic_2d_root/rosen/modules/2d_graphics/src",
57      "$graphic_2d_root/rosen/modules/frame_report/include",
58      "$graphic_2d_root/rosen/modules/render_frame_trace/include",
59      "$graphic_2d_root/rosen/modules/render_service_base/src",
60      "$graphic_2d_root/utils/color_manager/export",
61      "$graphic_2d_root/rosen/modules/2d_engine/rosen_text/symbol/symbol_animation",
62      "$graphic_2d_root/utils/log",
63      "$graphic_2d_root/utils/sandbox",
64    ]
65
66    if (defined(is_arkui_x) && is_arkui_x) {
67      include_dirs += [
68        "$graphic_2d_root/utils/color_manager/export",
69        "//foundation/multimedia/image_framework/interfaces/innerkits/include",
70        "//foundation/graphic/graphic_surface/interfaces/inner_api/surface",
71      ]
72    }
73
74    sources = [
75      #animation
76      "core/animation/rs_animation.cpp",
77      "core/animation/rs_animation_callback.cpp",
78      "core/animation/rs_animation_group.cpp",
79      "core/animation/rs_animation_timing_curve.cpp",
80      "core/animation/rs_curve_animation.cpp",
81      "core/animation/rs_implicit_animation_param.cpp",
82      "core/animation/rs_implicit_animator.cpp",
83      "core/animation/rs_implicit_animator_map.cpp",
84      "core/animation/rs_interactive_implict_animator.cpp",
85      "core/animation/rs_interpolating_spring_animation.cpp",
86      "core/animation/rs_keyframe_animation.cpp",
87      "core/animation/rs_path_animation.cpp",
88      "core/animation/rs_property_animation.cpp",
89      "core/animation/rs_spring_animation.cpp",
90      "core/animation/rs_symbol_animation.cpp",
91      "core/animation/rs_transition.cpp",
92      "core/animation/rs_transition_effect.cpp",
93
94      #modifier
95      "core/modifier/rs_extended_modifier.cpp",
96      "core/modifier/rs_modifier.cpp",
97      "core/modifier/rs_modifier_extractor.cpp",
98      "core/modifier/rs_modifier_manager.cpp",
99      "core/modifier/rs_modifier_manager_map.cpp",
100      "core/modifier/rs_property.cpp",
101      "core/modifier/rs_property_modifier.cpp",
102      "core/modifier/rs_showing_properties_freezer.cpp",
103
104      #jank_detector
105      "core/jank_detector/rs_jank_detector.cpp",
106
107      #pipeline
108      "core/pipeline/rs_divided_ui_capture.cpp",
109      "core/pipeline/rs_node_map.cpp",
110      "core/pipeline/rs_render_thread.cpp",
111      "core/pipeline/rs_render_thread_visitor.cpp",
112
113      #transaction
114      "core/transaction/rs_application_agent_impl.cpp",
115      "core/transaction/rs_interfaces.cpp",
116      "core/transaction/rs_render_thread_client.cpp",
117      "core/transaction/rs_sync_transaction_controller.cpp",
118      "core/transaction/rs_transaction.cpp",
119
120      #ui
121      "core/ui/rs_canvas_drawing_node.cpp",
122      "core/ui/rs_canvas_node.cpp",
123      "core/ui/rs_display_node.cpp",
124      "core/ui/rs_effect_node.cpp",
125      "core/ui/rs_ext_node_operation.cpp",
126      "core/ui/rs_frame_rate_linker.cpp",
127      "core/ui/rs_frame_rate_policy.cpp",
128      "core/ui/rs_hdr_manager.cpp",
129      "core/ui/rs_node.cpp",
130      "core/ui/rs_proxy_node.cpp",
131      "core/ui/rs_root_node.cpp",
132      "core/ui/rs_surface_extractor.cpp",
133      "core/ui/rs_surface_node.cpp",
134      "core/ui/rs_texture_export.cpp",
135      "core/ui/rs_ui_director.cpp",
136      "core/ui/rs_ui_display_soloist.cpp",
137      "core/ui/rs_ui_share_context.cpp",
138    ]
139
140    if (is_cross_platform) {
141      #ui
142      sources -= [ "core/ui/rs_display_node.cpp" ]
143      defines += [ "CROSS_PLATFORM" ]
144    }
145
146    if (rosen_is_ohos) {
147      sources += [ "$rosen_root/modules/frame_report/src/rs_frame_report.cpp" ]
148    } else if (!is_arkui_x) {
149      sources +=
150          [ "$rosen_root/modules/frame_report/src/mingw/rs_frame_report.cpp" ]
151    }
152
153    cflags = [
154      "-Wall",
155      "-Wno-pointer-arith",
156      "-Wno-non-virtual-dtor",
157      "-Wno-missing-field-initializers",
158      "-Wno-c++11-narrowing",
159      "-fvisibility=hidden",
160    ]
161
162    if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64")) {
163      if (!use_libfuzzer) {
164        cflags += [ "-flto=thin" ]
165      }
166      if (enhanced_opt) {
167        if (!use_libfuzzer) {
168          cflags += [ "-fwhole-program-vtables" ]
169        }
170      }
171    }
172
173    cflags_cc = [
174      "-std=c++17",
175      "-fvisibility-inlines-hidden",
176    ]
177
178    deps = [
179      "$graphic_2d_root/rosen/modules/platform:ipc_core",
180      "$graphic_2d_root/rosen/modules/render_frame_trace:render_frame_trace",
181    ]
182    public_deps = []
183    if (enable_export_macro) {
184      defines += [ "ENABLE_EXPORT_MACRO" ]
185    }
186
187    if (defined(use_rosen_drawing) && use_rosen_drawing) {
188      defines += [ "USE_ROSEN_DRAWING" ]
189      deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
190      if (rs_enable_gpu) {
191        defines += [ "RS_ENABLE_GPU" ]
192      }
193      if (current_os == "mingw") {
194        defines += [ "WINDOWS_PLATFORM" ]
195      }
196    }
197    if (rosen_is_ohos) {
198      deps += [
199        "$graphic_2d_root/rosen/modules/frame_analyzer:libframe_analyzer",
200        "$graphic_2d_root/utils/color_manager:color_manager",
201      ]
202
203      external_deps = [
204        "c_utils:utils",
205        "hisysevent:libhisysevent",
206        "hitrace:hitrace_meter",
207        "image_framework:image_native",
208        "qos_manager:qos",
209      ]
210
211      defines += [ "RES_CLINET_SCHED_ENABLE" ]
212
213      if (accessibility_enable) {
214        external_deps += [ "accessibility:accessibilityconfig" ]
215        external_deps += [ "accessibility:accessibility_common" ]
216        defines += accessibility_defines
217      }
218    } else if (rosen_preview) {
219      deps += [
220        "$graphic_2d_root/frameworks/opengl_wrapper:EGL",
221        "$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
222        "$graphic_2d_root/rosen/modules/glfw_render_context:libglfw_render_context",
223      ]
224
225      if (rss_enabled) {
226        external_deps = []
227      }
228    }
229    if (defined(external_deps)) {
230      external_deps += [ "hilog:libhilog" ]
231    } else {
232      external_deps = [ "hilog:libhilog" ]
233    }
234
235    external_deps += [ "graphic_surface:surface_headers" ]
236
237    if (rosen_cross_platform) {
238      deps += [ "$rosen_root/modules/platform:hilog" ]
239    }
240
241    if (rss_enabled) {
242      defines += [ "OHOS_RSS_CLIENT" ]
243      external_deps += [ "resource_schedule_service:ressched_client" ]
244    }
245
246    if (is_static_lib) {
247      public_deps += [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base_static" ]
248    } else {
249      public_deps += [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base" ]
250      deps += [ "$rosen_root/modules/platform:eventhandler" ]
251    }
252
253    if (defined(graphic_2d_broker_configs.vendor_root) && !rosen_preview) {
254      sources +=
255          graphic_2d_broker_configs.librender_service_client_ext_broker_sources
256      sources -= graphic_2d_broker_configs.librender_service_client_ext_broker_sources_del
257      external_deps += [ "ipc:ipc_core" ]
258      external_deps += [ "samgr:samgr_proxy" ]
259    }
260
261    if (tp_feature_enable) {
262      defines += tp_defines
263    }
264
265    public_configs = [ ":render_service_client_config" ]
266
267    part_name = "graphic_2d"
268    subsystem_name = "graphic"
269  }
270}
271
272render_service_client_source_set("render_service_client_src") {
273  is_static_lib = false
274}
275
276render_service_client_source_set("render_service_client_src_static") {
277  is_static_lib = true
278}
279
280config("render_service_client_link_config") {
281  if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64")) {
282    ldflags = [
283      "-Wl,--lto-O2",
284      "-Wl,-mllvm",
285      "-Wl,-wholeprogramdevirt-check=fallback",
286      "-Wl,-Bsymbolic",
287    ]
288  }
289}
290
291ohos_shared_library("librender_service_client") {
292  branch_protector_ret = "pac_ret"
293  sanitize = {
294    cfi = false
295    cfi_cross_dso = false
296    debug = false
297    blocklist = "./rs_client_blocklist.txt"
298  }
299
300  public_configs = [ ":render_service_client_config" ]
301
302  public_deps = [ ":render_service_client_src" ]
303
304  external_deps = [ "hilog:libhilog" ]
305
306  if (enhanced_opt) {
307    configs = [ ":render_service_client_link_config" ]
308  }
309
310  public_external_deps = []
311  if (rosen_is_ohos) {
312    public_external_deps += [ "graphic_surface:surface" ]
313  } else if (rosen_preview) {
314    public_external_deps += [ "graphic_surface:surface_headers" ]
315  }
316
317  part_name = "graphic_2d"
318  subsystem_name = "graphic"
319}
320
321ohos_source_set("librender_service_client_static") {
322  branch_protector_ret = "pac_ret"
323  sanitize = {
324    cfi = false
325    cfi_cross_dso = false
326    debug = false
327    blocklist = "./rs_client_blocklist.txt"
328  }
329  public_deps = [ ":render_service_client_src_static" ]
330  deps = [ "$rosen_root/modules/platform:eventhandler" ]
331
332  public_external_deps = []
333  if (rosen_is_ohos) {
334    public_external_deps += [ "graphic_surface:surface" ]
335  } else if (rosen_preview) {
336    public_external_deps += [ "graphic_surface:surface_headers" ]
337  } else if (is_arkui_x) {
338    public_deps +=
339        [ "//foundation/graphic/graphic_surface/surface:surface_headers" ]
340  }
341
342  part_name = "graphic_2d"
343  subsystem_name = "graphic"
344}
345
346group("test") {
347  if (rosen_is_ohos) {
348    testonly = true
349
350    deps = [ "test:test" ]
351  }
352}
353