1# Copyright (c) 2020-2022 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 14curl_source = [ 15 "//third_party/curl/lib/altsvc.c", 16 "//third_party/curl/lib/amigaos.c", 17 "//third_party/curl/lib/asyn-ares.c", 18 "//third_party/curl/lib/asyn-thread.c", 19 "//third_party/curl/lib/base64.c", 20 "//third_party/curl/lib/bufref.c", 21 "//third_party/curl/lib/c-hyper.c", 22 "//third_party/curl/lib/conncache.c", 23 "//third_party/curl/lib/connect.c", 24 "//third_party/curl/lib/content_encoding.c", 25 "//third_party/curl/lib/cookie.c", 26 "//third_party/curl/lib/curl_addrinfo.c", 27 "//third_party/curl/lib/curl_ctype.c", 28 "//third_party/curl/lib/curl_des.c", 29 "//third_party/curl/lib/curl_endian.c", 30 "//third_party/curl/lib/curl_fnmatch.c", 31 "//third_party/curl/lib/curl_get_line.c", 32 "//third_party/curl/lib/curl_gethostname.c", 33 "//third_party/curl/lib/curl_gssapi.c", 34 "//third_party/curl/lib/curl_memrchr.c", 35 "//third_party/curl/lib/curl_multibyte.c", 36 "//third_party/curl/lib/curl_ntlm_core.c", 37 "//third_party/curl/lib/curl_ntlm_wb.c", 38 "//third_party/curl/lib/curl_path.c", 39 "//third_party/curl/lib/curl_range.c", 40 "//third_party/curl/lib/curl_rtmp.c", 41 "//third_party/curl/lib/curl_sasl.c", 42 "//third_party/curl/lib/curl_sspi.c", 43 "//third_party/curl/lib/curl_threads.c", 44 "//third_party/curl/lib/dict.c", 45 "//third_party/curl/lib/doh.c", 46 "//third_party/curl/lib/dotdot.c", 47 "//third_party/curl/lib/dynbuf.c", 48 "//third_party/curl/lib/easy.c", 49 "//third_party/curl/lib/easygetopt.c", 50 "//third_party/curl/lib/easyoptions.c", 51 "//third_party/curl/lib/escape.c", 52 "//third_party/curl/lib/file.c", 53 "//third_party/curl/lib/fileinfo.c", 54 "//third_party/curl/lib/fopen.c", 55 "//third_party/curl/lib/formdata.c", 56 "//third_party/curl/lib/ftp.c", 57 "//third_party/curl/lib/ftplistparser.c", 58 "//third_party/curl/lib/getenv.c", 59 "//third_party/curl/lib/getinfo.c", 60 "//third_party/curl/lib/gopher.c", 61 "//third_party/curl/lib/hash.c", 62 "//third_party/curl/lib/hmac.c", 63 "//third_party/curl/lib/hostasyn.c", 64 "//third_party/curl/lib/hostcheck.c", 65 "//third_party/curl/lib/hostip.c", 66 "//third_party/curl/lib/hostip4.c", 67 "//third_party/curl/lib/hostip6.c", 68 "//third_party/curl/lib/hostsyn.c", 69 "//third_party/curl/lib/hsts.c", 70 "//third_party/curl/lib/http.c", 71 "//third_party/curl/lib/http_aws_sigv4.c", 72 "//third_party/curl/lib/http2.c", 73 "//third_party/curl/lib/http_chunks.c", 74 "//third_party/curl/lib/http_digest.c", 75 "//third_party/curl/lib/http_negotiate.c", 76 "//third_party/curl/lib/http_ntlm.c", 77 "//third_party/curl/lib/http_proxy.c", 78 "//third_party/curl/lib/idn_win32.c", 79 "//third_party/curl/lib/if2ip.c", 80 "//third_party/curl/lib/imap.c", 81 "//third_party/curl/lib/inet_ntop.c", 82 "//third_party/curl/lib/inet_pton.c", 83 "//third_party/curl/lib/krb5.c", 84 "//third_party/curl/lib/ldap.c", 85 "//third_party/curl/lib/llist.c", 86 "//third_party/curl/lib/md4.c", 87 "//third_party/curl/lib/md5.c", 88 "//third_party/curl/lib/memdebug.c", 89 "//third_party/curl/lib/mime.c", 90 "//third_party/curl/lib/mprintf.c", 91 "//third_party/curl/lib/mqtt.c", 92 "//third_party/curl/lib/multi.c", 93 "//third_party/curl/lib/netrc.c", 94 "//third_party/curl/lib/non-ascii.c", 95 "//third_party/curl/lib/nonblock.c", 96 "//third_party/curl/lib/openldap.c", 97 "//third_party/curl/lib/parsedate.c", 98 "//third_party/curl/lib/pingpong.c", 99 "//third_party/curl/lib/pop3.c", 100 "//third_party/curl/lib/progress.c", 101 "//third_party/curl/lib/psl.c", 102 "//third_party/curl/lib/rand.c", 103 "//third_party/curl/lib/rename.c", 104 "//third_party/curl/lib/rtsp.c", 105 "//third_party/curl/lib/select.c", 106 "//third_party/curl/lib/sendf.c", 107 "//third_party/curl/lib/setopt.c", 108 "//third_party/curl/lib/sha256.c", 109 "//third_party/curl/lib/share.c", 110 "//third_party/curl/lib/slist.c", 111 "//third_party/curl/lib/smb.c", 112 "//third_party/curl/lib/smtp.c", 113 "//third_party/curl/lib/socketpair.c", 114 "//third_party/curl/lib/socks.c", 115 "//third_party/curl/lib/socks_gssapi.c", 116 "//third_party/curl/lib/socks_sspi.c", 117 "//third_party/curl/lib/speedcheck.c", 118 "//third_party/curl/lib/splay.c", 119 "//third_party/curl/lib/strcase.c", 120 "//third_party/curl/lib/strdup.c", 121 "//third_party/curl/lib/strerror.c", 122 "//third_party/curl/lib/strtok.c", 123 "//third_party/curl/lib/strtoofft.c", 124 "//third_party/curl/lib/system_win32.c", 125 "//third_party/curl/lib/telnet.c", 126 "//third_party/curl/lib/tftp.c", 127 "//third_party/curl/lib/timeval.c", 128 "//third_party/curl/lib/transfer.c", 129 "//third_party/curl/lib/url.c", 130 "//third_party/curl/lib/urlapi.c", 131 "//third_party/curl/lib/vauth/cleartext.c", 132 "//third_party/curl/lib/vauth/cram.c", 133 "//third_party/curl/lib/vauth/digest.c", 134 "//third_party/curl/lib/vauth/digest_sspi.c", 135 "//third_party/curl/lib/vauth/gsasl.c", 136 "//third_party/curl/lib/vauth/krb5_gssapi.c", 137 "//third_party/curl/lib/vauth/krb5_sspi.c", 138 "//third_party/curl/lib/vauth/ntlm.c", 139 "//third_party/curl/lib/vauth/ntlm_sspi.c", 140 "//third_party/curl/lib/vauth/oauth2.c", 141 "//third_party/curl/lib/vauth/spnego_gssapi.c", 142 "//third_party/curl/lib/vauth/spnego_sspi.c", 143 "//third_party/curl/lib/vauth/vauth.c", 144 "//third_party/curl/lib/version.c", 145 "//third_party/curl/lib/version_win32.c", 146 "//third_party/curl/lib/vquic/ngtcp2.c", 147 "//third_party/curl/lib/vquic/quiche.c", 148 "//third_party/curl/lib/vquic/vquic.c", 149 "//third_party/curl/lib/vssh/libssh.c", 150 "//third_party/curl/lib/vssh/libssh2.c", 151 "//third_party/curl/lib/vssh/wolfssh.c", 152 "//third_party/curl/lib/vtls/bearssl.c", 153 "//third_party/curl/lib/vtls/gskit.c", 154 "//third_party/curl/lib/vtls/gtls.c", 155 "//third_party/curl/lib/vtls/keylog.c", 156 "//third_party/curl/lib/vtls/mbedtls.c", 157 "//third_party/curl/lib/vtls/mbedtls_threadlock.c", 158 "//third_party/curl/lib/vtls/mesalink.c", 159 "//third_party/curl/lib/vtls/nss.c", 160 "//third_party/curl/lib/vtls/openssl.c", 161 "//third_party/curl/lib/vtls/rustls.c", 162 "//third_party/curl/lib/vtls/schannel.c", 163 "//third_party/curl/lib/vtls/schannel_verify.c", 164 "//third_party/curl/lib/vtls/sectransp.c", 165 "//third_party/curl/lib/vtls/vtls.c", 166 "//third_party/curl/lib/vtls/wolfssl.c", 167 "//third_party/curl/lib/warnless.c", 168 "//third_party/curl/lib/wildcard.c", 169 "//third_party/curl/lib/x509asn1.c", 170] 171 172if (defined(ohos_lite)) { 173 import("//build/lite/config/component/lite_component.gni") 174 175 config("curl_config") { 176 include_dirs = [ "//third_party/curl/lib" ] 177 if (ohos_kernel_type == "liteos_m") { 178 include_dirs += [ "//kernel/liteos_m/kal/posix/include" ] 179 } 180 cflags = [ 181 "-DBUILDING_LIBCURL", 182 "-DHAVE_CONFIG_H", 183 "-D_GNU_SOURCE", 184 "-DOS=\"liteOS\"", 185 "-fPIC", 186 "-Wdeclaration-after-statement", 187 "-Wendif-labels", 188 "-Wfloat-equal", 189 "-Winline", 190 "-Wmissing-declarations", 191 "-Wmissing-prototypes", 192 "-Wnested-externs", 193 "-Wno-format-nonliteral", 194 "-Wno-implicit-function-declaration", 195 "-Wno-int-conversion", 196 "-Wno-long-long", 197 "-Wno-multichar", 198 "-Wno-nested-externs", 199 "-Wno-sign-compare", 200 "-Wno-system-headers", 201 "-Wno-varargs", 202 "-Wno-overflow", 203 "-Wpointer-arith", 204 "-Wstrict-prototypes", 205 "-Wunused", 206 "-Wwrite-strings", 207 "-Wno-unused-variable", 208 "-Wno-parentheses", 209 "-Wno-strict-prototypes", 210 "-Os", 211 "-ffunction-sections", 212 "-fdata-sections", 213 "-fno-unwind-tables", 214 "-fno-asynchronous-unwind-tables", 215 ] 216 if (ohos_kernel_type == "liteos_m") { 217 cflags += [ "-DOHOS_CURL_CONFIG_H=\"curl_config_liteos_m.h\"" ] 218 } else { 219 cflags += [ "-DOHOS_CURL_CONFIG_H=\"curl_config_liteos_a.h\"" ] 220 } 221 } 222 223 config("curl_config_public") { 224 include_dirs = [ 225 "//third_party/curl/lib", 226 "//third_party/curl/include", 227 ] 228 } 229 230 if (ohos_kernel_type == "liteos_m") { 231 static_library("libcurl_static") { 232 sources = curl_source 233 deps = [ "//third_party/mbedtls" ] 234 deps += [ "//third_party/nghttp2/lib:nghttp2_lib_static" ] 235 configs += [ 236 ":curl_config", 237 ":curl_config_public", 238 ] 239 240 public_configs = [ ":curl_config_public" ] 241 } 242 } else { 243 shared_library("libcurl_shared") { 244 sources = curl_source 245 deps = [ "//third_party/mbedtls" ] 246 deps += [ "//third_party/nghttp2/lib:nghttp2_lib_shared" ] 247 configs += [ 248 ":curl_config", 249 ":curl_config_public", 250 ] 251 public_configs = [ ":curl_config_public" ] 252 } 253 } 254} else { 255 import("//build/ohos.gni") 256 257 config("curl_config") { 258 visibility = [ ":*" ] 259 260 include_dirs = [ 261 "//third_party/curl/include", 262 "//third_party/curl/lib", 263 "//third_party/nghttp2/lib/includes", 264 ] 265 } 266 267 ohos_source_set("curl") { 268 configs = [ "//third_party/curl:curl_config" ] 269 configs += [ "//third_party/openssl:ssl_config_public" ] 270 271 sources = curl_source 272 273 if ("${current_os}_${current_cpu}" == "mingw_x86_64") { 274 curl_https_ca_file_path = "\"../../resources/cacert.pem\"" 275 276 cflags = [ 277 "-g", 278 "-O2", 279 "-Wall", 280 "-w", 281 "-fno-strict-aliasing", 282 "-m64", 283 "-D_AMD64_", 284 "-DBUILDING_LIBCURL", 285 "-c", 286 "-DUSE_OPENSSL", 287 "-DHAVE_OPENSSL_ENGINE_H", 288 "-DHAVE_OPENSSL_PKCS12_H", 289 "-DHAVE_ENGINE_LOAD_BUILTIN_ENGINES", 290 "-DOPENSSL_NO_KRB5", 291 "-DCURL_CA_BUNDLE=${curl_https_ca_file_path}", 292 ] 293 294 libs = [ 295 "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32/lib/libwsock32.a", 296 "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32/lib/libmincore.a", 297 ] 298 } else if (host_os == "mac" && current_os == "mac") { 299 cflags = [ 300 "-DHAVE_CONFIG_H", 301 "-Qunused-arguments", 302 "-Os", 303 "-mmacosx-version-min=10.8", 304 "-Werror=partial-availability", 305 "-fvisibility=hidden", 306 "-DBUILDING_LIBCURL", 307 "-DCURL_HIDDEN_SYMBOLS", 308 "-c", 309 ] 310 cflags_c = [ 311 "-Wno-unused-function", 312 ] 313 libs = [ 314 # AppKit symbols NSFontWeightXXX may be dlsym'ed. 315 "AppKit.framework", 316 "ApplicationServices.framework", 317 "OpenGL.framework", 318 "CoreFoundation.framework", 319 "SystemConfiguration.framework", 320 ] 321 } else if ("${current_cpu}" == "arm64" || "${current_cpu}" == "arm" || 322 "${current_cpu}" == "x86_64") { 323 cflags = [ 324 "-fPIC", 325 "-g", 326 "-O2", 327 "-Wall", 328 "-w", 329 "-fno-strict-aliasing", 330 "-fvisibility=hidden", 331 "-DBUILDING_LIBCURL", 332 "-DCURL_HIDDEN_SYMBOLS", 333 "-c", 334 "-DHAVE_CONFIG_H", 335 ] 336 } else if (current_cpu == "x64" && current_os == "ios") { 337 cflags = [ 338 "-fPIC", 339 "-g", 340 "-O2", 341 "-Wall", 342 "-w", 343 "-fno-strict-aliasing", 344 "-fvisibility=hidden", 345 "-DBUILDING_LIBCURL", 346 "-DCURL_HIDDEN_SYMBOLS", 347 "-c", 348 "-DHAVE_CONFIG_H", 349 ] 350 } else if (current_cpu == "x64" && current_os == "linux") { 351 cflags = [ 352 "-fPIC", 353 "-g", 354 "-O2", 355 "-Wall", 356 "-w", 357 "-fno-strict-aliasing", 358 "-fvisibility=hidden", 359 "-DBUILDING_LIBCURL", 360 "-DCURL_HIDDEN_SYMBOLS", 361 "-c", 362 "-DHAVE_CONFIG_H", 363 ] 364 } 365 cflags += [ "-DOHOS_CURL_CONFIG_H=\"curl_config_standard.h\"" ] 366 367 deps = [ 368 "//third_party/nghttp2/lib:libnghttp2_shared", 369 "//third_party/openssl:libcrypto_shared", 370 "//third_party/openssl:libssl_shared", 371 "//third_party/zlib:shared_libz", 372 ] 373 } 374 375 ohos_shared_library("curl_shared") { 376 deps = [ ":curl" ] 377 public_configs = [ ":curl_config" ] 378 379 install_images = [ "system" ] 380 381 subsystem_name = "thirdparty" 382 part_name = "curl" 383 } 384} 385 386group("curl_target") { 387 if (defined(ohos_lite)) { 388 if (ohos_kernel_type == "liteos_m") { 389 deps = [ ":libcurl_static" ] 390 } else { 391 deps = [ ":libcurl_shared" ] 392 } 393 } else { 394 deps = [ 395 ":curl", 396 ":curl_shared", 397 ] 398 } 399} 400