• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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")
15
16dsoftbus_root_path = ".."
17softbus_adapter_common = "${dsoftbus_root_path}/adapter/common"
18dsoftbus_feature_product_config_path =
19    "${dsoftbus_root_path}/adapter/default_config"
20softbus_adapter_config = "${dsoftbus_root_path}/adapter/default_config"
21native_source_path = rebase_path("$dsoftbus_root_path")
22dep_feature = "dsoftbus_enhance/adapter/default_config/spec_config/softbus_config_adapter.c"
23enhance_feature = exec_script("$dsoftbus_root_path/check_sub_module.py",
24                              [
25                                "$native_source_path",
26                                "$dep_feature",
27                              ],
28                              "value")
29
30if (defined(ohos_lite)) {
31  import("//build/lite/config/component/lite_component.gni")
32  config("dsoftbus_adapter_common_interface") {
33    include_dirs = [
34      "$dsoftbus_root_path/core/common/include",
35      "$hilog_lite_include_path",
36      "$softbus_adapter_common/include",
37      "$softbus_adapter_common/include/OS_adapter_define/linux",
38      "$softbus_adapter_common/security/access_token/include",
39      "$softbus_adapter_config/spec_config",
40      "$utils_lite_include_path",
41    ]
42    if (board_name == "v200zr") {
43      defines += [ "DSOFTBUS_V200ZR" ]
44    }
45  }
46
47  common_include = [
48    "$dsoftbus_dfx_path/interface/include",
49    "$dsoftbus_root_path/interfaces/kits",
50    "$dsoftbus_root_path/adapter/common/net/bluetooth/broadcast/adapter/include",
51    "$dsoftbus_root_path/interfaces/kits/common",
52    "$softbus_adapter_common/security/access_token/include",
53  ]
54
55  if (ohos_kernel_type == "liteos_m") {
56    static_library("softbus_adapter") {
57      include_dirs = common_include
58      include_dirs += [ "//kernel/liteos_m/kal/cmsis" ]
59      external_deps = [
60        "bounds_checking_function:libsec_static",
61        "init:libbegetutil",
62      ]
63      public_external_deps = [ "json:nlohmann_json_static" ]
64      if (board_name == "hispark_pegasus") {
65        include_dirs +=
66            [ "$hispark_pegasus_sdk_path/third_party/lwip_sack/include" ]
67        defines += [ "HISPARK_PEGASUS_USE_NETIF_GET_ADDR" ]
68      }
69      if (board_toolchain_type == "iccarm") {
70        include_dirs += [
71          "//kernel/liteos_m/components/net/lwip-2.1/porting/include",
72          "//third_party/lwip/src/include",
73        ]
74        cflags = [
75          "--diag_suppress",
76          "Pe226,Pe513",
77        ]
78        ldflags = [ "-lpthread" ]
79      } else {
80        cflags = [ "-Wall" ]
81      }
82      sources = [
83        "$dsoftbus_dfx_path/event/legacy/softbus_adapter_hisysevent_mini.c",
84        "$dsoftbus_dfx_path/trace/legacy/softbus_adapter_hitrace_virtual.c",
85        "$softbus_adapter_common/kernel/liteos_m/lnn_ip_utils_adapter.c",
86        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_file.c",
87        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_mem.c",
88        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_timer.c",
89        "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
90        "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
91        "$softbus_adapter_common/range/softbus_adapter_range.c",
92      ]
93
94      if (dsoftbus_access_token_feature) {
95        sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter.cpp" ]
96        external_deps += [
97          "access_token:libaccesstoken_sdk",
98          "access_token:libprivacy_sdk",
99          "access_token:libtokenid_sdk",
100        ]
101        if (dsoftbus_ipc_feature) {
102          external_deps += [ "ipc:ipc_single" ]
103        }
104      } else {
105        sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter_virtual.c" ]
106      }
107
108      if (enhance_feature) {
109        sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/default_config/spec_config/softbus_config_adapter.c" ]
110      } else {
111        sources +=
112            [ "$softbus_adapter_config/spec_config/softbus_config_adapter.c" ]
113      }
114
115      if (board_name == "v200zr") {
116        external_deps += [ "json:nlohmann_json_static" ]
117        sources = []
118        sources = [
119          "$dsoftbus_dfx_path/event/legacy/softbus_adapter_hisysevent_mini.c",
120          "$dsoftbus_dfx_path/trace/legacy/softbus_adapter_hitrace_virtual.c",
121          "$softbus_adapter_common/json/nlohmann/softbus_adapter_json.cpp",
122          "$softbus_adapter_common/kernel/liteos_m/lnn_ip_utils_adapter.c",
123          "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_mem.c",
124          "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_timer.c",
125          "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
126          "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
127          "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
128          "$softbus_adapter_common/perf/softbus_adapter_perf.c",
129          "$softbus_adapter_common/range/softbus_adapter_range.c",
130        ]
131
132        if (enhance_feature) {
133          sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/default_config/spec_config/softbus_config_adapter.c" ]
134        } else {
135          sources +=
136              [ "$softbus_adapter_config/spec_config/softbus_config_adapter.c" ]
137        }
138      }
139
140      deps = [
141        "$dsoftbus_dfx_path:softbus_dfx",
142        "$hilog_lite_deps_path",
143      ]
144
145      if (dsoftbus_feature_encrypt == 0) {
146        sources += [
147          "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c",
148          "$softbus_adapter_common/mbedtls/softbus_aes_encrypt_virtual.c",
149        ]
150        deps += [ "//third_party/mbedtls" ]
151      } else if (dsoftbus_feature_encrypt == 1) {
152        sources += [
153          "$softbus_adapter_common/openssl/softbus_adapter_crypto.c",
154          "$softbus_adapter_common/openssl/softbus_aes_encrypt.c",
155        ]
156        deps += [ "//third_party/openssl:libcrypto_shared" ]
157      }
158      public_configs = [ ":dsoftbus_adapter_common_interface" ]
159    }
160  } else {
161    shared_library("softbus_adapter") {
162      include_dirs = common_include
163      cflags = [
164        "-Wall",
165        "-Werror",
166        "-fPIC",
167        "-fno-builtin",
168        "-std=c99",
169      ]
170      cflags_cc = [ "-fPIC" ]
171      sources = [
172        "$dsoftbus_dfx_path/event/legacy/softbus_adapter_hisysevent_mini.c",
173        "$dsoftbus_dfx_path/trace/legacy/softbus_adapter_hitrace_virtual.c",
174        "$softbus_adapter_common/json/nlohmann/softbus_adapter_json.cpp",
175        "$softbus_adapter_common/kernel/posix/lnn_ip_utils_adapter.c",
176        "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
177        "$softbus_adapter_common/kernel/posix/softbus_adapter_mem.c",
178        "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
179        "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
180        "$softbus_adapter_common/kernel/posix/softbus_adapter_timer.c",
181        "$softbus_adapter_common/perf/softbus_adapter_perf.c",
182        "$softbus_adapter_common/range/softbus_adapter_range.c",
183      ]
184
185      if (dsoftbus_access_token_feature) {
186        sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter.cpp" ]
187        external_deps += [
188          "access_token:libaccesstoken_sdk",
189          "access_token:libprivacy_sdk",
190          "access_token:libtokenid_sdk",
191        ]
192        if (dsoftbus_ipc_feature) {
193          external_deps += [ "ipc:ipc_single" ]
194        }
195      } else {
196        sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter_virtual.c" ]
197      }
198
199      if (enhance_feature) {
200        sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/default_config/spec_config/softbus_config_adapter.c" ]
201      } else {
202        sources +=
203            [ "$softbus_adapter_config/spec_config/softbus_config_adapter.c" ]
204      }
205
206      deps = [
207        "$dsoftbus_dfx_path:softbus_dfx",
208        "$hilog_lite_deps_path",
209      ]
210      external_deps = [
211        "bounds_checking_function:libsec_shared",
212        "init:libbegetutil",
213      ]
214      public_external_deps = [ "json:nlohmann_json_static" ]
215
216      if (dsoftbus_feature_encrypt == 0) {
217        sources += [
218          "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c",
219          "$softbus_adapter_common/mbedtls/softbus_aes_encrypt_virtual.c",
220        ]
221        deps += [ "//third_party/mbedtls" ]
222      } else if (dsoftbus_feature_encrypt == 1) {
223        sources += [
224          "$softbus_adapter_common/openssl/softbus_adapter_crypto.c",
225          "$softbus_adapter_common/openssl/softbus_aes_encrypt.c",
226        ]
227        deps += [ "//third_party/openssl:libcrypto_shared" ]
228      }
229      public_configs = [ ":dsoftbus_adapter_common_interface" ]
230    }
231  }
232} else {
233  config("config_adapter_common") {
234    include_dirs = [
235      "$dsoftbus_dfx_path/interface/include",
236      "$dsoftbus_feature_product_config_path/spec_config",
237      "$dsoftbus_root_path/core/common/include",
238      "$softbus_adapter_common/include",
239      "$softbus_adapter_common/include/OS_adapter_define/linux",
240      "$softbus_adapter_common/security/access_token/include",
241    ]
242  }
243
244  ohos_shared_library("softbus_adapter") {
245    sanitize = {
246      ubsan = true
247      integer_overflow = true
248      boundary_sanitize = true
249      cfi = true
250      cfi_cross_dso = true
251      debug = false
252    }
253    branch_protector_ret = "pac_ret"
254
255    include_dirs = [
256      "$dsoftbus_dfx_path/interface/include",
257      "$dsoftbus_root_path/interfaces/kits",
258      "$dsoftbus_root_path/interfaces/kits/common",
259      "$softbus_adapter_common/security/access_token/include",
260    ]
261
262    external_deps = [ "bounds_checking_function:libsec_shared" ]
263    if (is_standard_system) {
264      external_deps += [
265        "c_utils:utils",
266        "json:nlohmann_json_static",
267      ]
268    }
269    sources = [
270      "$dsoftbus_dfx_path/event/legacy/softbus_adapter_hisysevent.cpp",
271      "$dsoftbus_dfx_path/trace/legacy/softbus_adapter_hitrace.c",
272      "$softbus_adapter_common/json/nlohmann/softbus_adapter_json.cpp",
273      "$softbus_adapter_common/kernel/posix/lnn_ip_utils_adapter.c",
274      "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
275      "$softbus_adapter_common/kernel/posix/softbus_adapter_mem.c",
276      "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
277      "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
278      "$softbus_adapter_common/kernel/posix/softbus_adapter_timer.c",
279      "$softbus_adapter_common/perf/softbus_adapter_perf.c",
280    ]
281
282    if (dsoftbus_access_token_feature) {
283      sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter.cpp" ]
284      external_deps += [
285        "access_token:libaccesstoken_sdk",
286        "access_token:libprivacy_sdk",
287        "access_token:libtokenid_sdk",
288      ]
289      if (dsoftbus_ipc_feature) {
290        external_deps += [ "ipc:ipc_single" ]
291      }
292    } else {
293      sources += [ "$softbus_adapter_common/security/access_token/common/softbus_access_token_adapter_virtual.c" ]
294    }
295
296    if (enhance_feature) {
297      sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/default_config/spec_config/softbus_config_adapter.c" ]
298    } else {
299      sources +=
300          [ "$softbus_adapter_config/spec_config/softbus_config_adapter.c" ]
301    }
302
303    public_deps = [ "$dsoftbus_dfx_path:softbus_dfx" ]
304    public_external_deps = [
305      "bounds_checking_function:libsec_shared",
306      "json:nlohmann_json_static",
307    ]
308
309    ble_enhanced_impl =
310        "dsoftbus_enhance/adapter/common/range/softbus_adapter_range.c"
311    enhanced_range = exec_script("$dsoftbus_root_path/check_sub_module.py",
312                                 [
313                                   "$native_source_path",
314                                   "$ble_enhanced_impl",
315                                 ],
316                                 "value")
317    if (enhanced_range && defined(global_parts_info.msdp_algorithm) &&
318        defined(global_parts_info.msdp_range_measure)) {
319      sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/common/range/softbus_adapter_range.c" ]
320      external_deps += [
321        "algorithm:msdp_ble_range",
322        "spatial_awareness:msdp_range_measure",
323      ]
324    } else {
325      sources += [ "$softbus_adapter_common/range/softbus_adapter_range.c" ]
326    }
327
328    if (dsoftbus_feature_encrypt == 0) {
329      sources += [
330        "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c",
331        "$softbus_adapter_common/mbedtls/softbus_aes_encrypt_virtual.c",
332      ]
333      public_deps += [ "//third_party/mbedtls" ]
334    } else if (dsoftbus_feature_encrypt == 1) {
335      sources += [
336        "$softbus_adapter_common/openssl/softbus_adapter_crypto.c",
337        "$softbus_adapter_common/openssl/softbus_aes_encrypt.c",
338      ]
339      public_external_deps += [ "openssl:libcrypto_shared" ]
340    }
341    public_configs = [ ":config_adapter_common" ]
342    public_external_deps += [ "hitrace:libhitracechain" ]
343    if (is_standard_system) {
344      external_deps += [
345        "ffrt:libffrt",
346        "hilog:libhilog",
347        "hisysevent:libhisysevent",
348        "hitrace:libhitracechain",
349        "init:libbegetutil",
350      ]
351    }
352    innerapi_tags = [ "platformsdk_indirect" ]
353    part_name = "dsoftbus"
354    subsystem_name = "communication"
355  }
356}
357