1# Copyright (c) 2021-2023 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_base/netmanager_base_config.gni") 16 17config("net_policy_manager_config") { 18 include_dirs = [ 19 "$INNERKITS_ROOT/include", 20 "$INNERKITS_ROOT/netpolicyclient/include", 21 "$INNERKITS_ROOT/netpolicyclient/include/proxy", 22 "$INNERKITS_ROOT/netconnclient/include", 23 "$NETCONNMANAGER_COMMON_DIR/include", 24 "$NETMANAGER_BASE_ROOT/utils/log/include", 25 "include", 26 "include/stub", 27 "$NETSYSCONTROLLER_ROOT_DIR/include", 28 "$NETSYSNATIVE_SOURCE_DIR/include/netsys", 29 "$SAMGR_MANAGER_ROOT/interfaces/innerkits/samgr_proxy/include", 30 ] 31} 32 33ohos_shared_library("net_policy_manager") { 34 sanitize = { 35 cfi = true 36 cfi_cross_dso = true 37 boundary_sanitize = true 38 all_ubsan = true 39 blocklist = "./policy_blocklist.txt" 40 debug = false 41 } 42 43 sources = [ 44 "src/common/net_policy_event_handler.cpp", 45 "src/common/net_policy_file_event_handler.cpp", 46 "src/common/net_policy_service_common.cpp", 47 "src/common/netsys_policy_wrapper.cpp", 48 "src/core/net_policy_base.cpp", 49 "src/core/net_policy_callback.cpp", 50 "src/core/net_policy_core.cpp", 51 "src/core/net_policy_file.cpp", 52 "src/core/net_policy_firewall.cpp", 53 "src/core/net_policy_rule.cpp", 54 "src/core/net_policy_traffic.cpp", 55 "src/firewall_rule/device_idle_firewall_rule.cpp", 56 "src/firewall_rule/firewall_rule.cpp", 57 "src/firewall_rule/power_save_firewall_rule.cpp", 58 "src/net_policy_service.cpp", 59 "src/stub/net_policy_callback_proxy.cpp", 60 "src/stub/net_policy_service_stub.cpp", 61 ] 62 63 configs = [ ":net_policy_manager_config" ] 64 65 deps = [ 66 "$INNERKITS_ROOT/netpolicyclient:net_policy_parcel", 67 "$INNERKITS_ROOT/netstatsclient:net_stats_manager_if", 68 "$NETCONNMANAGER_COMMON_DIR:net_service_common", 69 "$NETMANAGER_BASE_ROOT/utils:net_manager_common", 70 "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller", 71 "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp", 72 ] 73 74 cflags = [ 75 "-fvisibility=hidden", 76 "-fdata-sections", 77 "-ffunction-sections", 78 "-Os", 79 "-fstack-protector-strong", 80 "-D_FORTIFY_SOURCE=2", 81 "-O2", 82 ] 83 84 cflags_cc = [ 85 "-fvisibility-inlines-hidden", 86 "-Os", 87 "-fstack-protector-strong", 88 "-D_FORTIFY_SOURCE=2", 89 "-O2", 90 ] 91 92 ldflags = [ 93 "-Wl,--exclude-libs=ALL", 94 "-Wl,--gc-sections", 95 ] 96 97 external_deps = [ 98 "ability_base:want", 99 "ability_runtime:app_manager", 100 "common_event_service:cesfwk_innerkits", 101 "eventhandler:libeventhandler", 102 "hitrace:hitrace_meter", 103 "ipc:ipc_core", 104 "safwk:system_ability_fwk", 105 ] 106 107 defines = [ 108 "NETMGR_LOG_TAG = \"NetPolicyService\"", 109 "LOG_DOMAIN = 0xD0015B0", 110 ] 111 112 if (enable_netmgr_debug) { 113 defines += [ "NETMGR_DEBUG" ] 114 } 115 116 external_deps += [ "hilog:libhilog" ] 117 118 part_name = "netmanager_base" 119 subsystem_name = "communication" 120} 121 122ohos_static_library("net_policy_manager_static") { 123 testonly = true 124 sanitize = { 125 cfi = true 126 cfi_cross_dso = true 127 debug = false 128 } 129 sources = [ 130 "src/common/net_policy_event_handler.cpp", 131 "src/common/net_policy_file_event_handler.cpp", 132 "src/common/net_policy_service_common.cpp", 133 "src/common/netsys_policy_wrapper.cpp", 134 "src/core/net_policy_base.cpp", 135 "src/core/net_policy_callback.cpp", 136 "src/core/net_policy_core.cpp", 137 "src/core/net_policy_file.cpp", 138 "src/core/net_policy_firewall.cpp", 139 "src/core/net_policy_rule.cpp", 140 "src/core/net_policy_traffic.cpp", 141 "src/firewall_rule/device_idle_firewall_rule.cpp", 142 "src/firewall_rule/firewall_rule.cpp", 143 "src/firewall_rule/power_save_firewall_rule.cpp", 144 "src/net_policy_service.cpp", 145 "src/stub/net_policy_callback_proxy.cpp", 146 "src/stub/net_policy_service_stub.cpp", 147 ] 148 149 configs = [ ":net_policy_manager_config" ] 150 151 deps = [ 152 "$INNERKITS_ROOT/netpolicyclient:net_policy_parcel", 153 "$INNERKITS_ROOT/netstatsclient:net_stats_manager_if", 154 "$NETCONNMANAGER_COMMON_DIR:net_service_common", 155 "$NETMANAGER_BASE_ROOT/utils:net_manager_common", 156 "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller", 157 "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp", 158 ] 159 160 external_deps = [ 161 "ability_base:want", 162 "ability_runtime:app_manager", 163 "c_utils:utils", 164 "common_event_service:cesfwk_innerkits", 165 "eventhandler:libeventhandler", 166 "hitrace:hitrace_meter", 167 "ipc:ipc_core", 168 "safwk:system_ability_fwk", 169 ] 170 171 defines = [ 172 "NETMGR_LOG_TAG = \"NetPolicyService\"", 173 "LOG_DOMAIN = 0xD0015B0", 174 ] 175 176 if (enable_netmgr_debug) { 177 defines += [ "NETMGR_DEBUG" ] 178 } 179 180 external_deps += [ "hilog:libhilog" ] 181 182 part_name = "netmanager_base" 183 subsystem_name = "communication" 184} 185