1518678f8Sopenharmony_ci# Copyright (C) 2021-2023 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_cilocal_sdk_include_dirs = [
23518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/services",
24518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces",
25518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/inner_api",
26518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/kits/c",
27518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/inner_api/include",
28518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/interfaces/inner_api/interfaces",
29518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/include",
30518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/interfaces",
31518678f8Sopenharmony_ci  "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc",
32518678f8Sopenharmony_ci]
33518678f8Sopenharmony_ci
34518678f8Sopenharmony_ciif (defined(ohos_lite)) {
35518678f8Sopenharmony_ci  shared_library("dhcp_sdk") {
36518678f8Sopenharmony_ci    sources = [
37518678f8Sopenharmony_ci      "c_adapter/src/dhcp_c_service.cpp",
38518678f8Sopenharmony_ci      "c_adapter/src/dhcp_c_utils.cpp",
39518678f8Sopenharmony_ci      "src/dhcp_client.cpp",
40518678f8Sopenharmony_ci      "src/dhcp_client_callback_stub_lite.cpp",
41518678f8Sopenharmony_ci      "src/dhcp_client_proxy_lite.cpp",
42518678f8Sopenharmony_ci      "src/dhcp_event.cpp",
43518678f8Sopenharmony_ci      "src/dhcp_server.cpp",
44518678f8Sopenharmony_ci      "src/dhcp_server_callback_stub_lite.cpp",
45518678f8Sopenharmony_ci      "src/dhcp_server_impl.cpp",
46518678f8Sopenharmony_ci      "src/dhcp_server_proxy_lite.cpp",
47518678f8Sopenharmony_ci    ]
48518678f8Sopenharmony_ci    include_dirs = local_sdk_include_dirs
49518678f8Sopenharmony_ci    include_dirs += [ "//commonlibrary/c_utils/base/include" ]
50518678f8Sopenharmony_ci
51518678f8Sopenharmony_ci    deps = [
52518678f8Sopenharmony_ci      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
53518678f8Sopenharmony_ci      "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
54518678f8Sopenharmony_ci      "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
55518678f8Sopenharmony_ci      "//third_party/bounds_checking_function:libsec_shared",
56518678f8Sopenharmony_ci    ]
57518678f8Sopenharmony_ci    configs -= [ "//build/lite/config:language_cpp" ]
58518678f8Sopenharmony_ci    cflags_cc = [
59518678f8Sopenharmony_ci      "-std=c++17",
60518678f8Sopenharmony_ci      "-fno-rtti",
61518678f8Sopenharmony_ci    ]
62518678f8Sopenharmony_ci    defines = [ "OHOS_ARCH_LITE" ]
63518678f8Sopenharmony_ci    ldflags = [
64518678f8Sopenharmony_ci      "-fPIC",
65518678f8Sopenharmony_ci      "-Wl,-E",
66518678f8Sopenharmony_ci    ]
67518678f8Sopenharmony_ci  }
68518678f8Sopenharmony_ci} else {
69518678f8Sopenharmony_ci  local_sdk_sources = [
70518678f8Sopenharmony_ci    "c_adapter/src/dhcp_c_service.cpp",
71518678f8Sopenharmony_ci    "c_adapter/src/dhcp_c_utils.cpp",
72518678f8Sopenharmony_ci    "src/dhcp_client.cpp",
73518678f8Sopenharmony_ci    "src/dhcp_client_callback_stub.cpp",
74518678f8Sopenharmony_ci    "src/dhcp_event.cpp",
75518678f8Sopenharmony_ci    "src/dhcp_sa_manager.cpp",
76518678f8Sopenharmony_ci    "src/dhcp_server.cpp",
77518678f8Sopenharmony_ci  ]
78518678f8Sopenharmony_ci  config("dhcp_sdk_header") {
79518678f8Sopenharmony_ci    visibility = [ ":*" ]
80518678f8Sopenharmony_ci    include_dirs = local_sdk_include_dirs
81518678f8Sopenharmony_ci  }
82518678f8Sopenharmony_ci  config("dhcp_sdk_config") {
83518678f8Sopenharmony_ci    visibility = [ ":*" ]
84518678f8Sopenharmony_ci    include_dirs = local_sdk_include_dirs
85518678f8Sopenharmony_ci    cflags = [
86518678f8Sopenharmony_ci      "-std=c++17",
87518678f8Sopenharmony_ci      "-fno-rtti",
88518678f8Sopenharmony_ci    ]
89518678f8Sopenharmony_ci    if (target_cpu == "arm") {
90518678f8Sopenharmony_ci      cflags += [ "-DBINDER_IPC_32BIT" ]
91518678f8Sopenharmony_ci    }
92518678f8Sopenharmony_ci  }
93518678f8Sopenharmony_ci  ohos_source_set("dhcp_client_proxy_impl") {
94518678f8Sopenharmony_ci    branch_protector_ret = "pac_ret"
95518678f8Sopenharmony_ci    sanitize = {
96518678f8Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
97518678f8Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
98518678f8Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
99518678f8Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
100518678f8Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
101518678f8Sopenharmony_ci      debug = false
102518678f8Sopenharmony_ci    }
103518678f8Sopenharmony_ci    part_name = "dhcp"
104518678f8Sopenharmony_ci    subsystem_name = "communication"
105518678f8Sopenharmony_ci    sources = [
106518678f8Sopenharmony_ci      "src/dhcp_client_impl.cpp",
107518678f8Sopenharmony_ci      "src/dhcp_client_proxy.cpp",
108518678f8Sopenharmony_ci    ]
109518678f8Sopenharmony_ci    configs = [
110518678f8Sopenharmony_ci      ":dhcp_sdk_config",
111518678f8Sopenharmony_ci      ":dhcp_sdk_header",
112518678f8Sopenharmony_ci    ]
113518678f8Sopenharmony_ci    defines = []
114518678f8Sopenharmony_ci    external_deps = [
115518678f8Sopenharmony_ci      "c_utils:utils",
116518678f8Sopenharmony_ci      "hilog:libhilog",
117518678f8Sopenharmony_ci      "ipc:ipc_single",
118518678f8Sopenharmony_ci      "samgr:samgr_proxy",
119518678f8Sopenharmony_ci    ]
120518678f8Sopenharmony_ci  }
121518678f8Sopenharmony_ci
122518678f8Sopenharmony_ci  ohos_source_set("dhcp_server_proxy_impl") {
123518678f8Sopenharmony_ci    branch_protector_ret = "pac_ret"
124518678f8Sopenharmony_ci    sanitize = {
125518678f8Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
126518678f8Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
127518678f8Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
128518678f8Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
129518678f8Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
130518678f8Sopenharmony_ci      debug = false
131518678f8Sopenharmony_ci    }
132518678f8Sopenharmony_ci    part_name = "dhcp"
133518678f8Sopenharmony_ci    subsystem_name = "communication"
134518678f8Sopenharmony_ci    sources = [
135518678f8Sopenharmony_ci      "src/dhcp_server_impl.cpp",
136518678f8Sopenharmony_ci      "src/dhcp_server_proxy.cpp",
137518678f8Sopenharmony_ci    ]
138518678f8Sopenharmony_ci    configs = [
139518678f8Sopenharmony_ci      ":dhcp_sdk_config",
140518678f8Sopenharmony_ci      ":dhcp_sdk_header",
141518678f8Sopenharmony_ci    ]
142518678f8Sopenharmony_ci    defines = []
143518678f8Sopenharmony_ci    external_deps = [
144518678f8Sopenharmony_ci      "c_utils:utils",
145518678f8Sopenharmony_ci      "hilog:libhilog",
146518678f8Sopenharmony_ci      "ipc:ipc_single",
147518678f8Sopenharmony_ci      "samgr:samgr_proxy",
148518678f8Sopenharmony_ci    ]
149518678f8Sopenharmony_ci  }
150518678f8Sopenharmony_ci
151518678f8Sopenharmony_ci  ohos_shared_library("dhcp_sdk") {
152518678f8Sopenharmony_ci    branch_protector_ret = "pac_ret"
153518678f8Sopenharmony_ci    sanitize = {
154518678f8Sopenharmony_ci      cfi = true  # Enable/disable control flow integrity detection
155518678f8Sopenharmony_ci      boundary_sanitize = true  # Enable boundary san detection
156518678f8Sopenharmony_ci      cfi_cross_dso = true  # Cross-SO CFI Checks
157518678f8Sopenharmony_ci      integer_overflow = true  # Enable integer overflow detection
158518678f8Sopenharmony_ci      ubsan = true  # Enable some Ubsan options
159518678f8Sopenharmony_ci      debug = false
160518678f8Sopenharmony_ci    }
161518678f8Sopenharmony_ci    install_enable = true
162518678f8Sopenharmony_ci    sources = local_sdk_sources
163518678f8Sopenharmony_ci    sources += [ "src/dhcp_server_callback_stub.cpp" ]
164518678f8Sopenharmony_ci    deps = [
165518678f8Sopenharmony_ci      ":dhcp_client_proxy_impl",
166518678f8Sopenharmony_ci      ":dhcp_server_proxy_impl",
167518678f8Sopenharmony_ci    ]
168518678f8Sopenharmony_ci    external_deps = [
169518678f8Sopenharmony_ci      "c_utils:utils",
170518678f8Sopenharmony_ci      "hilog:libhilog",
171518678f8Sopenharmony_ci      "ipc:ipc_single",
172518678f8Sopenharmony_ci      "safwk:system_ability_fwk",
173518678f8Sopenharmony_ci      "samgr:samgr_proxy",
174518678f8Sopenharmony_ci    ]
175518678f8Sopenharmony_ci    defines = []
176518678f8Sopenharmony_ci    cflags_cc = [
177518678f8Sopenharmony_ci      "-std=c++17",
178518678f8Sopenharmony_ci      "-fno-rtti",
179518678f8Sopenharmony_ci    ]
180518678f8Sopenharmony_ci    ldflags = [
181518678f8Sopenharmony_ci      "-fPIC",
182518678f8Sopenharmony_ci      "-Wl,-E",
183518678f8Sopenharmony_ci    ]
184518678f8Sopenharmony_ci    configs = [
185518678f8Sopenharmony_ci      ":dhcp_sdk_config",
186518678f8Sopenharmony_ci      ":dhcp_sdk_header",
187518678f8Sopenharmony_ci    ]
188518678f8Sopenharmony_ci    public_configs = [ ":dhcp_sdk_header" ]
189518678f8Sopenharmony_ci    part_name = "dhcp"
190518678f8Sopenharmony_ci    subsystem_name = "communication"
191518678f8Sopenharmony_ci    innerapi_tags = [ "platformsdk" ]
192518678f8Sopenharmony_ci  }
193518678f8Sopenharmony_ci}
194