# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("//commonlibrary/ets_utils/ets_utils_config.gni") import("//foundation/arkui/ace_engine/ace_config.gni") import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni") config("worker_public_config") { include_dirs = [ js_concurrent_module_common ] } ohos_shared_library("worker") { branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } include_dirs = [ "include", ets_util_path, ] public_configs = [ ":worker_public_config" ] sources = [ "../common/helper/napi_helper.cpp", "message_queue.cpp", "native_module_worker.cpp", "thread.cpp", "worker.cpp", "worker_runner.cpp", ] deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] defines = [] if (is_ohos) { defines += [ "OHOS_PLATFORM" ] } else if (is_mingw) { defines += [ "WINDOWS_PLATFORM" ] } else if (target_os == "android") { defines += [ "ANDROID_PLATFORM" ] } else if (target_os == "ios") { defines += [ "IOS_PLATFORM" ] } else if (is_mac && target_os != "android") { defines += [ "MAC_PLATFORM" ] } external_deps = [ "napi:ace_napi" ] if (is_linux && current_toolchain == host_toolchain) { external_deps += [ "innerkits:libhilog_linux" ] defines = [ "LINUX_PLATFORM", "PREVIEW", ] } else { if (is_standard_system) { external_deps += [ "hilog:libhilog", "init:libbegetutil", ] } else { external_deps += [ "hilog:libhilog" ] } } if (is_ohos && is_standard_system && !is_arkui_x) { defines += [ "ENABLE_WORKER_EVENTHANDLER" ] external_deps += [ "eventhandler:libeventhandler" ] } external_deps += [ "hitrace:hitrace_meter" ] subsystem_name = "commonlibrary" part_name = "ets_utils" relative_install_dir = "module" } ohos_source_set("worker_static") { branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } include_dirs = [ js_concurrent_module_common, "$concurrent_module/worker", "$sys_module/timer", ets_util_path, ] sources = [ "$js_concurrent_module_common/helper/napi_helper.cpp", "$sys_module/timer/timer.cpp", "message_queue.cpp", "native_module_worker.cpp", "thread.cpp", "worker.cpp", "worker_runner.cpp", ] deps = [] defines = [] external_deps = [] if (is_standard_system) { external_deps += [ "hilog:libhilog", "init:libbegetutil", ] } else { external_deps += [ "c_utils:utils", "hilog:libhilog", ] } if (is_arkui_x) { include_dirs += [ "$plugins_root/hilog/include", "$plugins_root/interfaces", "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", ] sources -= [ "$js_concurrent_module_common/helper/napi_helper.cpp", "$sys_module/timer/timer.cpp", ] defines += [ "__ARKUI_CROSS__" ] deps += [ "$plugins_root/libs/napi:napi_${target_os}", "$plugins_root/libs/uv:uv_${target_os}", "$sys_module/timer:timer_static", ] if (target_os == "android") { defines += [ "ANDROID_PLATFORM" ] } if (target_os == "ios") { defines += [ "IOS_PLATFORM" ] } } else { deps += [ "$napi_root:ace_napi" ] external_deps += [ "hitrace:hitrace_meter" ] } if (is_ohos && is_standard_system && !is_arkui_x) { defines += [ "ENABLE_WORKER_EVENTHANDLER" ] external_deps += [ "eventhandler:libeventhandler" ] } subsystem_name = "commonlibrary" part_name = "ets_utils" } group("worker_packages") { deps = [ ":worker" ] }