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/ohos.gni") 15import("//foundation/communication/netmanager_ext/netmanager_ext_config.gni") 16 17config("netfirewall_manager_config") { 18 include_dirs = [ 19 "$EXT_INNERKITS_ROOT/include", 20 "$EXT_INNERKITS_ROOT/netfirewallclient/include", 21 "$NETCONNMANAGER_COMMON_DIR/include", 22 "$NETMANAGER_EXT_ROOT/utils/log/include", 23 "$NETFIREWALLMANAGER_SOURCE_DIR/include", 24 "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include", 25 "$NETSYSCONTROLLER_ROOT_DIR/include", 26 "$NETCONNMANAGER_UTILS_DIR/common_utils/include", 27 ] 28 29 defines = [ 30 "NETMGR_EXT_LOG_TAG = \"NetFirewallManager\"", 31 "LOG_DOMAIN = 0xD0015B0", 32 "DEFAULT_RULE_FILE = \"/system/etc/communication/netmanager_ext/default_firewall_rule.json\"", 33 ] 34 35 if (enable_netmgr_ext_debug) { 36 defines += [ "NETMGR_DEBUG" ] 37 } 38} 39 40netfirewall_manager_sources = [ 41 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_database.cpp", 42 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_db_helper.cpp", 43 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_default_rule_parser.cpp", 44 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_hisysevent.cpp", 45 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_intercept_recorder.cpp", 46 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_policy_manager.cpp", 47 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_preference_helper.cpp", 48 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_rule_manager.cpp", 49 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_rule_native_helper.cpp", 50 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_service.cpp", 51 "$NETFIREWALLMANAGER_SOURCE_DIR/src/netfirewall_stub.cpp", 52] 53 54netfirewall_manager_deps = [ "$NETMANAGER_EXT_ROOT/utils:net_event_report" ] 55 56netfirewall_manager_external_deps = [ 57 "ability_base:want", 58 "ability_base:zuri", 59 "bundle_framework:appexecfwk_base", 60 "bundle_framework:appexecfwk_core", 61 "cJSON:cjson", 62 "c_utils:utils", 63 "common_event_service:cesfwk_innerkits", 64 "ffrt:libffrt", 65 "hilog:libhilog", 66 "hisysevent:libhisysevent", 67 "hitrace:hitrace_meter", 68 "ipc:ipc_core", 69 "netmanager_base:net_conn_manager_if", 70 "netmanager_base:net_data_share", 71 "netmanager_base:net_manager_common", 72 "netmanager_base:net_native_manager_if", 73 "netmanager_base:netsys_controller", 74 "os_account:os_account_innerkits", 75 "preferences:native_preferences", 76 "relational_store:native_rdb", 77 "safwk:system_ability_fwk", 78 "samgr:samgr_proxy", 79] 80 81ohos_shared_library("netfirewall_manager") { 82 sanitize = { 83 cfi = true 84 cfi_cross_dso = true 85 debug = false 86 } 87 88 configs = [ 89 ":netfirewall_manager_config", 90 "$NETMANAGER_EXT_ROOT/resource:coverage_flags", 91 ] 92 93 sources = netfirewall_manager_sources 94 deps = netfirewall_manager_deps 95 external_deps = netfirewall_manager_external_deps 96 97 cflags = memory_optimization_cflags 98 cflags += [ 99 "-fstack-protector-strong", 100 "-D_FORTIFY_SOURCE=2", 101 "-O2", 102 ] 103 104 cflags_cc = memory_optimization_cflags_cc 105 cflags_cc += [ 106 "-fstack-protector-strong", 107 "-D_FORTIFY_SOURCE=2", 108 "-O2", 109 ] 110 111 deps += [ "$EXT_INNERKITS_ROOT/netfirewallclient:netfirewall_parcel" ] 112 113 ldflags = memory_optimization_ldflags 114 115 part_name = "netmanager_ext" 116 subsystem_name = "communication" 117} 118 119ohos_static_library("netfirewall_manager_static") { 120 sanitize = { 121 cfi = true 122 cfi_cross_dso = true 123 debug = false 124 } 125 126 configs = [ 127 ":netfirewall_manager_config", 128 "$NETMANAGER_EXT_ROOT/resource:coverage_flags", 129 ] 130 131 sources = netfirewall_manager_sources 132 deps = netfirewall_manager_deps 133 external_deps = netfirewall_manager_external_deps 134 135 part_name = "netmanager_ext" 136 subsystem_name = "communication" 137} 138 139ohos_prebuilt_etc("netfirewall_default_rule") { 140 source = "$NETMANAGER_EXT_ROOT/services/netfirewallmanager/config/default_firewall_rule.json" 141 install_enable = true 142 relative_install_dir = "communication/netmanager_ext" 143 part_name = "netmanager_ext" 144 subsystem_name = "communication" 145} 146