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 "src/hi_app_event_report.cpp", 45 ] 46 47 part_name = "netstack" 48 subsystem_name = "communication" 49 public_configs = [ ":napi_utils_public_config" ] 50 51 public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 52 external_deps = [ 53 "cJSON:cjson", 54 "c_utils:utils", 55 "hilog:libhilog", 56 "napi:ace_napi", 57 ] 58 59 if (!build_ohos_sdk) { 60 external_deps += [ 61 "hiappevent:hiappevent_innerapi", 62 "time_service:time_client", 63 "ability_runtime:wantagent_innerkits", 64 ] 65 } 66 67 if (defined(global_parts_info) && 68 defined(global_parts_info.communication_netmanager_base) && 69 global_parts_info.communication_netmanager_base && is_ohos && 70 is_standard_system && !is_arkui_x && product_name != "ohos-sdk") { 71 defines = [ "HAS_NETMANAGER_BASE=1" ] 72 external_deps += [ 73 "ffrt:libffrt", 74 ] 75 } else { 76 defines = [ "HAS_NETMANAGER_BASE=0" ] 77 } 78} 79 80ohos_static_library("napi_utils_static") { 81 sanitize = { 82 cfi = true 83 cfi_cross_dso = true 84 debug = false 85 } 86 87 branch_protector_ret = "pac_ret" 88 89 sources = [ 90 "src/base_context.cpp", 91 "src/event_listener.cpp", 92 "src/event_manager.cpp", 93 "src/module_template.cpp", 94 "src/napi_utils.cpp", 95 "src/secure_char.cpp", 96 "src/timing.cpp", 97 "src/hi_app_event_report.cpp", 98 ] 99 100 101 public_configs = [ ":napi_utils_public_config" ] 102 103 external_deps = [ "cJSON:cjson" ] 104 105 if (!build_ohos_sdk) { 106 external_deps += [ 107 "hiappevent:hiappevent_innerapi", 108 "time_service:time_client", 109 "ability_runtime:wantagent_innerkits", 110 ] 111 } 112 113 if (defined(global_parts_info) && 114 defined(global_parts_info.communication_netmanager_base) && 115 global_parts_info.communication_netmanager_base && is_ohos && 116 is_standard_system && !is_arkui_x && product_name != "ohos-sdk") { 117 defines = [ "HAS_NETMANAGER_BASE=1" ] 118 external_deps += [ "ffrt:libffrt" ] 119 } else { 120 defines = [ "HAS_NETMANAGER_BASE=0" ] 121 } 122 123 if (current_os == "ohos") { 124 public_deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 125 external_deps += [ 126 "c_utils:utils", 127 "hilog:libhilog", 128 "napi:ace_napi", 129 ] 130 } else { 131 external_deps += [ 132 "napi:ace_napi", 133 "bounds_checking_function:libsec_static", 134 ] 135 } 136} 137