1518678f8Sopenharmony_ci# Copyright (C) 2024 Huawei Device Co., Ltd.
2518678f8Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3518678f8Sopenharmony_ci# you may not use this file except in compliance with the License.
4518678f8Sopenharmony_ci# You may obtain a copy of the License at
5518678f8Sopenharmony_ci#
6518678f8Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7518678f8Sopenharmony_ci#
8518678f8Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9518678f8Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10518678f8Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11518678f8Sopenharmony_ci# See the License for the specific language governing permissions and
12518678f8Sopenharmony_ci# limitations under the License.
13518678f8Sopenharmony_ci
14518678f8Sopenharmony_ciif (defined(ohos_lite)) {
15518678f8Sopenharmony_ci  import("//build/lite/config/component/lite_component.gni")
16518678f8Sopenharmony_ci  import("//foundation/communication/dhcp/dhcp_lite.gni")
17518678f8Sopenharmony_ci} else {
18518678f8Sopenharmony_ci  import("//build/ohos.gni")
19518678f8Sopenharmony_ci  import("//foundation/communication/dhcp/dhcp.gni")
20518678f8Sopenharmony_ci}
21518678f8Sopenharmony_ci
22518678f8Sopenharmony_ci################################################################################
23518678f8Sopenharmony_ciif (defined(ohos_lite)) {
24518678f8Sopenharmony_ci  shared_library("dhcp_utils") {
25518678f8Sopenharmony_ci    sources = [
26518678f8Sopenharmony_ci      "src/dhcp_arp_checker.cpp",
27518678f8Sopenharmony_ci      "src/dhcp_common_utils.cpp",
28518678f8Sopenharmony_ci    ]
29518678f8Sopenharmony_ci
30518678f8Sopenharmony_ci    include_dirs = [
31518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services",
32518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/include",
33518678f8Sopenharmony_ci    ]
34518678f8Sopenharmony_ci
35518678f8Sopenharmony_ci    deps = []
36518678f8Sopenharmony_ci    external_deps = []
37518678f8Sopenharmony_ci    defines = [
38518678f8Sopenharmony_ci      "_GNU_SOURCE",
39518678f8Sopenharmony_ci      "OHOS_ARCH_LITE",
40518678f8Sopenharmony_ci    ]
41518678f8Sopenharmony_ci  }
42518678f8Sopenharmony_ci} else {
43518678f8Sopenharmony_ci  config("dhcp_common_config") {
44518678f8Sopenharmony_ci    visibility = [ ":*" ]
45518678f8Sopenharmony_ci    include_dirs = [ "$DHCP_ROOT_DIR/services/utils/include" ]
46518678f8Sopenharmony_ci  }
47518678f8Sopenharmony_ci  ohos_shared_library("dhcp_utils") {
48518678f8Sopenharmony_ci    branch_protector_ret = "pac_ret"
49518678f8Sopenharmony_ci    sanitize = {
50518678f8Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
51518678f8Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
52518678f8Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
53518678f8Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
54518678f8Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
55518678f8Sopenharmony_ci      debug = false
56518678f8Sopenharmony_ci    }
57518678f8Sopenharmony_ci    install_enable = true
58518678f8Sopenharmony_ci    sources = [
59518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/src/dhcp_arp_checker.cpp",
60518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/src/dhcp_common_utils.cpp",
61518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/src/dhcp_permission_utils.cpp",
62518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/src/dhcp_system_timer.cpp",
63518678f8Sopenharmony_ci    ]
64518678f8Sopenharmony_ci
65518678f8Sopenharmony_ci    include_dirs = [
66518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services",
67518678f8Sopenharmony_ci      "$DHCP_ROOT_DIR/services/utils/include",
68518678f8Sopenharmony_ci    ]
69518678f8Sopenharmony_ci    if (is_asan) {
70518678f8Sopenharmony_ci      defines = [ "DTFUZZ_TEST" ]
71518678f8Sopenharmony_ci    }
72518678f8Sopenharmony_ci    deps = []
73518678f8Sopenharmony_ci    external_deps = [
74518678f8Sopenharmony_ci      "ability_runtime:wantagent_innerkits",
75518678f8Sopenharmony_ci      "access_token:libaccesstoken_sdk",
76518678f8Sopenharmony_ci      "access_token:libtokenid_sdk",
77518678f8Sopenharmony_ci      "c_utils:utils",
78518678f8Sopenharmony_ci      "hilog:libhilog",
79518678f8Sopenharmony_ci      "ipc:ipc_single",
80518678f8Sopenharmony_ci      "time_service:time_client",
81518678f8Sopenharmony_ci    ]
82518678f8Sopenharmony_ci
83518678f8Sopenharmony_ci    cflags = [
84518678f8Sopenharmony_ci      "-std=c++17",
85518678f8Sopenharmony_ci      "-fno-rtti",
86518678f8Sopenharmony_ci    ]
87518678f8Sopenharmony_ci    ldflags = [
88518678f8Sopenharmony_ci      "-fPIC",
89518678f8Sopenharmony_ci      "-Wl,-E",
90518678f8Sopenharmony_ci    ]
91518678f8Sopenharmony_ci
92518678f8Sopenharmony_ci    public_configs = [ ":dhcp_common_config" ]
93518678f8Sopenharmony_ci    part_name = "dhcp"
94518678f8Sopenharmony_ci    subsystem_name = "communication"
95518678f8Sopenharmony_ci    innerapi_tags = [ "platformsdk" ]
96518678f8Sopenharmony_ci  }
97518678f8Sopenharmony_ci}
98