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