1# Copyright (c) 2021 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")
16
17## Build libvsync.so
18
19config("vsync_config") {
20  visibility = [ ":*" ]
21
22  cflags = [
23    "-Wall",
24    "-Werror",
25    "-g3",
26  ]
27
28  if (graphic_2d_feature_enable_dvsync) {
29    gpu_defines += [ "RS_ENABLE_DVSYNC" ]
30  }
31
32  defines = []
33  defines += gpu_defines
34
35  if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64")) {
36    ldflags = [ "-Wl,-Bsymbolic" ]
37  }
38}
39
40config("vsync_public_config") {
41  include_dirs = [
42    "$graphic_2d_root/interfaces/inner_api/composer",
43    "$graphic_2d_root/rosen/include/common",
44    "$graphic_2d_root/rosen/modules/composer/vsync/include",
45    "$graphic_2d_root/utils/sandbox",
46  ]
47  if (graphic_2d_feature_enable_dvsync) {
48    include_dirs += [ "$graphic_2d_ext_root/dvsync/include" ]
49  }
50  if (defined(global_parts_info) &&
51      defined(global_parts_info.resourceschedule_resource_schedule_service)) {
52    include_dirs += [ "$graphic_2d_root/rosen/modules/ressched/include" ]
53  }
54}
55
56ohos_shared_library("libvsync") {
57  sanitize = {
58    boundary_sanitize = true
59    integer_overflow = true
60    ubsan = true
61  }
62  sources = [
63    "src/vsync_connection_proxy.cpp",
64    "src/vsync_connection_stub.cpp",
65    "src/vsync_controller.cpp",
66    "src/vsync_distributor.cpp",
67    "src/vsync_generator.cpp",
68    "src/vsync_receiver.cpp",
69    "src/vsync_sampler.cpp",
70    "src/vsync_system_ability_listener.cpp",
71  ]
72
73  include_dirs = [
74    "$graphic_2d_root/utils/log",
75    "$graphic_2d_root/interfaces/inner_api/common",
76    "$graphic_2d_root/rosen/modules/composer/vsync/include",
77    "$graphic_2d_root/utils/rs_frame_report_ext/include",
78  ]
79
80  defines = []
81
82  configs = [ ":vsync_config" ]
83
84  public_configs = [ ":vsync_public_config" ]
85
86  deps = [
87    "$graphic_2d_root/utils:rs_frame_report_ext",
88    "$graphic_2d_root/utils:sandbox_utils",
89  ]
90
91  if (graphic_2d_feature_enable_dvsync) {
92    deps += [ "$graphic_2d_ext_root/dvsync:libdvsync" ]
93    include_dirs += [ "$graphic_2d_ext_root/dvsync/include" ]
94  }
95
96  public_deps = [
97    "$graphic_2d_root/utils:scoped_bytrace",
98    "$graphic_2d_root/utils:socketpair",
99  ]
100
101  external_deps = [
102    "access_token:libaccesstoken_sdk",
103    "c_utils:utils",
104    "eventhandler:libeventhandler",
105    "hilog:libhilog",
106    "hitrace:hitrace_meter",
107    "init:libbegetutil",
108    "ipc:ipc_core",
109    "qos_manager:qos",
110    "safwk:system_ability_fwk",
111    "samgr:samgr_proxy",
112  ]
113  public_external_deps = [ "c_utils:utils" ]
114
115  if (defined(graphic_2d_ext_configs.vendor_root)) {
116    include_dirs += graphic_2d_ext_configs.libvsync_ext_include_dirs
117
118    sources += graphic_2d_ext_configs.libvsync_ext_sources
119
120    public_deps += [ "//foundation/graphic/graphic_2d_ext/ohcore/graphic_compat_layer:libgraphic_compat_layer" ]
121  }
122
123  if (defined(global_parts_info) &&
124      defined(global_parts_info.resourceschedule_resource_schedule_service)) {
125    external_deps += [ "resource_schedule_service:ressched_client" ]
126    defines += [ "COMPOSER_SCHED_ENABLE" ]
127    sources += [
128      "$graphic_2d_root/rosen/modules/ressched/src/ressched_event_listener.cpp",
129    ]
130  }
131
132  part_name = "graphic_2d"
133  subsystem_name = "graphic"
134}
135
136## Build libvsync.so
137
138group("test") {
139  testonly = true
140
141  deps = [ "test:test" ]
142}
143