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_2" ] 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 if (enhanced_opt) { 38 if (graphic_2d_feature_enable_pgo && 39 graphic_2d_feature_product == "phone") { 40 cflags += [ 41 "-fprofile-use=" + 42 rebase_path("${graphic_2d_feature_pgo_path}/libvsync.profdata", 43 root_build_dir), 44 "-Wno-error=backend-plugin", 45 "-Wno-profile-instr-out-of-date", 46 "-Wno-profile-instr-unprofiled", 47 ] 48 49 if (target_cpu == "arm64" && enable_enhanced_opt) { 50 ldflags += [ "-Wl,--aarch64-inline-plt" ] 51 } 52 } 53 } 54 } 55} 56 57config("vsync_public_config") { 58 include_dirs = [ 59 "$graphic_2d_root/interfaces/inner_api/composer", 60 "$graphic_2d_root/rosen/include/common", 61 "$graphic_2d_root/rosen/modules/composer/vsync/include", 62 "$graphic_2d_root/utils/sandbox", 63 ] 64 if (graphic_2d_feature_enable_dvsync) { 65 include_dirs += [ "$graphic_2d_ext_root/dvsync/dvsync_2/include" ] 66 } 67 if (defined(global_parts_info) && 68 defined(global_parts_info.resourceschedule_resource_schedule_service)) { 69 include_dirs += [ "$graphic_2d_root/rosen/modules/ressched/include" ] 70 } 71} 72 73ohos_shared_library("libvsync") { 74 sanitize = { 75 boundary_sanitize = true 76 integer_overflow = true 77 ubsan = true 78 } 79 sources = [ 80 "src/vsync_callback_listener.cpp", 81 "src/vsync_connection_proxy.cpp", 82 "src/vsync_connection_stub.cpp", 83 "src/vsync_controller.cpp", 84 "src/vsync_distributor.cpp", 85 "src/vsync_generator.cpp", 86 "src/vsync_receiver.cpp", 87 "src/vsync_sampler.cpp", 88 "src/vsync_system_ability_listener.cpp", 89 ] 90 91 include_dirs = [ 92 "$graphic_2d_root/utils/log", 93 "$graphic_2d_root/interfaces/inner_api/common", 94 "$graphic_2d_root/rosen/modules/composer/vsync/include", 95 "$graphic_2d_root/utils/rs_frame_report_ext/include", 96 ] 97 98 defines = [] 99 100 configs = [ ":vsync_config" ] 101 102 public_configs = [ ":vsync_public_config" ] 103 104 deps = [ 105 "$graphic_2d_root/utils:rs_frame_report_ext", 106 "$graphic_2d_root/utils:sandbox_utils", 107 "$graphic_2d_root/utils:scoped_bytrace", 108 "$graphic_2d_root/utils:socketpair", 109 ] 110 111 external_deps = [ 112 "access_token:libaccesstoken_sdk", 113 "c_utils:utils", 114 "eventhandler:libeventhandler", 115 "ffrt:libffrt", 116 "hilog:libhilog", 117 "hitrace:hitrace_meter", 118 "init:libbegetutil", 119 "ipc:ipc_core", 120 "qos_manager:qos", 121 "safwk:system_ability_fwk", 122 ] 123 124 public_external_deps = 125 [ 126 "c_utils:utils", 127 "samgr:samgr_proxy", 128 ] 129 130 if (graphic_2d_feature_enable_dvsync) { 131 external_deps += [ "graphic_2d_ext:libdvsync" ] 132 include_dirs += [ "$graphic_2d_ext_root/dvsync/dvsync_2/include" ] 133 sources += 134 [ "$graphic_2d_ext_root/dvsync/dvsync_2/src/dvsync_controller.cpp" ] 135 } 136 137 if (defined(global_parts_info) && 138 defined(global_parts_info.resourceschedule_resource_schedule_service)) { 139 external_deps += [ "resource_schedule_service:ressched_client" ] 140 defines += [ "COMPOSER_SCHED_ENABLE" ] 141 sources += [ 142 "$graphic_2d_root/rosen/modules/ressched/src/ressched_event_listener.cpp", 143 ] 144 } 145 146 part_name = "graphic_2d" 147 subsystem_name = "graphic" 148} 149 150## Build libvsync.so 151 152group("test") { 153 testonly = true 154 155 deps = [ "test:test" ] 156} 157