1# Copyright (C) 2021-2023 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
22local_sdk_include_dirs = [
23  "$DHCP_ROOT_DIR/services",
24  "$DHCP_ROOT_DIR/interfaces",
25  "$DHCP_ROOT_DIR/interfaces/inner_api",
26  "$DHCP_ROOT_DIR/interfaces/kits/c",
27  "$DHCP_ROOT_DIR/interfaces/inner_api/include",
28  "$DHCP_ROOT_DIR/interfaces/inner_api/interfaces",
29  "$DHCP_ROOT_DIR/frameworks/native/include",
30  "$DHCP_ROOT_DIR/frameworks/native/interfaces",
31  "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc",
32]
33
34if (defined(ohos_lite)) {
35  shared_library("dhcp_sdk") {
36    sources = [
37      "c_adapter/src/dhcp_c_service.cpp",
38      "c_adapter/src/dhcp_c_utils.cpp",
39      "src/dhcp_client.cpp",
40      "src/dhcp_client_callback_stub_lite.cpp",
41      "src/dhcp_client_proxy_lite.cpp",
42      "src/dhcp_event.cpp",
43      "src/dhcp_server.cpp",
44      "src/dhcp_server_callback_stub_lite.cpp",
45      "src/dhcp_server_impl.cpp",
46      "src/dhcp_server_proxy_lite.cpp",
47    ]
48    include_dirs = local_sdk_include_dirs
49    include_dirs += [ "//commonlibrary/c_utils/base/include" ]
50
51    deps = [
52      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
53      "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
54      "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
55      "//third_party/bounds_checking_function:libsec_shared",
56    ]
57    configs -= [ "//build/lite/config:language_cpp" ]
58    cflags_cc = [
59      "-std=c++17",
60      "-fno-rtti",
61    ]
62    defines = [ "OHOS_ARCH_LITE" ]
63    ldflags = [
64      "-fPIC",
65      "-Wl,-E",
66    ]
67  }
68} else {
69  local_sdk_sources = [
70    "c_adapter/src/dhcp_c_service.cpp",
71    "c_adapter/src/dhcp_c_utils.cpp",
72    "src/dhcp_client.cpp",
73    "src/dhcp_client_callback_stub.cpp",
74    "src/dhcp_event.cpp",
75    "src/dhcp_sa_manager.cpp",
76    "src/dhcp_server.cpp",
77  ]
78  config("dhcp_sdk_header") {
79    visibility = [ ":*" ]
80    include_dirs = local_sdk_include_dirs
81  }
82  config("dhcp_sdk_config") {
83    visibility = [ ":*" ]
84    include_dirs = local_sdk_include_dirs
85    cflags = [
86      "-std=c++17",
87      "-fno-rtti",
88    ]
89    if (target_cpu == "arm") {
90      cflags += [ "-DBINDER_IPC_32BIT" ]
91    }
92  }
93  ohos_source_set("dhcp_client_proxy_impl") {
94    branch_protector_ret = "pac_ret"
95    sanitize = {
96      cfi = true  # Enable/disable control flow integrity detection
97      boundary_sanitize = true  # Enable boundary san detection
98      cfi_cross_dso = true  # Cross-SO CFI Checks
99      integer_overflow = true  # Enable integer overflow detection
100      ubsan = true  # Enable some Ubsan options
101      debug = false
102    }
103    part_name = "dhcp"
104    subsystem_name = "communication"
105    sources = [
106      "src/dhcp_client_impl.cpp",
107      "src/dhcp_client_proxy.cpp",
108    ]
109    configs = [
110      ":dhcp_sdk_config",
111      ":dhcp_sdk_header",
112    ]
113    defines = []
114    external_deps = [
115      "c_utils:utils",
116      "hilog:libhilog",
117      "ipc:ipc_single",
118      "samgr:samgr_proxy",
119    ]
120  }
121
122  ohos_source_set("dhcp_server_proxy_impl") {
123    branch_protector_ret = "pac_ret"
124    sanitize = {
125      cfi = true  # Enable/disable control flow integrity detection
126      boundary_sanitize = true  # Enable boundary san detection
127      cfi_cross_dso = true  # Cross-SO CFI Checks
128      integer_overflow = true  # Enable integer overflow detection
129      ubsan = true  # Enable some Ubsan options
130      debug = false
131    }
132    part_name = "dhcp"
133    subsystem_name = "communication"
134    sources = [
135      "src/dhcp_server_impl.cpp",
136      "src/dhcp_server_proxy.cpp",
137    ]
138    configs = [
139      ":dhcp_sdk_config",
140      ":dhcp_sdk_header",
141    ]
142    defines = []
143    external_deps = [
144      "c_utils:utils",
145      "hilog:libhilog",
146      "ipc:ipc_single",
147      "samgr:samgr_proxy",
148    ]
149  }
150
151  ohos_shared_library("dhcp_sdk") {
152    branch_protector_ret = "pac_ret"
153    sanitize = {
154      cfi = true  # Enable/disable control flow integrity detection
155      boundary_sanitize = true  # Enable boundary san detection
156      cfi_cross_dso = true  # Cross-SO CFI Checks
157      integer_overflow = true  # Enable integer overflow detection
158      ubsan = true  # Enable some Ubsan options
159      debug = false
160    }
161    install_enable = true
162    sources = local_sdk_sources
163    sources += [ "src/dhcp_server_callback_stub.cpp" ]
164    deps = [
165      ":dhcp_client_proxy_impl",
166      ":dhcp_server_proxy_impl",
167    ]
168    external_deps = [
169      "c_utils:utils",
170      "hilog:libhilog",
171      "ipc:ipc_single",
172      "safwk:system_ability_fwk",
173      "samgr:samgr_proxy",
174    ]
175    defines = []
176    cflags_cc = [
177      "-std=c++17",
178      "-fno-rtti",
179    ]
180    ldflags = [
181      "-fPIC",
182      "-Wl,-E",
183    ]
184    configs = [
185      ":dhcp_sdk_config",
186      ":dhcp_sdk_header",
187    ]
188    public_configs = [ ":dhcp_sdk_header" ]
189    part_name = "dhcp"
190    subsystem_name = "communication"
191    innerapi_tags = [ "platformsdk" ]
192  }
193}
194