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
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################################################################################
23if (defined(ohos_lite)) {
24  shared_library("dhcp_utils") {
25    sources = [
26      "src/dhcp_arp_checker.cpp",
27      "src/dhcp_common_utils.cpp",
28    ]
29
30    include_dirs = [
31      "$DHCP_ROOT_DIR/services",
32      "$DHCP_ROOT_DIR/services/utils/include",
33    ]
34
35    deps = []
36    external_deps = []
37    defines = [
38      "_GNU_SOURCE",
39      "OHOS_ARCH_LITE",
40    ]
41  }
42} else {
43  config("dhcp_common_config") {
44    visibility = [ ":*" ]
45    include_dirs = [ "$DHCP_ROOT_DIR/services/utils/include" ]
46  }
47  ohos_shared_library("dhcp_utils") {
48    branch_protector_ret = "pac_ret"
49    sanitize = {
50      cfi = true  # Enable/disable control flow integrity detection
51      boundary_sanitize = true  # Enable boundary san detection
52      cfi_cross_dso = true  # Cross-SO CFI Checks
53      integer_overflow = true  # Enable integer overflow detection
54      ubsan = true  # Enable some Ubsan options
55      debug = false
56    }
57    install_enable = true
58    sources = [
59      "$DHCP_ROOT_DIR/services/utils/src/dhcp_arp_checker.cpp",
60      "$DHCP_ROOT_DIR/services/utils/src/dhcp_common_utils.cpp",
61      "$DHCP_ROOT_DIR/services/utils/src/dhcp_permission_utils.cpp",
62      "$DHCP_ROOT_DIR/services/utils/src/dhcp_system_timer.cpp",
63    ]
64
65    include_dirs = [
66      "$DHCP_ROOT_DIR/services",
67      "$DHCP_ROOT_DIR/services/utils/include",
68    ]
69    if (is_asan) {
70      defines = [ "DTFUZZ_TEST" ]
71    }
72    deps = []
73    external_deps = [
74      "ability_runtime:wantagent_innerkits",
75      "access_token:libaccesstoken_sdk",
76      "access_token:libtokenid_sdk",
77      "c_utils:utils",
78      "hilog:libhilog",
79      "ipc:ipc_single",
80      "time_service:time_client",
81    ]
82
83    cflags = [
84      "-std=c++17",
85      "-fno-rtti",
86    ]
87    ldflags = [
88      "-fPIC",
89      "-Wl,-E",
90    ]
91
92    public_configs = [ ":dhcp_common_config" ]
93    part_name = "dhcp"
94    subsystem_name = "communication"
95    innerapi_tags = [ "platformsdk" ]
96  }
97}
98