• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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
14import("../../dsoftbus.gni")
15import("../adapter/core_adapter.gni")
16import("../authentication/authentication.gni")
17import("../broadcast/broadcast.gni")
18import("../bus_center/bus_center_server.gni")
19import("../common/security/permission/permission.gni")
20import("../connection/conn.gni")
21import("../discovery/disc.gni")
22import("../transmission/trans.gni")
23
24dsoftbus_feature_product_config_path =
25    "${dsoftbus_root_path}/adapter/default_config"
26softbus_adapter_config = "${dsoftbus_root_path}/adapter/default_config"
27
28dsoftbus_server_common_src =
29    auth_server_src + bus_center_server_src + conn_manager_src +
30    disc_server_src + trans_session_src + softbus_permission_src + broadcast_src
31dsoftbus_server_common_inc =
32    auth_server_inc + bus_center_server_inc + conn_manager_inc +
33    disc_server_inc + trans_session_inc + softbus_permission_inc + broadcast_inc
34dsoftbus_server_common_deps =
35    auth_server_deps + bus_center_server_deps + disc_server_deps +
36    conn_manager_common_deps + trans_session_deps + softbus_permission_deps +
37    broadcast_deps
38
39if (defined(ohos_lite)) {
40  copy("permission_json") {
41    sources = [ "$dsoftbus_core_path/common/security/permission/softbus_trans_permission.json" ]
42    outputs = [ "$root_out_dir/etc/softbus_trans_permission.json" ]
43  }
44  if (ohos_kernel_type == "liteos_m") {
45    static_library("softbus_server_frame") {
46      defines += AUTH_SERVER_DEFINES
47      defines += DISC_SERVER_DEFINES
48      defines += CONN_SERVER_DEFINES
49      defines += [ "__STDC_FORMAT_MACROS" ]
50      include_dirs = dsoftbus_server_common_inc
51      include_dirs += [
52        "$dsoftbus_dfx_path/interface/include",
53        "$dsoftbus_root_path/core/frame/common/include",
54        "$dsoftbus_root_path/interfaces/inner_kits/lnn",
55        "$dsoftbus_root_path/interfaces/kits",
56        "$dsoftbus_root_path/interfaces/kits/bus_center",
57        "$dsoftbus_root_path/interfaces/kits/transport",
58        "$dsoftbus_root_path/interfaces/kits/common",
59        "$softbus_adapter_config/spec_config",
60      ]
61      sources = dsoftbus_server_common_src
62      sources += [
63        "common/src/softbus_ddos_virtual.c",
64        "common/src/softbus_server_frame.c",
65        "mini/src/softbus_server_stub.c",
66      ]
67      if (board_toolchain_type != "iccarm") {
68        cflags = [
69          "-Wall",
70          "-fPIC",
71          "-std=c99",
72        ]
73        cflags_cc = cflags
74      } else {
75        include_dirs += [
76          "//kernel/liteos_m/components/net/lwip-2.1/porting/include",
77          "//third_party/lwip/src/include",
78        ]
79        cflags = [
80          "--diag_suppress",
81          "Pe301",
82        ]
83      }
84      deps = dsoftbus_server_common_deps
85      deps += [
86        "$dsoftbus_dfx_path/dumper/legacy:softbus_dfx_dump",
87        "$dsoftbus_root_path/adapter:softbus_adapter",
88        "$dsoftbus_root_path/core/common:softbus_utils",
89        "$dsoftbus_root_path/core/connection/wifi_direct_cpp:wifi_direct",
90        "//build/lite/config/component/cJSON:cjson_static",
91      ]
92      external_deps = [ "device_auth:deviceauth_sdk" ]
93      external_deps += auth_server_ex_deps
94      if (defined(global_parts_info) &&
95          defined(global_parts_info.hmoshiviewdfx_hiview_xcommradar_plugin)) {
96        include_dirs += [
97          "$dsoftbus_root_path/../../../vendor/huawei/base/hiviewdfx/hiview_plugins/communication_radar_plugin/interfaces/inner_api/communication_radar",
98          "$dsoftbus_dfx_path/statistics/include",
99        ]
100        sources += [
101          "$dsoftbus_dfx_path/statistics/instant/bt_statistic.cpp",
102          "$dsoftbus_dfx_path/statistics/instant/instant_statistics.cpp",
103          "$dsoftbus_dfx_path/statistics/instant/wifi_statistic.cpp",
104        ]
105        external_deps +=
106            [ "hiview_xcommradar_plugin:communication_radar_client" ]
107      } else {
108        sources += [ "$dsoftbus_dfx_path/statistics/instant/instant_statistics_virtual.cpp" ]
109      }
110      public_deps = [ "$dsoftbus_dfx_path:softbus_dfx" ]
111      if (support_bluetooth &&
112          (dsoftbus_feature_conn_br || dsoftbus_feature_conn_ble)) {
113        deps += [
114          "//foundation/communication/bluetooth/frameworks/inner:btframework",
115        ]
116        include_dirs += [
117          "//foundation/communication/bluetooth/interfaces/inner_api/include",
118          "//foundation/communication/bluetooth/interfaces/inner_api/include/c_header",
119        ]
120      }
121    }
122  } else {
123    shared_library("softbus_server_frame") {
124      defines += AUTH_SERVER_DEFINES
125      defines += DISC_SERVER_DEFINES
126      defines += CONN_SERVER_DEFINES
127      defines += [ "__STDC_FORMAT_MACROS" ]
128      include_dirs = dsoftbus_server_common_inc
129      include_dirs += [
130        "common/include",
131        "small/init/include",
132        "small/client_manager/include",
133        "$softbus_adapter_common/include",
134        "$softbus_adapter_config/spec_config",
135        "$dsoftbus_root_path/core/common/include",
136        "$dsoftbus_root_path/interfaces/inner_kits/lnn",
137        "$dsoftbus_root_path/interfaces/kits/bus_center",
138        "$dsoftbus_root_path/interfaces/kits/common",
139        "$dsoftbus_root_path/interfaces/kits/transport",
140        "$dsoftbus_dfx_path/interface/include",
141        "//commonlibrary/utils_lite/include",
142      ]
143      sources = dsoftbus_server_common_src
144      sources += [
145        "common/src/softbus_ddos_virtual.c",
146        "common/src/softbus_server_frame.c",
147        "small/client_manager/src/softbus_client_info_manager.c",
148        "small/init/src/bus_center_server_stub.c",
149        "small/init/src/softbus_server_stub.c",
150        "small/init/src/trans_server_stub.c",
151      ]
152
153      cflags = [
154        "-Wall",
155        "-fPIC",
156        "-fno-builtin",
157        "-std=c99",
158      ]
159      cflags_cc = cflags
160      deps = dsoftbus_server_common_deps
161      deps += [
162        ":permission_json",
163        "$dsoftbus_dfx_path/dumper/legacy:softbus_dfx_dump",
164        "$dsoftbus_root_path/adapter:softbus_adapter",
165        "$dsoftbus_root_path/core/common:softbus_utils",
166        "$dsoftbus_root_path/core/connection/wifi_direct_cpp:wifi_direct",
167        "//build/lite/config/component/cJSON:cjson_shared",
168        "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
169        "//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
170      ]
171      external_deps = [
172        "bounds_checking_function:libsec_shared",
173        "device_auth:deviceauth_sdk",
174      ]
175      external_deps += auth_server_ex_deps
176      if (defined(global_parts_info) &&
177          defined(global_parts_info.hmoshiviewdfx_hiview_xcommradar_plugin)) {
178        include_dirs += [
179          "$dsoftbus_root_path/../../../vendor/huawei/base/hiviewdfx/hiview_plugins/communication_radar_plugin/interfaces/inner_api/communication_radar",
180          "$dsoftbus_dfx_path/statistics/include",
181        ]
182        sources += [
183          "$dsoftbus_dfx_path/statistics/instant/bt_statistic.cpp",
184          "$dsoftbus_dfx_path/statistics/instant/instant_statistics.cpp",
185          "$dsoftbus_dfx_path/statistics/instant/wifi_statistic.cpp",
186        ]
187        external_deps +=
188            [ "hiview_xcommradar_plugin:communication_radar_client" ]
189      } else {
190        sources += [ "$dsoftbus_dfx_path/statistics/instant/instant_statistics_virtual.cpp" ]
191      }
192      public_deps = [ "$dsoftbus_dfx_path:softbus_dfx" ]
193      if (support_bluetooth &&
194          (dsoftbus_feature_conn_br || dsoftbus_feature_conn_ble)) {
195        deps += [
196          "//foundation/communication/bluetooth/frameworks/inner:btframework",
197        ]
198        include_dirs += [
199          "//foundation/communication/bluetooth/interfaces/inner_api/include",
200          "//foundation/communication/bluetooth/interfaces/inner_api/include/c_header",
201        ]
202      }
203    }
204    executable("softbus_server") {
205      sources = [ "small/init/src/softbus_server_main.c" ]
206      include_dirs = [ "common/include" ]
207      deps = [ ":softbus_server_frame" ]
208      cflags = [ "-fPIC" ]
209    }
210  }
211} else {
212  ohos_prebuilt_etc("softbus_server.rc") {
213    relative_install_dir = "init"
214    if (use_musl) {
215      source = "$dsoftbus_root_path/core/frame/$os_type/init/src/softbus_server_musl.cfg"
216    } else {
217      source =
218          "$dsoftbus_root_path/core/frame/$os_type/init/src/softbus_server.cfg"
219    }
220
221    part_name = "dsoftbus"
222    subsystem_name = "communication"
223  }
224  ohos_prebuilt_etc("softbus_permission_json") {
225    source = "$dsoftbus_root_path/core/common/security/permission/softbus_trans_permission.json"
226    install_enable = true
227    relative_install_dir = "communication/softbus"
228    part_name = "dsoftbus"
229    subsystem_name = "communication"
230  }
231  ohos_shared_library("softbus_server") {
232    sanitize = {
233      cfi = true
234      cfi_cross_dso = true
235      debug = false
236    }
237    branch_protector_ret = "pac_ret"
238
239    defines += AUTH_SERVER_DEFINES
240    defines += DISC_SERVER_DEFINES
241    defines += CONN_SERVER_DEFINES
242    defines += [ "__STDC_FORMAT_MACROS" ]
243    include_dirs = dsoftbus_server_common_inc
244    include_dirs += [
245      "$dsoftbus_dfx_path/interface/include",
246      "$dsoftbus_root_path/core/frame/common/include",
247      "$dsoftbus_root_path/core/frame/$os_type/client_manager/include",
248      "$dsoftbus_root_path/core/frame/$os_type/init/include",
249      "$dsoftbus_root_path/core/common/include",
250      "$dsoftbus_root_path/interfaces/inner_kits/lnn",
251      "$dsoftbus_root_path/interfaces/kits/bus_center",
252      "$dsoftbus_root_path/interfaces/kits/common",
253      "$dsoftbus_root_path/interfaces/kits/transport",
254      "$dsoftbus_root_path/core/common/include",
255      "$dsoftbus_feature_product_config_path/spec_config",
256    ]
257    sources = dsoftbus_server_common_src
258    sources += [
259      "$dsoftbus_root_path/sdk/frame/$os_type/src/if_softbus_client.cpp",
260      "$os_type/client_manager/src/softbus_client_info_manager.cpp",
261      "$os_type/init/src/if_softbus_server.cpp",
262      "$os_type/init/src/softbus_server.cpp",
263      "$os_type/init/src/softbus_server_death_recipient.cpp",
264      "$os_type/init/src/softbus_server_stub.cpp",
265      "common/src/softbus_ddos.c",
266      "common/src/softbus_server_frame.c",
267    ]
268    deps = dsoftbus_server_common_deps
269    deps += [
270      ":softbus_permission_json",
271      ":softbus_server.rc",
272      "$dsoftbus_dfx_path/dumper/legacy:softbus_dfx_dump",
273      "$dsoftbus_root_path/adapter:softbus_adapter",
274      "$dsoftbus_root_path/core/common:softbus_utils",
275      "$dsoftbus_root_path/core/connection/wifi_direct_cpp:wifi_direct",
276    ]
277    external_deps = [ "cJSON:cjson" ]
278    external_deps += auth_server_ex_deps
279    public_deps = [ "$dsoftbus_dfx_path:softbus_dfx" ]
280    dsoftbus_server_common_external_deps =
281        bus_center_server_external_deps + disc_server_external_deps +
282        softbus_permission_external_deps + trans_session_external_deps +
283        conn_manager_external_deps
284    if (is_standard_system) {
285      external_deps += dsoftbus_server_common_external_deps
286      external_deps += [
287        "device_auth:deviceauth_sdk",
288        "hilog:libhilog",
289        "ipc:ipc_single",
290        "kv_store:distributeddata_inner",
291        "netmanager_base:net_conn_manager_if",
292        "safwk:system_ability_fwk",
293        "samgr:samgr_proxy",
294      ]
295      if (dsoftbus_access_token_feature) {
296        external_deps += [
297          "access_token:libaccesstoken_sdk",
298          "access_token:libprivacy_sdk",
299          "access_token:libtokenid_sdk",
300        ]
301      }
302      if (!defined(global_parts_info) ||
303          defined(global_parts_info.deviceprofile_device_info_manager)) {
304        external_deps += [
305          "device_info_manager:distributed_device_profile_common",
306          "device_info_manager:distributed_device_profile_sdk",
307        ]
308      }
309      if (!defined(global_parts_info) ||
310          defined(global_parts_info.bundlemanager_bundle_framework)) {
311        cflags = [ "-DSUPPORT_BUNDLENAME" ]
312      }
313      if (!defined(global_parts_info) ||
314          defined(global_parts_info.ability_ability_runtime)) {
315        cflags += [ "-DSUPPORT_ABILITY_RUNTIME" ]
316      }
317      if (enhanced) {
318        cflags += [ "-DENHANCED_FLAG" ]
319        external_deps += [
320          "device_certificate_manager:device_cert_mgr_sdk",
321          "zlib:libz",
322        ]
323      }
324    }
325    if (defined(global_parts_info) &&
326        defined(global_parts_info.hmoshiviewdfx_hiview_xcommradar_plugin)) {
327      include_dirs += [
328        "$dsoftbus_root_path/../../../vendor/huawei/base/hiviewdfx/hiview_plugins/communication_radar_plugin/interfaces/inner_api/communication_radar",
329        "$dsoftbus_dfx_path/statistics/include",
330      ]
331      sources += [
332        "$dsoftbus_dfx_path/statistics/instant/bt_statistic.cpp",
333        "$dsoftbus_dfx_path/statistics/instant/instant_statistics.cpp",
334        "$dsoftbus_dfx_path/statistics/instant/wifi_statistic.cpp",
335      ]
336      external_deps += [ "hiview_xcommradar_plugin:communication_radar_client" ]
337    } else {
338      sources += [
339        "$dsoftbus_dfx_path/statistics/instant/instant_statistics_virtual.cpp",
340      ]
341    }
342    part_name = "dsoftbus"
343    subsystem_name = "communication"
344  }
345}
346