1# Copyright (c) 2023-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/netmanager_ext/netmanager_ext_config.gni") 16 17config("net_vpn_manager_config") { 18 include_dirs = [ 19 "$EXT_INNERKITS_ROOT/include", 20 "$EXT_INNERKITS_ROOT/netvpnclient/include", 21 "$EXT_INNERKITS_ROOT/netvpnclient/include/ipc", 22 "$VPNMANAGER_SOURCE_DIR/include", 23 "$VPNMANAGER_SOURCE_DIR/include/ipc", 24 "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include", 25 "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpnext/include", 26 ] 27 28 defines = [ 29 "NETMGR_LOG_TAG = \"NetworkVpnManager\"", 30 "LOG_DOMAIN = 0xD0015B0", 31 ] 32 33 if (enable_netmgr_ext_debug) { 34 defines += [ "NETMGR_DEBUG" ] 35 } 36} 37 38net_vpn_manager_sources = [ 39 "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpn/src/networkvpn_service.cpp", 40 "$VPNMANAGER_SOURCE_DIR/src/extended_vpn_ctl.cpp", 41 "$VPNMANAGER_SOURCE_DIR/src/net_vpn_impl.cpp", 42 "$VPNMANAGER_SOURCE_DIR/src/networkvpn_hisysevent.cpp", 43 "$VPN_INNERKITS_SOURCE_DIR/src/vpn_config.cpp", 44] 45 46if (netmanager_ext_feature_sysvpn) { 47 net_vpn_manager_sources += [ 48 "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpn/src/vpn_database_helper.cpp", 49 "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpn/src/vpn_encryption_util.cpp", 50 "$VPN_INNERKITS_SOURCE_DIR/src/ipsecvpn_config.cpp", 51 "$VPN_INNERKITS_SOURCE_DIR/src/l2tpvpn_config.cpp", 52 "$VPN_INNERKITS_SOURCE_DIR/src/openvpn_config.cpp", 53 "$VPN_INNERKITS_SOURCE_DIR/src/sysvpn_config.cpp", 54 "$VPN_INNERKITS_SOURCE_DIR/src/vpn_data_bean.cpp", 55 "$VPNMANAGER_SOURCE_DIR/src/multi_vpn_helper.cpp", 56 "$VPNMANAGER_SOURCE_DIR/src/vpn_template_processor.cpp", 57 ] 58} 59 60net_vpn_manager_deps = [ "$NETMANAGER_EXT_ROOT/utils:net_event_report" ] 61 62net_vpn_manager_external_deps = [ 63 "ability_base:want", 64 "ability_base:zuri", 65 "ability_runtime:ability_manager", 66 "ability_runtime:app_manager", 67 "bundle_framework:appexecfwk_base", 68 "bundle_framework:appexecfwk_core", 69 "cJSON:cjson", 70 "c_utils:utils", 71 "common_event_service:cesfwk_innerkits", 72 "eventhandler:libeventhandler", 73 "ffrt:libffrt", 74 "hilog:libhilog", 75 "hisysevent:libhisysevent", 76 "huks:libhukssdk", 77 "init:libbegetutil", 78 "ipc:ipc_core", 79 "netmanager_base:net_conn_manager_if", 80 "netmanager_base:net_data_share", 81 "netmanager_base:net_manager_common", 82 "netmanager_base:net_native_manager_if", 83 "netmanager_base:net_service_common", 84 "netmanager_base:netsys_controller", 85 "os_account:os_account_innerkits", 86 "relational_store:native_rdb", 87 "safwk:system_ability_fwk", 88 "samgr:samgr_proxy", 89] 90 91ohos_shared_library("net_vpn_manager") { 92 sanitize = { 93 cfi = true 94 cfi_cross_dso = true 95 blocklist = "./cfi_blocklist.txt" 96 debug = false 97 } 98 99 branch_protector_ret = "pac_ret" 100 101 configs = [ ":net_vpn_manager_config" ] 102 103 defines = [] 104 if (netmanager_ext_feature_vpn_for_user0) { 105 defines += [ "ENABLE_VPN_FOR_USER0" ] 106 } 107 108 sources = net_vpn_manager_sources 109 deps = net_vpn_manager_deps 110 deps += [ "$EXT_INNERKITS_ROOT/netvpnclient:networkvpn_interface_stub" ] 111 external_deps = net_vpn_manager_external_deps 112 113 cflags = common_cflags + memory_optimization_cflags 114 defines = [] 115 if (netmanager_ext_feature_vpn_for_user0) { 116 defines += [ "ENABLE_VPN_FOR_USER0" ] 117 } 118 cflags_cc = common_cflags + memory_optimization_cflags_cc 119 120 if (netmanager_ext_feature_sysvpn) { 121 cflags += sysvpn_flags 122 cflags_cc += sysvpn_flags 123 sources += [ 124 "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp", 125 "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp", 126 "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp", 127 ] 128 } 129 130 ldflags = memory_optimization_ldflags 131 132 part_name = "netmanager_ext" 133 subsystem_name = "communication" 134} 135 136ohos_static_library("net_vpn_manager_static") { 137 sanitize = { 138 cfi = true 139 cfi_cross_dso = true 140 blocklist = "./cfi_blocklist.txt" 141 debug = false 142 } 143 144 branch_protector_ret = "pac_ret" 145 146 configs = [ ":net_vpn_manager_config" ] 147 148 sources = net_vpn_manager_sources 149 150 if (netmanager_ext_feature_sysvpn) { 151 cflags = sysvpn_flags 152 cflags_cc = sysvpn_flags 153 sources += [ 154 "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp", 155 "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp", 156 "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp", 157 ] 158 } 159 160 deps = net_vpn_manager_deps 161 deps += [ "$EXT_INNERKITS_ROOT/netvpnclient:networkvpn_interface_stub" ] 162 external_deps = net_vpn_manager_external_deps 163 164 part_name = "netmanager_ext" 165 subsystem_name = "communication" 166} 167