1# Copyright (c) 2024 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 17locks_sources = [ 18 "json/json_manager.cpp", 19 "locks/async_lock.cpp", 20 "locks/async_lock_manager.cpp", 21 "locks/deadlock_helpers.cpp", 22 "locks/graph.cpp", 23 "locks/lock_request.cpp", 24 "native_utils_module.cpp", 25 "utils.cpp", 26] 27 28concurrent_helper_sources = [ "../common/helper/napi_helper.cpp" ] 29 30ohos_shared_library("utils") { 31 branch_protector_ret = "pac_ret" 32 sanitize = { 33 cfi = true 34 cfi_cross_dso = true 35 debug = false 36 } 37 include_dirs = [ 38 js_concurrent_module_common, 39 ets_util_path, 40 ] 41 42 sources = locks_sources 43 sources += concurrent_helper_sources 44 45 defines = [] 46 deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] 47 external_deps = [ "napi:ace_napi" ] 48 49 if (is_ohos) { 50 defines += [ "OHOS_PLATFORM" ] 51 } else if (is_mingw) { 52 defines += [ "WINDOWS_PLATFORM" ] 53 } else if (target_os == "android") { 54 defines += [ "ANDROID_PLATFORM" ] 55 } else if (target_os == "ios") { 56 defines += [ "IOS_PLATFORM" ] 57 } else if (is_mac) { 58 defines += [ "MAC_PLATFORM" ] 59 } 60 61 if (is_linux && current_toolchain == host_toolchain) { 62 defines = [ 63 "LINUX_PLATFORM", 64 "PREVIEW", 65 ] 66 external_deps += [ "innerkits:libhilog_linux" ] 67 } else { 68 external_deps += [ "hilog:libhilog" ] 69 } 70 71 external_deps += [ "hitrace:hitrace_meter" ] 72 73 subsystem_name = "commonlibrary" 74 part_name = "ets_utils" 75 relative_install_dir = "module/arkts" 76} 77 78ohos_source_set("utils_static") { 79 branch_protector_ret = "pac_ret" 80 sanitize = { 81 cfi = true 82 cfi_cross_dso = true 83 debug = false 84 } 85 include_dirs = [ 86 js_concurrent_module_common, 87 ets_util_path, 88 ] 89 90 sources = locks_sources 91 sources += concurrent_helper_sources 92 93 defines = [] 94 deps = [ "${ets_util_path}/js_sys_module/timer:timer" ] 95 external_deps = [ "napi:ace_napi" ] 96 97 if (is_arkui_x) { 98 include_dirs += [ 99 "$plugins_root/hilog/include", 100 "$plugins_root/interfaces", 101 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 102 ] 103 104 sources -= concurrent_helper_sources 105 106 defines += [ "__ARKUI_CROSS__" ] 107 if (target_os == "android") { 108 defines += [ "ANDROID_PLATFORM" ] 109 } 110 if (target_os == "ios") { 111 defines += [ "IOS_PLATFORM" ] 112 } 113 114 deps -= [ "${ets_util_path}/js_sys_module/timer:timer" ] 115 deps += [ 116 "$plugins_root/libs/napi:napi_${target_os}", 117 "$plugins_root/libs/uv:uv_${target_os}", 118 "$sys_module/timer:timer_static", 119 ] 120 121 external_deps -= [ "napi:ace_napi" ] 122 } else { 123 external_deps += [ 124 "hilog:libhilog", 125 "hitrace:hitrace_meter", 126 ] 127 } 128 129 subsystem_name = "commonlibrary" 130 part_name = "ets_utils" 131} 132 133group("utils_packages") { 134 deps = [ ":utils" ] 135} 136