1# Copyright (c) 2022 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("//commonlibrary/ets_utils/ets_utils_config.gni") 16 17taskpool_sources = [ 18 "async_runner.cpp", 19 "async_runner_manager.cpp", 20 "dfx_hisys_event.cpp", 21 "native_module_taskpool.cpp", 22 "sequence_runner.cpp", 23 "sequence_runner_manager.cpp", 24 "task.cpp", 25 "task_group.cpp", 26 "task_group_manager.cpp", 27 "task_manager.cpp", 28 "task_queue.cpp", 29 "task_runner.cpp", 30 "taskpool.cpp", 31 "thread.cpp", 32 "worker.cpp", 33] 34 35concurrent_helper_sources = [ 36 "../common/helper/concurrent_helper.cpp", 37 "../common/helper/napi_helper.cpp", 38] 39 40concurrent_platform_sources = [] 41 42if (is_ohos) { 43 concurrent_platform_sources += [ "$platform_root/ohos/qos_helper.cpp" ] 44} else { 45 concurrent_platform_sources += [ "$platform_root/default/qos_helper.cpp" ] 46} 47 48if (target_os == "ios" || (!is_arkui_x && is_mac)) { 49 concurrent_platform_sources += [ "$platform_root/ios/process_helper.cpp" ] 50} else { 51 concurrent_platform_sources += [ "$platform_root/default/process_helper.cpp" ] 52} 53 54ohos_shared_library("taskpool") { 55 branch_protector_ret = "pac_ret" 56 sanitize = { 57 cfi = true 58 cfi_cross_dso = true 59 debug = false 60 } 61 include_dirs = [ 62 "include", 63 js_concurrent_module_common, 64 platform_root, 65 ets_util_path, 66 ] 67 sources = taskpool_sources 68 sources += concurrent_helper_sources 69 sources += concurrent_platform_sources 70 71 defines = [] 72 if (is_ohos) { 73 defines += [ "OHOS_PLATFORM" ] 74 } else if (is_mingw) { 75 defines += [ "WINDOWS_PLATFORM" ] 76 } else if (target_os == "android") { 77 defines += [ "ANDROID_PLATFORM" ] 78 } else if (target_os == "ios") { 79 defines += [ "IOS_PLATFORM" ] 80 } else if (is_mac && target_os != "android") { 81 defines += [ "MAC_PLATFORM" ] 82 } 83 84 deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] 85 86 external_deps = [ 87 "bounds_checking_function:libsec_shared", 88 "napi:ace_napi", 89 ] 90 91 if (ets_utils_stacksize_low_enable) { 92 defines += [ "ENABLE_ETS_UTILS_STACKSIZE_LOW" ] 93 } 94 if (is_ohos && is_standard_system && !is_arkui_x) { 95 defines += [ 96 "ENABLE_TASKPOOL_EVENTHANDLER", 97 "ENABLE_TASKPOOL_FFRT", 98 "ENABLE_TASKPOOL_HISYSEVENT", 99 ] 100 external_deps += [ 101 "bundle_framework:appexecfwk_base", 102 "bundle_framework:appexecfwk_core", 103 "c_utils:utils", 104 "eventhandler:libeventhandler", 105 "ffrt:libffrt", 106 "hisysevent:libhisysevent", 107 "init:libbegetutil", 108 "ipc:ipc_core", 109 "samgr:samgr_proxy", 110 ] 111 } 112 113 if (is_ohos && is_standard_system && !is_arkui_x && 114 defined(global_parts_info) && 115 defined(global_parts_info.resourceschedule_qos_manager)) { 116 defines += [ "ENABLE_QOS" ] 117 external_deps += [ "qos_manager:qos" ] 118 } 119 120 if (is_linux && current_toolchain == host_toolchain) { 121 external_deps += [ "innerkits:libhilog_linux" ] 122 defines = [ 123 "LINUX_PLATFORM", 124 "PREVIEW", 125 ] 126 } else { 127 external_deps += [ "hilog:libhilog" ] 128 } 129 130 external_deps += [ "hitrace:hitrace_meter" ] 131 132 subsystem_name = "commonlibrary" 133 part_name = "ets_utils" 134 135 relative_install_dir = "module" 136} 137 138ohos_source_set("taskpool_static") { 139 branch_protector_ret = "pac_ret" 140 sanitize = { 141 cfi = true 142 cfi_cross_dso = true 143 debug = false 144 } 145 include_dirs = [ 146 "include", 147 js_concurrent_module_common, 148 platform_root, 149 ets_util_path, 150 ] 151 152 sources = taskpool_sources 153 sources += concurrent_helper_sources 154 sources += concurrent_platform_sources 155 156 deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] 157 defines = [] 158 159 external_deps = [ "hilog:libhilog" ] 160 161 if (is_ohos && is_standard_system && !is_arkui_x) { 162 defines += [ 163 "ENABLE_TASKPOOL_EVENTHANDLER", 164 "ENABLE_TASKPOOL_FFRT", 165 "ENABLE_TASKPOOL_HISYSEVENT", 166 ] 167 external_deps += [ 168 "bundle_framework:appexecfwk_base", 169 "bundle_framework:appexecfwk_core", 170 "c_utils:utils", 171 "eventhandler:libeventhandler", 172 "ffrt:libffrt", 173 "hisysevent:libhisysevent", 174 "init:libbegetutil", 175 "ipc:ipc_core", 176 "samgr:samgr_proxy", 177 ] 178 } 179 180 if (is_arkui_x) { 181 sources -= [ "../common/helper/napi_helper.cpp" ] 182 deps -= [ "${ets_util_path}/js_sys_module/timer:timer" ] 183 include_dirs += [ 184 "$plugins_root/hilog/include", 185 "$plugins_root/interfaces", 186 "$sys_module/timer", 187 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 188 ] 189 defines += [ "__ARKUI_CROSS__" ] 190 deps += [ 191 "$plugins_root/libs/napi:napi_${target_os}", 192 "$plugins_root/libs/securec:sec_${target_os}", 193 "$plugins_root/libs/uv:uv_${target_os}", 194 "$sys_module/timer:timer_static", 195 ] 196 if (target_os == "android") { 197 defines += [ "ANDROID_PLATFORM" ] 198 } 199 if (target_os == "ios") { 200 defines += [ "IOS_PLATFORM" ] 201 } 202 } else { 203 external_deps += [ 204 "bounds_checking_function:libsec_shared", 205 "hitrace:hitrace_meter", 206 "napi:ace_napi", 207 ] 208 if (is_ohos && is_standard_system && defined(global_parts_info) && 209 defined(global_parts_info.resourceschedule_qos_manager)) { 210 defines += [ "ENABLE_QOS" ] 211 external_deps += [ "qos_manager:qos" ] 212 } 213 } 214 215 subsystem_name = "commonlibrary" 216 part_name = "ets_utils" 217} 218 219group("taskpool_packages") { 220 deps = [ ":taskpool" ] 221} 222