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 14DSOFTBUS_ROOT_PATH = "./../../.." 15import("$DSOFTBUS_ROOT_PATH/dsoftbus.gni") 16 17NSTACKX_ROOT = "$DSOFTBUS_ROOT_PATH/components/nstackx" 18cflags = [ "-DENABLE_USER_LOG" ] 19if (defined(ohos_lite)) { 20 import("//build/lite/config/component/lite_component.gni") 21 if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") { 22 config("nstackx_util_header") { 23 include_dirs = [ 24 "interface", 25 "platform/liteos", 26 ] 27 } 28 } else if (ohos_kernel_type == "linux") { 29 config("nstackx_util_header") { 30 include_dirs = [ 31 "interface", 32 "platform/unix", 33 ] 34 } 35 } 36 if (ohos_kernel_type == "liteos_m") { 37 static_library("nstackx_util.open") { 38 cflags += [ 39 "-D_GNU_SOURCE", 40 "-DNSTACKX_WITH_LITEOS", 41 "-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS", 42 "-DLWIP_LITEOS_A_COMPAT", 43 "-DMBEDTLS_INCLUDED", 44 "-DNSTACKX_WITH_LITEOS_M", 45 "-DENABLE_USER_LOG", 46 ] 47 if (board_toolchain_type != "iccarm") { 48 cflags += [ "-Wall" ] 49 } 50 cflags_cc = cflags 51 include_dirs = [ 52 "include", 53 "interface", 54 "platform/liteos", 55 "$NSTACKX_ROOT/nstackx_core/", 56 "$hilog_lite_include_path", 57 "$utils_lite_include_path", 58 ] 59 sources = [ 60 "core/nstackx_event.c", 61 "core/nstackx_log.c", 62 "core/nstackx_socket.c", 63 "core/nstackx_timer.c", 64 ] 65 66 sources += [ 67 "core/nstackx_getopt.c", 68 "platform/liteos/sys_dev.c", 69 "platform/liteos/sys_epoll.c", 70 "platform/liteos/sys_event.c", 71 "platform/liteos/sys_log.c", 72 "platform/liteos/sys_socket.c", 73 "platform/liteos/sys_timer.c", 74 "platform/liteos/sys_util.c", 75 ] 76 77 public_configs = [ ":nstackx_util_header" ] 78 } 79 } else { 80 shared_library("nstackx_util.open") { 81 if (ohos_kernel_type == "liteos_a") { 82 cflags += [ 83 "-Wall", 84 "-D_GNU_SOURCE", 85 "-DNSTACKX_WITH_LITEOS", 86 "-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS", 87 "-DLWIP_LITEOS_A_COMPAT", 88 "-DMBEDTLS_INCLUDED", 89 "-DENABLE_USER_LOG", 90 ] 91 cflags_cc = cflags 92 include_dirs = [ 93 "include", 94 "interface", 95 "platform/liteos", 96 "$NSTACKX_ROOT/nstackx_core/", 97 "$hilog_lite_include_path", 98 "$utils_lite_include_path", 99 ] 100 sources = [ 101 "core/nstackx_dev.c", 102 "core/nstackx_event.c", 103 "core/nstackx_getopt.c", 104 "core/nstackx_log.c", 105 "core/nstackx_mbedtls.c", 106 "core/nstackx_socket.c", 107 "core/nstackx_timer.c", 108 "core/nstackx_util.c", 109 "platform/liteos/sys_dev.c", 110 "platform/liteos/sys_epoll.c", 111 "platform/liteos/sys_event.c", 112 "platform/liteos/sys_log.c", 113 "platform/liteos/sys_socket.c", 114 "platform/liteos/sys_timer.c", 115 "platform/liteos/sys_util.c", 116 ] 117 deps = [ "$hilog_lite_deps_path" ] 118 external_deps = [ 119 "bounds_checking_function:libsec_shared", 120 "mbedtls:mbedtls_shared", 121 ] 122 } else if (ohos_kernel_type == "linux") { 123 cflags += [ 124 "-Wall", 125 "-DNSTACKX_WITH_HMOS_LINUX", 126 "-DMBEDTLS_INCLUDED", 127 "-DENABLE_USER_LOG", 128 ] 129 cflags_cc = cflags 130 include_dirs = [ 131 "include", 132 "interface", 133 "platform/unix", 134 "$NSTACKX_ROOT/nstackx_core/", 135 "$hilog_lite_include_path", 136 "$utils_lite_include_path", 137 ] 138 sources = [ 139 "core/nstackx_dev.c", 140 "core/nstackx_event.c", 141 "core/nstackx_getopt.c", 142 "core/nstackx_log.c", 143 "core/nstackx_mbedtls.c", 144 "core/nstackx_socket.c", 145 "core/nstackx_timer.c", 146 "core/nstackx_util.c", 147 "platform/unix/sys_dev.c", 148 "platform/unix/sys_epoll.c", 149 "platform/unix/sys_event.c", 150 "platform/unix/sys_log.c", 151 "platform/unix/sys_socket.c", 152 "platform/unix/sys_timer.c", 153 "platform/unix/sys_util.c", 154 ] 155 deps = [ "$hilog_lite_deps_path" ] 156 external_deps = [ 157 "bounds_checking_function:libsec_shared", 158 "mbedtls:mbedtls_shared", 159 ] 160 } 161 public_configs = [ ":nstackx_util_header" ] 162 } 163 } 164} else { 165 import("//build/ohos.gni") 166 167 config("nstackx_util_header") { 168 include_dirs = [ 169 "interface", 170 "platform/unix", 171 ] 172 } 173 174 ohos_shared_library("nstackx_util.open") { 175 sanitize = { 176 ubsan = true 177 integer_overflow = true 178 boundary_sanitize = true 179 cfi = true 180 cfi_cross_dso = true 181 debug = false 182 } 183 branch_protector_ret = "pac_ret" 184 185 cflags += [ 186 "-DNSTACKX_WITH_HMOS_LINUX", 187 "-DENABLE_USER_LOG", 188 "-DNSTACKX_WITH_LINUX_STANDARD", 189 ] 190 if (defined(board_toolchain_type)) { 191 if (board_toolchain_type != "iccarm") { 192 cflags += [ "-Wall" ] 193 } 194 } else { 195 cflags += [ "-Wall" ] 196 } 197 cflags_cc = cflags 198 include_dirs = [ 199 "include", 200 "interface", 201 "platform/unix", 202 "$NSTACKX_ROOT/nstackx_core/", 203 ] 204 sources = [ 205 "core/nstackx_dev.c", 206 "core/nstackx_event.c", 207 "core/nstackx_getopt.c", 208 "core/nstackx_log.c", 209 "core/nstackx_socket.c", 210 "core/nstackx_timer.c", 211 "core/nstackx_util.c", 212 "platform/unix/sys_dev.c", 213 "platform/unix/sys_epoll.c", 214 "platform/unix/sys_event.c", 215 "platform/unix/sys_log.c", 216 "platform/unix/sys_socket.c", 217 "platform/unix/sys_timer.c", 218 "platform/unix/sys_util.c", 219 ] 220 221 external_deps = [ 222 "bounds_checking_function:libsec_shared", 223 "hilog:libhilog", 224 ] 225 if (is_standard_system) { 226 cflags += [ "-DSSL_AND_CRYPTO_INCLUDED" ] 227 sources += [ "core/nstackx_openssl.c" ] 228 external_deps += [ 229 "c_utils:utils", 230 "openssl:libcrypto_shared", 231 ] 232 } 233 public_configs = [ ":nstackx_util_header" ] 234 innerapi_tags = [ "platformsdk_indirect" ] 235 part_name = "dsoftbus" 236 subsystem_name = "communication" 237 } 238} 239