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/config/components/ace_engine/ace_gen_obj.gni") 15import("//build/ohos.gni") 16import("//commonlibrary/ets_utils/ets_utils_config.gni") 17 18config("worker_public_config") { 19 include_dirs = [ 20 "${ets_util_path}/js_concurrent_module/worker", 21 js_concurrent_module_common, 22 ] 23} 24 25ohos_shared_library("worker") { 26 branch_protector_ret = "pac_ret" 27 sanitize = { 28 cfi = true 29 cfi_cross_dso = true 30 debug = false 31 } 32 include_dirs = [ 33 "include", 34 ets_util_path, 35 ] 36 public_configs = [ ":worker_public_config" ] 37 38 sources = [ 39 "../common/helper/napi_helper.cpp", 40 "message_queue.cpp", 41 "native_module_worker.cpp", 42 "thread.cpp", 43 "worker.cpp", 44 "worker_runner.cpp", 45 ] 46 47 deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] 48 49 defines = [] 50 51 if (is_ohos) { 52 defines += [ "OHOS_PLATFORM" ] 53 } else if (is_mingw) { 54 defines += [ "WINDOWS_PLATFORM" ] 55 } else if (target_os == "android") { 56 defines += [ "ANDROID_PLATFORM" ] 57 } else if (target_os == "ios") { 58 defines += [ "IOS_PLATFORM" ] 59 } else if (is_mac && target_os != "android") { 60 defines += [ "MAC_PLATFORM" ] 61 } 62 63 external_deps = [ 64 "c_utils:utils", 65 "napi:ace_napi", 66 ] 67 68 if (is_linux && current_toolchain == host_toolchain) { 69 external_deps += [ "innerkits:libhilog_linux" ] 70 defines = [ 71 "LINUX_PLATFORM", 72 "PREVIEW", 73 ] 74 } else { 75 if (is_standard_system) { 76 external_deps += [ 77 "hilog:libhilog", 78 "init:libbegetutil", 79 ] 80 } else { 81 external_deps += [ "hilog:libhilog" ] 82 } 83 } 84 85 if (is_ohos && is_standard_system && !is_arkui_x) { 86 defines += [ "ENABLE_WORKER_EVENTHANDLER" ] 87 external_deps += [ "eventhandler:libeventhandler" ] 88 } 89 90 if (is_ohos && is_standard_system && defined(global_parts_info) && 91 defined(global_parts_info.resourceschedule_qos_manager)) { 92 defines += [ "ENABLE_QOS" ] 93 external_deps += [ "qos_manager:qos" ] 94 } 95 96 external_deps += [ "hitrace:hitrace_meter" ] 97 98 subsystem_name = "commonlibrary" 99 part_name = "ets_utils" 100 101 relative_install_dir = "module" 102} 103 104ohos_source_set("worker_static") { 105 branch_protector_ret = "pac_ret" 106 sanitize = { 107 cfi = true 108 cfi_cross_dso = true 109 debug = false 110 } 111 include_dirs = [ 112 js_concurrent_module_common, 113 "$concurrent_module/worker", 114 "$sys_module/timer", 115 ets_util_path, 116 ] 117 118 sources = [ 119 "$js_concurrent_module_common/helper/napi_helper.cpp", 120 "$sys_module/timer/sys_timer.cpp", 121 "message_queue.cpp", 122 "native_module_worker.cpp", 123 "thread.cpp", 124 "worker.cpp", 125 "worker_runner.cpp", 126 ] 127 deps = [] 128 129 defines = [] 130 131 external_deps = [ "c_utils:utils" ] 132 if (is_standard_system) { 133 external_deps += [ 134 "hilog:libhilog", 135 "init:libbegetutil", 136 ] 137 } else { 138 external_deps += [ 139 "c_utils:utils", 140 "hilog:libhilog", 141 ] 142 } 143 144 if (is_arkui_x) { 145 include_dirs += [ 146 "$plugins_root/hilog/include", 147 "$plugins_root/interfaces", 148 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 149 ] 150 sources -= [ 151 "$js_concurrent_module_common/helper/napi_helper.cpp", 152 "$sys_module/timer/sys_timer.cpp", 153 ] 154 defines += [ "__ARKUI_CROSS__" ] 155 deps += [ 156 "$plugins_root/libs/napi:napi_${target_os}", 157 "$plugins_root/libs/uv:uv_${target_os}", 158 "$sys_module/timer:timer_static", 159 ] 160 if (target_os == "android") { 161 defines += [ "ANDROID_PLATFORM" ] 162 } 163 if (target_os == "ios") { 164 defines += [ "IOS_PLATFORM" ] 165 } 166 } else { 167 external_deps += [ 168 "hitrace:hitrace_meter", 169 "napi:ace_napi", 170 ] 171 } 172 173 if (is_ohos && is_standard_system && !is_arkui_x) { 174 defines += [ "ENABLE_WORKER_EVENTHANDLER" ] 175 external_deps += [ "eventhandler:libeventhandler" ] 176 } 177 178 if (is_ohos && is_standard_system && defined(global_parts_info) && 179 defined(global_parts_info.resourceschedule_qos_manager)) { 180 defines += [ "ENABLE_QOS" ] 181 external_deps += [ "qos_manager:qos" ] 182 } 183 184 subsystem_name = "commonlibrary" 185 part_name = "ets_utils" 186} 187 188group("worker_packages") { 189 deps = [ ":worker" ] 190} 191