1# Copyright (c) 2022-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("//foundation/communication/netstack/netstack_config.gni") 16 17config("napi_utils_public_config") { 18 include_dirs = [ 19 "include", 20 "$NETSTACK_DIR/utils/log/include", 21 ] 22 if (current_os != "ohos") { 23 cflags = [ "-std=c++17" ] 24 } 25} 26 27ohos_static_library("napi_utils") { 28 sanitize = { 29 cfi = true 30 cfi_cross_dso = true 31 debug = false 32 } 33 34 branch_protector_ret = "pac_ret" 35 36 sources = [ 37 "src/base_context.cpp", 38 "src/event_listener.cpp", 39 "src/event_manager.cpp", 40 "src/module_template.cpp", 41 "src/napi_utils.cpp", 42 "src/secure_char.cpp", 43 "src/timing.cpp", 44 ] 45 46 part_name = "netstack" 47 subsystem_name = "communication" 48 public_configs = [ ":napi_utils_public_config" ] 49 50 public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 51 external_deps = [ 52 "cJSON:cjson", 53 "c_utils:utils", 54 "hilog:libhilog", 55 "napi:ace_napi", 56 ] 57 58 if (defined(global_parts_info) && 59 defined(global_parts_info.communication_netmanager_base) && 60 global_parts_info.communication_netmanager_base && is_ohos && 61 is_standard_system && !is_arkui_x && product_name != "ohos-sdk") { 62 defines = [ "HAS_NETMANAGER_BASE=1" ] 63 external_deps += [ "ffrt:libffrt" ] 64 } else { 65 defines = [ "HAS_NETMANAGER_BASE=0" ] 66 } 67} 68 69ohos_static_library("napi_utils_static") { 70 sanitize = { 71 cfi = true 72 cfi_cross_dso = true 73 debug = false 74 } 75 76 branch_protector_ret = "pac_ret" 77 78 sources = [ 79 "src/base_context.cpp", 80 "src/event_listener.cpp", 81 "src/event_manager.cpp", 82 "src/module_template.cpp", 83 "src/napi_utils.cpp", 84 "src/secure_char.cpp", 85 "src/timing.cpp", 86 ] 87 88 public_configs = [ ":napi_utils_public_config" ] 89 90 external_deps = [ "cJSON:cjson" ] 91 92 if (defined(global_parts_info) && 93 defined(global_parts_info.communication_netmanager_base) && 94 global_parts_info.communication_netmanager_base && is_ohos && 95 is_standard_system && !is_arkui_x && product_name != "ohos-sdk") { 96 defines = [ "HAS_NETMANAGER_BASE=1" ] 97 external_deps += [ "ffrt:libffrt" ] 98 } else { 99 defines = [ "HAS_NETMANAGER_BASE=0" ] 100 } 101 102 if (current_os == "ohos") { 103 public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 104 external_deps += [ 105 "c_utils:utils", 106 "hilog:libhilog", 107 "napi:ace_napi", 108 ] 109 } else { 110 public_deps = [ 111 "$ARKUI_ROOT/napi:ace_napi", 112 "$THIRD_PARTY_ROOT/bounds_checking_function:libsec_static", 113 ] 114 } 115} 116