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