1# Copyright (C) 2021-2022 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 14if (defined(ohos_lite)) { 15 import("//build/lite/config/component/lite_component.gni") 16 import("//foundation/communication/dhcp/dhcp_lite.gni") 17} else { 18 import("//build/ohos.gni") 19 import("//foundation/communication/dhcp/dhcp.gni") 20} 21 22################################################################################ 23local_base_include_dirs = [ 24 "$DHCP_ROOT_DIR/services", 25 "$DHCP_ROOT_DIR/services/dhcp_server/include", 26 "$DHCP_ROOT_DIR/interfaces", 27 "$DHCP_ROOT_DIR/interfaces/kits/c", 28 "$DHCP_ROOT_DIR/interfaces/inner_api", 29 "$DHCP_ROOT_DIR/interfaces/inner_api/include", 30 "$DHCP_ROOT_DIR/frameworks/native/include", 31 "$DHCP_ROOT_DIR/frameworks/native/interfaces", 32 "$DHCP_ROOT_DIR/frameworks/native/src", 33 "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc", 34 "$DHCP_ROOT_DIR/services/dhcp_client/include", 35 "$DHCP_ROOT_DIR/services/utils/include", 36] 37 38if (defined(ohos_lite)) { 39 dhcp_hilog_enable = true 40 shared_library("dhcp_server") { 41 sources = [ 42 "src/address_utils.cpp", 43 "src/common_util.cpp", 44 "src/dhcp_address_pool.cpp", 45 "src/dhcp_argument.cpp", 46 "src/dhcp_binding.cpp", 47 "src/dhcp_config.cpp", 48 "src/dhcp_dhcpd.cpp", 49 "src/dhcp_function.cpp", 50 "src/dhcp_option.cpp", 51 "src/dhcp_s_server.cpp", 52 "src/dhcp_server_callback_proxy_lite.cpp", 53 "src/dhcp_server_feature_lite.cpp", 54 "src/dhcp_server_service_impl.cpp", 55 "src/dhcp_server_stub_lite.cpp", 56 ] 57 58 include_dirs = local_base_include_dirs 59 include_dirs += [ 60 "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", 61 "//third_party/bounds_checking_function/include", 62 "//foundation/systemabilitymgr/samgr_lite/interfaces/innerkits/registry", 63 "//foundation/systemabilitymgr/samgr_lite/interfaces/innerkits/samgr", 64 ] 65 66 deps = [ 67 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 68 "//foundation/systemabilitymgr/samgr_lite/samgr:samgr", 69 ] 70 71 external_deps = [ "bounds_checking_function:libsec_shared" ] 72 73 configs -= [ "//build/lite/config:language_cpp" ] 74 cflags = [ 75 "-std=c++17", 76 "-fno-rtti", 77 ] 78 cflags_cc = [ 79 "-std=c++17", 80 "-fno-rtti", 81 ] 82 83 defines = [ 84 "_GNU_SOURCE", 85 "OHOS_ARCH_LITE", 86 ] 87 if (dhcp_hilog_enable) { 88 deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ] 89 defines += [ "DHCP_HILOG_ENABLE" ] 90 } 91 } 92} else { 93 local_base_sources = [ 94 "src/address_utils.cpp", 95 "src/common_util.cpp", 96 "src/dhcp_address_pool.cpp", 97 "src/dhcp_argument.cpp", 98 "src/dhcp_binding.cpp", 99 "src/dhcp_config.cpp", 100 "src/dhcp_dhcpd.cpp", 101 "src/dhcp_function.cpp", 102 "src/dhcp_option.cpp", 103 "src/dhcp_s_server.cpp", 104 "src/dhcp_server_death_recipient.cpp", 105 "src/dhcp_server_service_impl.cpp", 106 ] 107 config("dhcp_manager_service_header") { 108 visibility = [ ":*" ] 109 include_dirs = local_base_include_dirs 110 } 111 112 ohos_shared_library("dhcp_server") { 113 branch_protector_ret = "pac_ret" 114 sanitize = { 115 cfi = true # Enable/disable control flow integrity detection 116 boundary_sanitize = true # Enable boundary san detection 117 cfi_cross_dso = true # Cross-SO CFI Checks 118 integer_overflow = true # Enable integer overflow detection 119 ubsan = true # Enable some Ubsan options 120 debug = false 121 } 122 install_enable = true 123 sources = local_base_sources 124 sources += [ 125 "src/dhcp_server_callback_proxy.cpp", 126 "src/dhcp_server_stub.cpp", 127 ] 128 129 include_dirs = local_base_include_dirs 130 deps = [ "$DHCP_ROOT_DIR/services/utils:dhcp_utils" ] 131 external_deps = [ 132 "c_utils:utils", 133 "hilog:libhilog", 134 "ipc:ipc_single", 135 "safwk:system_ability_fwk", 136 "samgr:samgr_proxy", 137 ] 138 139 cflags_cc = memory_optimization_cflags_cc 140 cflags_cc += [ 141 "-std=c++17", 142 "-fno-rtti", 143 ] 144 ldflags = memory_optimization_ldflags 145 ldflags += [ 146 "-fPIC", 147 "-Wl,-E", 148 ] 149 shlib_type = "sa" 150 part_name = "dhcp" 151 subsystem_name = "communication" 152 } 153 ohos_static_library("dhcp_server_static") { 154 branch_protector_ret = "pac_ret" 155 sanitize = { 156 cfi = true # Enable/disable control flow integrity detection 157 boundary_sanitize = true # Enable boundary san detection 158 cfi_cross_dso = true # Cross-SO CFI Checks 159 integer_overflow = true # Enable integer overflow detection 160 ubsan = true # Enable some Ubsan options 161 debug = false 162 } 163 sources = local_base_sources 164 sources += [ 165 "src/dhcp_server_callback_proxy.cpp", 166 "src/dhcp_server_stub.cpp", 167 ] 168 169 include_dirs = local_base_include_dirs 170 deps = [ "$DHCP_ROOT_DIR/services/utils:dhcp_utils" ] 171 external_deps = [ 172 "c_utils:utils", 173 "hilog:libhilog", 174 "ipc:ipc_single", 175 "safwk:system_ability_fwk", 176 "samgr:samgr_proxy", 177 ] 178 179 cflags_cc = memory_optimization_cflags_cc 180 cflags_cc += [ 181 "-std=c++17", 182 "-fno-rtti", 183 ] 184 ldflags = memory_optimization_ldflags 185 ldflags += [ 186 "-fPIC", 187 "-Wl,-E", 188 ] 189 part_name = "dhcp" 190 subsystem_name = "communication" 191 } 192} 193