1# Copyright (c) 2023 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. 13import("//build/ohos.gni") 14import("ffrt.gni") 15 16defines = [] 17 18config("ffrt_config") { 19 visibility = [ ":*" ] 20 include_dirs = [ 21 "include", 22 "interfaces/kits", 23 "interfaces/inner_api" 24 ] 25 26 ffrt_defaults_cflags = [ 27 "-fstack-protector-all", 28 "-Wno-unused-variable", 29 "-Wno-unused-function", 30 "-Wno-unused-value", 31 "-Wno-unused-private-field", 32 "-Wno-tautological-constant-out-of-range-compare", 33 "-Wno-shadow", 34 "-Wno-float-equal", 35 "-Wno-unused-parameter", 36 "-fno-common", 37 ] 38 39 cflags = ffrt_defaults_cflags 40 cflags_c = [ 41 "-fstack-protector-all", 42 "-fno-common", 43 ] 44 cflags_cc = ffrt_defaults_cflags 45 46 ffrt_debug_defines = [ 47 "FFRT_LOG_LEVEL=3", 48 "FFRT_BBOX_ENABLE", 49 "FFRT_OH_EVENT_RECORD", 50 "FFRT_CO_BACKTRACE_OH_ENABLE", 51 "FFRT_OH_TRACE_ENABLE", 52 "FFRT_TRACE_LEVEL=1", 53 "FFRT_TRACE_RECORD_LEVEL=1", 54 "FFRT_SEND_EVENT", 55 "FFRT_ALLOCATOR_MMAP_SIZE=${ffrt_allocator_mmap_size}", 56 "FFRT_STACK_SIZE=${ffrt_stack_size}", 57 ] 58 59 #ffrt_release_defines = [ 60 # "FFRT_LOG_LEVEL=0", 61 # "FFRT_RELEASE", 62 #] 63 64 defines += ffrt_debug_defines 65 66 if (is_asan && !use_hwasan) { 67 defines += [ "ASAN_MODE" ] 68 } 69 70 if (use_hwasan || is_tsan) { 71 defines += [ "CLOSE_COROUTINE_MODE" ] 72 } 73 74 if (target_cpu == "arm") { 75 defines += [ "APP_USE_ARM" ] 76 } 77 78 if (is_ohos && !ffrt_task_local_enable) { 79 defines += [ "FFRT_TASK_LOCAL_ENABLE" ] 80 } 81 82 #build_variant is root/user, default user 83 if (build_variant == "root") { 84 defines += [ "FFRT_ENG_DEBUG" ] 85 } 86 87 #defines += ffrt_release_defines 88} 89 90config("ffrt_inner_config") { 91 include_dirs = [ 92 "include", 93 "src", 94 "src/dfx/log", 95 "src_ext", 96 "src/sched", 97 ] 98 99 if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64")) { 100 cflags = [ 101 "-flto=thin", 102 "-fsplit-lto-unit", 103 ] 104 } 105 106 ffrt_inner_cflags = [ 107 "-std=c++17", 108 "-g", 109 "-D_FORTIFY_SOURCE=2", 110 "-O2", 111 "-fPIC", 112 "-DFFRT_PTHREAD_ENABLE", 113 "-DFFRT_OH_WATCHDOG_ENABLE", 114 "-DQOS_WORKER_FRAME_RTG", 115 "-DUSE_OHOS_QOS", 116 "-DOHOS_STANDARD_SYSTEM", 117 "-DTASKSTAT_LOG_ENABLE=0", 118 ] 119 120 cflags_cc = ffrt_inner_cflags 121} 122 123ohos_shared_library("libffrt") { 124 if (ffrt_support_enable) { 125 branch_protector_ret = "pac_ret" 126 public_configs = [ ":ffrt_config" ] 127 configs = [ ":ffrt_inner_config" ] 128 ldflags = [ "-Wl,-z,nodelete" ] 129 130 sources = [ 131 "src/core/entity.cpp", 132 "src/core/task.cpp", 133 "src/core/task_io.cpp", 134 "src/core/version_ctx.cpp", 135 "src/dfx/bbox/bbox.cpp", 136 "src/dfx/bbox/fault_logger_fd_manager.cpp", 137 "src/dfx/dump/dump.cpp", 138 "src/dfx/log/ffrt_log.cpp", 139 "src/dfx/sysevent/sysevent.cpp", 140 "src/dfx/trace/ffrt_trace.cpp", 141 "src/dfx/trace/ffrt_trace_chain.cpp", 142 "src/dfx/trace_record/ffrt_trace_record.cpp", 143 "src/dfx/watchdog/watchdog_util.cpp", 144 "src/dm/dependence_manager.cpp", 145 "src/dm/sdependence_manager.cpp", 146 "src/eu/co2_context.c", 147 "src/eu/co_routine.cpp", 148 "src/eu/co_routine_factory.cpp", 149 "src/eu/cpu_worker.cpp", 150 "src/eu/execute_unit.cpp", 151 "src/eu/io_poller.cpp", 152 "src/eu/loop.cpp", 153 "src/eu/loop_api.cpp", 154 "src/eu/osattr_manager.cpp", 155 "src/eu/qos_convert.cpp", 156 "src/eu/qos_interface.cpp", 157 "src/eu/rtg_ioctl.cpp", 158 "src/eu/rtg_perf_ctrl.cpp", 159 "src/eu/sexecute_unit.cpp", 160 "src/eu/worker_thread.cpp", 161 "src/ipc/ipc.cpp", 162 "src/queue/base_queue.cpp", 163 "src/queue/concurrent_queue.cpp", 164 "src/queue/eventhandler_adapter_queue.cpp", 165 "src/queue/eventhandler_interactive_queue.cpp", 166 "src/queue/queue_api.cpp", 167 "src/queue/queue_handler.cpp", 168 "src/queue/queue_monitor.cpp", 169 "src/queue/serial_queue.cpp", 170 "src/queue/traffic_record.cpp", 171 "src/sched/deadline.cpp", 172 "src/sched/execute_ctx.cpp", 173 "src/sched/frame_interval.cpp", 174 "src/sched/interval.cpp", 175 "src/sched/load_tracking.cpp", 176 "src/sched/multi_workgroup.cpp", 177 "src/sched/qos.cpp", 178 "src/sched/sched_deadline.cpp", 179 "src/sched/scheduler.cpp", 180 "src/sched/stask_scheduler.cpp", 181 "src/sched/task_scheduler.cpp", 182 "src/sync/condition_variable.cpp", 183 "src/sync/delayed_worker.cpp", 184 "src/sync/timer_manager.cpp", 185 "src/sync/mutex.cpp", 186 "src/sync/perf_counter.cpp", 187 "src/sync/poller.cpp", 188 "src/sync/poller_api.cpp", 189 "src/sync/record_mutex.cpp", 190 "src/sync/shared_mutex.cpp", 191 "src/sync/sleep.cpp", 192 "src/sync/sync.cpp", 193 "src/sync/thread.cpp", 194 "src/sync/timer_api.cpp", 195 "src/sync/wait_queue.cpp", 196 "src/tm/cpu_task.cpp", 197 "src/tm/io_task.cpp", 198 "src/tm/queue_task.cpp", 199 "src/tm/scpu_task.cpp", 200 "src/tm/task_base.cpp", 201 "src/tm/task_factory.cpp", 202 "src/tm/uv_task.cpp", 203 "src/util/cpu_boost_wrapper.cpp", 204 "src/util/ffrt_cpu_boost.cpp", 205 "src/util/ffrt_facade.cpp", 206 "src/util/graph_check.cpp", 207 "src/util/init.cpp", 208 "src/util/spmc_queue.cpp", 209 "src/util/time_format.cpp", 210 "src/util/white_list.cpp", 211 "src/util/worker_monitor.cpp", 212 ] 213 214 external_deps = [ 215 "bounds_checking_function:libsec_shared", 216 "c_utils:utils", 217 "faultloggerd:libbacktrace_local", 218 "faultloggerd:libdfx_dumpcatcher", 219 "faultloggerd:libfaultloggerd", 220 "faultloggerd:libunwinder", 221 "hilog:libhilog", 222 "hisysevent:libhisysevent", 223 ] 224 225 defines = [] 226 227 if (ffrt_async_stack_enable) { 228 defines += [ "FFRT_ASYNC_STACKTRACE" ] 229 sources += [ "src/dfx/async_stack/ffrt_async_stack.cpp" ] 230 } 231 232 defines += [ "FFRT_ENABLE_HITRACE_CHAIN" ] 233 234 output_extension = "so" 235 symlink_target_name = [ "libffrt.z.so" ] 236 part_name = "ffrt" 237 subsystem_name = "resourceschedule" 238 install_images = [ 239 "system", 240 "updater", 241 ] 242 innerapi_tags = [ 243 "chipsetsdk_sp", 244 "ndk", 245 "sasdk", 246 ] 247 } 248} 249 250ohos_prebuilt_etc("whitelist_cfg") { 251 relative_install_dir = "ffrt" 252 source = "ffrt_whitelist.conf" 253 part_name = "ffrt" 254 subsystem_name = "resourceschedule" 255 install_enable = true 256 install_images = [ 257 "system", 258 "updater", 259 ] 260} 261 262group("ffrt_ndk") { 263 deps = [ 264 ":libffrt", 265 ":whitelist_cfg", 266 ] 267}