1518678f8Sopenharmony_ci# Copyright (C) 2021-2022 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_cilocal_base_include_dirs = [
24518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/services",
25518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/services/dhcp_server/include",
26518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces",
27518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/kits/c",
28518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/inner_api",
29518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/inner_api/include",
30518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/include",
31518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/interfaces",
32518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/src",
33518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc",
34518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/services/dhcp_client/include",
35518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/services/utils/include",
36518678f8Sopenharmony_ci]
37518678f8Sopenharmony_ci
38518678f8Sopenharmony_ciif (defined(ohos_lite)) {
39518678f8Sopenharmony_ci  dhcp_hilog_enable = true
40518678f8Sopenharmony_ci  shared_library("dhcp_server") {
41518678f8Sopenharmony_ci    sources = [
42518678f8Sopenharmony_ci      "src/address_utils.cpp",
43518678f8Sopenharmony_ci      "src/common_util.cpp",
44518678f8Sopenharmony_ci      "src/dhcp_address_pool.cpp",
45518678f8Sopenharmony_ci      "src/dhcp_argument.cpp",
46518678f8Sopenharmony_ci      "src/dhcp_binding.cpp",
47518678f8Sopenharmony_ci      "src/dhcp_config.cpp",
48518678f8Sopenharmony_ci      "src/dhcp_dhcpd.cpp",
49518678f8Sopenharmony_ci      "src/dhcp_function.cpp",
50518678f8Sopenharmony_ci      "src/dhcp_option.cpp",
51518678f8Sopenharmony_ci      "src/dhcp_s_server.cpp",
52518678f8Sopenharmony_ci      "src/dhcp_server_callback_proxy_lite.cpp",
53518678f8Sopenharmony_ci      "src/dhcp_server_feature_lite.cpp",
54518678f8Sopenharmony_ci      "src/dhcp_server_service_impl.cpp",
55518678f8Sopenharmony_ci      "src/dhcp_server_stub_lite.cpp",
56518678f8Sopenharmony_ci    ]
57518678f8Sopenharmony_ci
58518678f8Sopenharmony_ci    include_dirs = local_base_include_dirs
59518678f8Sopenharmony_ci    include_dirs += [
60518678f8Sopenharmony_ci      "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
61518678f8Sopenharmony_ci      "//third_party/bounds_checking_function/include",
62518678f8Sopenharmony_ci      "//foundation/systemabilitymgr/samgr_lite/interfaces/innerkits/registry",
63518678f8Sopenharmony_ci      "//foundation/systemabilitymgr/samgr_lite/interfaces/innerkits/samgr",
64518678f8Sopenharmony_ci    ]
65518678f8Sopenharmony_ci
66518678f8Sopenharmony_ci    deps = [
67518678f8Sopenharmony_ci      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
68518678f8Sopenharmony_ci      "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
69518678f8Sopenharmony_ci    ]
70518678f8Sopenharmony_ci
71518678f8Sopenharmony_ci    external_deps = [ "bounds_checking_function:libsec_shared" ]
72518678f8Sopenharmony_ci
73518678f8Sopenharmony_ci    cflags_cc = [ "-fno-rtti" ]
74518678f8Sopenharmony_ci
75518678f8Sopenharmony_ci    defines = [
76518678f8Sopenharmony_ci      "_GNU_SOURCE",
77518678f8Sopenharmony_ci      "OHOS_ARCH_LITE",
78518678f8Sopenharmony_ci    ]
79518678f8Sopenharmony_ci    if (dhcp_hilog_enable) {
80518678f8Sopenharmony_ci      deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ]
81518678f8Sopenharmony_ci      defines += [ "DHCP_HILOG_ENABLE" ]
82518678f8Sopenharmony_ci    }
83518678f8Sopenharmony_ci  }
84518678f8Sopenharmony_ci} else {
85518678f8Sopenharmony_ci  local_base_sources = [
86518678f8Sopenharmony_ci    "src/address_utils.cpp",
87518678f8Sopenharmony_ci    "src/common_util.cpp",
88518678f8Sopenharmony_ci    "src/dhcp_address_pool.cpp",
89518678f8Sopenharmony_ci    "src/dhcp_argument.cpp",
90518678f8Sopenharmony_ci    "src/dhcp_binding.cpp",
91518678f8Sopenharmony_ci    "src/dhcp_config.cpp",
92518678f8Sopenharmony_ci    "src/dhcp_dhcpd.cpp",
93518678f8Sopenharmony_ci    "src/dhcp_function.cpp",
94518678f8Sopenharmony_ci    "src/dhcp_option.cpp",
95518678f8Sopenharmony_ci    "src/dhcp_s_server.cpp",
96518678f8Sopenharmony_ci    "src/dhcp_server_death_recipient.cpp",
97518678f8Sopenharmony_ci    "src/dhcp_server_service_impl.cpp",
98518678f8Sopenharmony_ci  ]
99518678f8Sopenharmony_ci  config("dhcp_manager_service_header") {
100518678f8Sopenharmony_ci    visibility = [ ":*" ]
101518678f8Sopenharmony_ci    include_dirs = local_base_include_dirs
102518678f8Sopenharmony_ci  }
103518678f8Sopenharmony_ci
104518678f8Sopenharmony_ci  ohos_shared_library("dhcp_server") {
105518678f8Sopenharmony_ci    branch_protector_ret = "pac_ret"
106518678f8Sopenharmony_ci    sanitize = {
107518678f8Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
108518678f8Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
109518678f8Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
110518678f8Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
111518678f8Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
112518678f8Sopenharmony_ci      debug = false
113518678f8Sopenharmony_ci    }
114518678f8Sopenharmony_ci    install_enable = true
115518678f8Sopenharmony_ci    sources = local_base_sources
116518678f8Sopenharmony_ci    sources += [
117518678f8Sopenharmony_ci      "src/dhcp_server_callback_proxy.cpp",
118518678f8Sopenharmony_ci      "src/dhcp_server_stub.cpp",
119518678f8Sopenharmony_ci    ]
120518678f8Sopenharmony_ci
121518678f8Sopenharmony_ci    include_dirs = local_base_include_dirs
122518678f8Sopenharmony_ci    deps = [ "$DHCP_ROOT_DIR/services/utils:dhcp_utils" ]
123518678f8Sopenharmony_ci    external_deps = [
124518678f8Sopenharmony_ci      "access_token:libaccesstoken_sdk",
125518678f8Sopenharmony_ci      "access_token:libtokenid_sdk",
126518678f8Sopenharmony_ci      "c_utils:utils",
127518678f8Sopenharmony_ci      "hilog:libhilog",
128518678f8Sopenharmony_ci      "ipc:ipc_single",
129518678f8Sopenharmony_ci      "safwk:system_ability_fwk",
130518678f8Sopenharmony_ci      "samgr:samgr_proxy",
131518678f8Sopenharmony_ci    ]
132518678f8Sopenharmony_ci
133518678f8Sopenharmony_ci    cflags = [
134518678f8Sopenharmony_ci      "-std=c++17",
135518678f8Sopenharmony_ci      "-fno-rtti",
136518678f8Sopenharmony_ci    ]
137518678f8Sopenharmony_ci    ldflags = [
138518678f8Sopenharmony_ci      "-fPIC",
139518678f8Sopenharmony_ci      "-Wl,-E",
140518678f8Sopenharmony_ci    ]
141518678f8Sopenharmony_ci    shlib_type = "sa"
142518678f8Sopenharmony_ci    version_script = "libdhcp_server.map"
143518678f8Sopenharmony_ci    public_configs = [ ":dhcp_manager_service_header" ]
144518678f8Sopenharmony_ci    part_name = "dhcp"
145518678f8Sopenharmony_ci    subsystem_name = "communication"
146518678f8Sopenharmony_ci    innerapi_tags = [ "platformsdk" ]
147518678f8Sopenharmony_ci  }
148518678f8Sopenharmony_ci}
149