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/config/components/ets_frontend/es2abc_config.gni") 15import("//build/ohos.gni") 16import("//commonlibrary/ets_utils/ets_utils_config.gni") 17 18# compile .js to .abc. 19es2abc_gen_abc("gen_utils_abc") { 20 src_js = rebase_path("src/utils_js.ts") 21 dst_file = rebase_path(target_out_dir + "/utils.abc") 22 in_puts = [ "src/utils_js.ts" ] 23 out_puts = [ target_out_dir + "/utils.abc" ] 24 extra_args = [ "--module" ] 25} 26 27abc_output_path = get_label_info(":utils_abc", "target_out_dir") 28 29gen_js_obj("utils_js") { 30 input = "src/utils_js.ts" 31 if (is_arkui_x) { 32 utils_js_obj_path = abc_output_path + "/utils.c" 33 } else { 34 utils_js_obj_path = abc_output_path + "/utils.o" 35 } 36 output = utils_js_obj_path 37} 38 39gen_js_obj("utils_abc") { 40 input = "$target_out_dir/utils.abc" 41 if (is_arkui_x) { 42 utils_js_obj_path = abc_output_path + "/utils_abc.c" 43 } else { 44 utils_js_obj_path = abc_output_path + "/utils_abc.o" 45 } 46 output = utils_js_obj_path 47 dep = ":gen_utils_abc" 48 print("Debug info gen_utils_abc file path: ", input) 49} 50 51locks_sources = [ 52 "condition/condition_manager.cpp", 53 "condition/condition_task.cpp", 54 "condition/condition_variable.cpp", 55 "json/json_manager.cpp", 56 "locks/async_lock.cpp", 57 "locks/async_lock_manager.cpp", 58 "locks/deadlock_helpers.cpp", 59 "locks/graph.cpp", 60 "locks/lock_request.cpp", 61 "native_utils_module.cpp", 62 "utils.cpp", 63] 64 65concurrent_helper_sources = [ "../common/helper/napi_helper.cpp" ] 66 67ohos_shared_library("utils") { 68 branch_protector_ret = "pac_ret" 69 sanitize = { 70 cfi = true 71 cfi_cross_dso = true 72 debug = false 73 } 74 75 defines = [] 76 deps = [ ":utils_static" ] 77 external_deps = [ "napi:ace_napi" ] 78 79 if (is_ohos) { 80 defines += [ "OHOS_PLATFORM" ] 81 } else if (is_mingw) { 82 defines += [ "WINDOWS_PLATFORM" ] 83 } else if (target_os == "android") { 84 defines += [ "ANDROID_PLATFORM" ] 85 } else if (target_os == "ios") { 86 defines += [ "IOS_PLATFORM" ] 87 } else if (is_mac) { 88 defines += [ "MAC_PLATFORM" ] 89 } 90 91 if (is_linux && current_toolchain == host_toolchain) { 92 defines = [ 93 "LINUX_PLATFORM", 94 "PREVIEW", 95 ] 96 external_deps += [ "innerkits:libhilog_linux" ] 97 } else { 98 external_deps += [ "hilog:libhilog" ] 99 } 100 101 external_deps += [ "hitrace:hitrace_meter" ] 102 103 subsystem_name = "commonlibrary" 104 part_name = "ets_utils" 105 relative_install_dir = "module/arkts" 106} 107 108ohos_source_set("utils_static") { 109 branch_protector_ret = "pac_ret" 110 sanitize = { 111 cfi = true 112 cfi_cross_dso = true 113 debug = false 114 } 115 include_dirs = [ 116 js_concurrent_module_common, 117 ets_util_path, 118 ] 119 120 sources = locks_sources 121 sources += concurrent_helper_sources 122 123 defines = [] 124 deps = [ 125 ":utils_abc", 126 ":utils_js", 127 "${ets_util_path}/js_sys_module/timer:timer", 128 ] 129 external_deps = [ "napi:ace_napi" ] 130 131 if (is_arkui_x) { 132 include_dirs += [ 133 "$plugins_root/hilog/include", 134 "$plugins_root/interfaces", 135 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 136 ] 137 138 sources -= concurrent_helper_sources 139 140 defines += [ "__ARKUI_CROSS__" ] 141 if (target_os == "android") { 142 defines += [ "ANDROID_PLATFORM" ] 143 } 144 if (target_os == "ios") { 145 defines += [ "IOS_PLATFORM" ] 146 } 147 148 deps -= [ "${ets_util_path}/js_sys_module/timer:timer" ] 149 deps += [ 150 "$plugins_root/libs/napi:napi_${target_os}", 151 "$plugins_root/libs/uv:uv_${target_os}", 152 "$sys_module/timer:timer_static", 153 ] 154 155 external_deps -= [ "napi:ace_napi" ] 156 } else { 157 external_deps += [ 158 "hilog:libhilog", 159 "hitrace:hitrace_meter", 160 ] 161 } 162 163 subsystem_name = "commonlibrary" 164 part_name = "ets_utils" 165} 166 167group("utils_packages") { 168 deps = [ ":utils" ] 169} 170