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