• 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("//foundation/communication/dsoftbus/dsoftbus.gni")
15
16if (defined(ohos_lite)) {
17  import("//build/lite/config/component/lite_component.gni")
18  if (ohos_kernel_type == "liteos_m") {
19    hilog_lite_include_path =
20        "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite"
21  } else {
22    hilog_lite_include_path =
23        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits"
24  }
25  config("dsoftbus_adapter_common_interface") {
26    include_dirs = [
27      "$softbus_adapter_common/include",
28      "$softbus_adapter_common/include/OS_adapter_define/linux",
29      "$softbus_adapter_config/spec_config",
30      "$dsoftbus_root_path/core/common/include",
31      "$hilog_lite_include_path",
32    ]
33    if (board_name == "v200zr") {
34      defines = [ "DSOFTBUS_V200ZR" ]
35    }
36  }
37
38  common_include = [
39    "$dsoftbus_root_path/interfaces/kits",
40    "$dsoftbus_root_path/interfaces/kits/common",
41    "//base/startup/init/interfaces/innerkits/include/syspara",
42    "//third_party/bounds_checking_function/include",
43  ]
44
45  if (ohos_kernel_type == "liteos_m") {
46    static_library("softbus_adapter") {
47      include_dirs = common_include
48      include_dirs += [ "//kernel/liteos_m/kal/cmsis" ]
49      if (board_name == "hispark_pegasus") {
50        include_dirs +=
51            [ "$hispark_pegasus_sdk_path/third_party/lwip_sack/include" ]
52        defines = [ "HISPARK_PEGASUS_USE_NETIF_GET_ADDR" ]
53      }
54      if (board_toolchain_type == "iccarm") {
55        include_dirs += [
56          "//kernel/liteos_m/components/net/lwip-2.1/porting/include",
57          "//third_party/lwip/src/include",
58        ]
59        cflags = [
60          "--diag_suppress",
61          "Pe226,Pe513",
62        ]
63        ldflags = [ "-lpthread" ]
64      } else {
65        cflags = [ "-Wall" ]
66      }
67      sources = [
68        "$softbus_adapter_common/dfx/softbus_adapter_hisysevent_mini.c",
69        "$softbus_adapter_common/kernel/liteos_m/lnn_ip_utils_adapter.c",
70        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_file.c",
71        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_mem.c",
72        "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_timer.c",
73        "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
74        "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
75        "$softbus_adapter_common/log/softbus_adapter_log.c",
76        "$softbus_adapter_common/range/softbus_adapter_range.c",
77        "$softbus_adapter_config/spec_config/softbus_config_adapter.c",
78      ]
79      if (board_name == "v200zr") {
80        sources = []
81        sources = [
82          "$softbus_adapter_common/dfx/softbus_adapter_hisysevent_mini.c",
83          "$softbus_adapter_common/kernel/liteos_m/lnn_ip_utils_adapter.c",
84          "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_mem.c",
85          "$softbus_adapter_common/kernel/liteos_m/softbus_adapter_timer.c",
86          "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
87          "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
88          "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
89          "$softbus_adapter_common/log/softbus_adapter_log.c",
90          "$softbus_adapter_common/range/softbus_adapter_range.c",
91          "$softbus_adapter_config/spec_config/softbus_config_adapter.c",
92        ]
93      }
94
95      deps = [ "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite" ]
96
97      if (dsoftbus_feature_encrypt == 0) {
98        sources +=
99            [ "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c" ]
100        deps += [ "//third_party/mbedtls" ]
101      } else if (dsoftbus_feature_encrypt == 1) {
102        sources +=
103            [ "$softbus_adapter_common/openssl/softbus_adapter_crypto.c" ]
104        deps += [ "//third_party/openssl:libcrypto_shared" ]
105      }
106      public_configs = [ ":dsoftbus_adapter_common_interface" ]
107    }
108  } else {
109    shared_library("softbus_adapter") {
110      include_dirs = common_include
111      cflags = [
112        "-Wall",
113        "-Werror",
114        "-fPIC",
115        "-fno-builtin",
116        "-std=c99",
117      ]
118      cflags_cc = [ "-fPIC" ]
119      sources = [
120        "$softbus_adapter_common/dfx/softbus_adapter_hisysevent_mini.c",
121        "$softbus_adapter_common/kernel/posix/lnn_ip_utils_adapter.c",
122        "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
123        "$softbus_adapter_common/kernel/posix/softbus_adapter_mem.c",
124        "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
125        "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
126        "$softbus_adapter_common/kernel/posix/softbus_adapter_timer.c",
127        "$softbus_adapter_common/log/softbus_adapter_log.c",
128        "$softbus_adapter_common/range/softbus_adapter_range.c",
129        "$softbus_adapter_config/spec_config/softbus_config_adapter.c",
130      ]
131      deps = [
132        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
133        "//base/startup/init/interfaces/innerkits:libbegetutil",
134        "//third_party/bounds_checking_function:libsec_shared",
135      ]
136
137      if (dsoftbus_feature_encrypt == 0) {
138        sources +=
139            [ "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c" ]
140        deps += [ "//third_party/mbedtls" ]
141      } else if (dsoftbus_feature_encrypt == 1) {
142        sources +=
143            [ "$softbus_adapter_common/openssl/softbus_adapter_crypto.c" ]
144        deps += [ "//third_party/openssl:libcrypto_shared" ]
145      }
146      public_configs = [ ":dsoftbus_adapter_common_interface" ]
147    }
148  }
149} else {
150  config("config_adapter_common") {
151    include_dirs = [
152      "$softbus_adapter_common/include",
153      "$softbus_adapter_common/include/OS_adapter_define/linux",
154      "$dsoftbus_feature_product_config_path/spec_config",
155      "$dsoftbus_root_path/core/common/include",
156    ]
157  }
158
159  ohos_shared_library("softbus_adapter") {
160    include_dirs = [
161      "$dsoftbus_root_path/interfaces/kits",
162      "$dsoftbus_root_path/interfaces/kits/common",
163      "//base/startup/init/interfaces/innerkits/include/syspara",
164      "//commonlibrary/c_utils/base/include",
165      "//third_party/bounds_checking_function/include",
166    ]
167    sources = [
168      "$dsoftbus_feature_product_config_path/spec_config/softbus_config_adapter.c",
169      "$softbus_adapter_common/dfx/softbus_adapter_hisysevent.cpp",
170      "$softbus_adapter_common/kernel/posix/lnn_ip_utils_adapter.c",
171      "$softbus_adapter_common/kernel/posix/softbus_adapter_file.c",
172      "$softbus_adapter_common/kernel/posix/softbus_adapter_mem.c",
173      "$softbus_adapter_common/kernel/posix/softbus_adapter_socket.c",
174      "$softbus_adapter_common/kernel/posix/softbus_adapter_thread.c",
175      "$softbus_adapter_common/kernel/posix/softbus_adapter_timer.c",
176      "$softbus_adapter_common/log/softbus_adapter_log.c",
177    ]
178    public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
179    deps = [ "//base/startup/init/interfaces/innerkits:libbegetutil" ]
180    native_source_path = rebase_path("$dsoftbus_root_path")
181
182    ble_enhanced_impl =
183        "dsoftbus_enhance/adapter/common/range/softbus_adapter_range.c"
184    enhanced_range = exec_script("$dsoftbus_root_path/check_sub_module.py",
185                                 [
186                                   "$native_source_path",
187                                   "$ble_enhanced_impl",
188                                 ],
189                                 "value")
190
191    if (enhanced_range && defined(global_parts_info.msdp_algorithm)) {
192      include_dirs += [ "//base/msdp/algorithm/ble_range/include" ]
193      sources += [ "$dsoftbus_root_path/dsoftbus_enhance/adapter/common/range/softbus_adapter_range.c" ]
194      public_deps += [ "//base/msdp/algorithm/ble_range:msdp_ble_range" ]
195    } else {
196      sources += [ "$softbus_adapter_common/range/softbus_adapter_range.c" ]
197    }
198
199    if (dsoftbus_feature_encrypt == 0) {
200      sources += [ "$softbus_adapter_common/mbedtls/softbus_adapter_crypto.c" ]
201      public_deps += [ "//third_party/mbedtls" ]
202    } else if (dsoftbus_feature_encrypt == 1) {
203      sources += [ "$softbus_adapter_common/openssl/softbus_adapter_crypto.c" ]
204      public_deps += [ "//third_party/openssl:libcrypto_shared" ]
205    }
206    public_configs = [ ":config_adapter_common" ]
207    if (is_standard_system) {
208      external_deps = [
209        "hisysevent_native:libhisysevent",
210        "hiviewdfx_hilog_native:libhilog",
211      ]
212    }
213    part_name = "dsoftbus"
214    subsystem_name = "communication"
215  }
216}
217