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