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