11e934351Sopenharmony_ci# Copyright (c) 2021-2024 Huawei Device Co., Ltd. 21e934351Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 31e934351Sopenharmony_ci# you may not use this file except in compliance with the License. 41e934351Sopenharmony_ci# You may obtain a copy of the License at 51e934351Sopenharmony_ci# 61e934351Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 71e934351Sopenharmony_ci# 81e934351Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 91e934351Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 101e934351Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 111e934351Sopenharmony_ci# See the License for the specific language governing permissions and 121e934351Sopenharmony_ci# limitations under the License. 131e934351Sopenharmony_ci 141e934351Sopenharmony_ciimport("//build/ohos.gni") 151e934351Sopenharmony_ciimport("//foundation/communication/netstack/netstack_config.gni") 161e934351Sopenharmony_ci 171e934351Sopenharmony_ciconfig("http_config") { 181e934351Sopenharmony_ci include_dirs = [ 191e934351Sopenharmony_ci "async_context/include", 201e934351Sopenharmony_ci "async_work/include", 211e934351Sopenharmony_ci "cache/base64/include", 221e934351Sopenharmony_ci "cache/cache_constant/include", 231e934351Sopenharmony_ci "cache/cache_proxy/include", 241e934351Sopenharmony_ci "cache/cache_strategy/include", 251e934351Sopenharmony_ci "cache/lru_cache/include", 261e934351Sopenharmony_ci "constant/include", 271e934351Sopenharmony_ci "http_exec/include", 281e934351Sopenharmony_ci "http_module/include", 291e934351Sopenharmony_ci "options/include", 301e934351Sopenharmony_ci "$NETSTACK_DIR/utils/common_utils/include", 311e934351Sopenharmony_ci ] 321e934351Sopenharmony_ci if (defined(global_parts_info) && 331e934351Sopenharmony_ci defined(global_parts_info.communication_netmanager_base) && 341e934351Sopenharmony_ci global_parts_info.communication_netmanager_base) { 351e934351Sopenharmony_ci include_dirs += [ 361e934351Sopenharmony_ci "$NETMANAGER_BASE_INNERKITS_DIR/include", 371e934351Sopenharmony_ci "$NETMANAGER_BASE_INNERKITS_DIR/netconnclient/include", 381e934351Sopenharmony_ci "$NETSTACK_DIR/utils/http_over_curl/include", 391e934351Sopenharmony_ci ] 401e934351Sopenharmony_ci } 411e934351Sopenharmony_ci defines = [] 421e934351Sopenharmony_ci 431e934351Sopenharmony_ci if (is_mingw || is_mac) { 441e934351Sopenharmony_ci cflags = [ 451e934351Sopenharmony_ci "-std=c++17", 461e934351Sopenharmony_ci "-stdlib=libc++", 471e934351Sopenharmony_ci ] 481e934351Sopenharmony_ci } 491e934351Sopenharmony_ci if (is_mingw) { 501e934351Sopenharmony_ci defines += [ "WINDOWS_PLATFORM" ] 511e934351Sopenharmony_ci } else if (is_mac) { 521e934351Sopenharmony_ci defines += [ "MAC_PLATFORM" ] 531e934351Sopenharmony_ci cflags_cc = [ 541e934351Sopenharmony_ci "-fstack-protector-strong", 551e934351Sopenharmony_ci "-D_FORTIFY_SOURCE=2", 561e934351Sopenharmony_ci "-O2", 571e934351Sopenharmony_ci ] 581e934351Sopenharmony_ci } else if (product_name != "ohos-sdk") { 591e934351Sopenharmony_ci defines += [ "HTTP_PROXY_ENABLE" ] 601e934351Sopenharmony_ci cflags_cc = [ 611e934351Sopenharmony_ci "-fstack-protector-strong", 621e934351Sopenharmony_ci "-D_FORTIFY_SOURCE=2", 631e934351Sopenharmony_ci "-O2", 641e934351Sopenharmony_ci ] 651e934351Sopenharmony_ci } 661e934351Sopenharmony_ci 671e934351Sopenharmony_ci if (product_name != "ohos-sdk") { 681e934351Sopenharmony_ci defines += [ "HTTP_MULTIPATH_CERT_ENABLE" ] 691e934351Sopenharmony_ci } 701e934351Sopenharmony_ci 711e934351Sopenharmony_ci if (netstack_http_boringssl) { 721e934351Sopenharmony_ci defines += [ "HTTP_CACHE_FILE_PATH_USE_BASE" ] 731e934351Sopenharmony_ci } 741e934351Sopenharmony_ci} 751e934351Sopenharmony_ci 761e934351Sopenharmony_ciohos_shared_library("http") { 771e934351Sopenharmony_ci if (product_name != "ohos-sdk") { 781e934351Sopenharmony_ci sanitize = { 791e934351Sopenharmony_ci cfi = true 801e934351Sopenharmony_ci cfi_cross_dso = true 811e934351Sopenharmony_ci debug = false 821e934351Sopenharmony_ci } 831e934351Sopenharmony_ci } 841e934351Sopenharmony_ci 851e934351Sopenharmony_ci branch_protector_ret = "pac_ret" 861e934351Sopenharmony_ci 871e934351Sopenharmony_ci include_dirs = [] 881e934351Sopenharmony_ci 891e934351Sopenharmony_ci sources = [ 901e934351Sopenharmony_ci "$NETSTACK_DIR/utils/profiler_utils/src/http_network_message.cpp", 911e934351Sopenharmony_ci "$NETSTACK_DIR/utils/profiler_utils/src/i_network_message.cpp", 921e934351Sopenharmony_ci "$NETSTACK_DIR/utils/profiler_utils/src/netstack_network_profiler.cpp", 931e934351Sopenharmony_ci "$NETSTACK_DIR/utils/tlv_utils/src/tlv_utils.cpp", 941e934351Sopenharmony_ci "async_context/src/request_context.cpp", 951e934351Sopenharmony_ci "async_work/src/http_async_work.cpp", 961e934351Sopenharmony_ci "cache/base64/src/base64_utils.cpp", 971e934351Sopenharmony_ci "cache/cache_proxy/src/cache_proxy.cpp", 981e934351Sopenharmony_ci "cache/cache_strategy/src/http_cache_request.cpp", 991e934351Sopenharmony_ci "cache/cache_strategy/src/http_cache_response.cpp", 1001e934351Sopenharmony_ci "cache/cache_strategy/src/http_cache_strategy.cpp", 1011e934351Sopenharmony_ci "cache/cache_strategy/src/http_time.cpp", 1021e934351Sopenharmony_ci "cache/lru_cache/src/disk_handler.cpp", 1031e934351Sopenharmony_ci "cache/lru_cache/src/lru_cache.cpp", 1041e934351Sopenharmony_ci "cache/lru_cache/src/lru_cache_disk_handler.cpp", 1051e934351Sopenharmony_ci "constant/src/constant.cpp", 1061e934351Sopenharmony_ci "http_exec/src/http_exec.cpp", 1071e934351Sopenharmony_ci "http_module/src/http_module.cpp", 1081e934351Sopenharmony_ci "options/src/http_request_options.cpp", 1091e934351Sopenharmony_ci "options/src/http_response.cpp", 1101e934351Sopenharmony_ci ] 1111e934351Sopenharmony_ci 1121e934351Sopenharmony_ci configs = [ ":http_config" ] 1131e934351Sopenharmony_ci 1141e934351Sopenharmony_ci if (is_mingw || is_mac) { 1151e934351Sopenharmony_ci sources += [ 1161e934351Sopenharmony_ci "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp", 1171e934351Sopenharmony_ci "$NETSTACK_DIR/utils/common_utils/src/request_tracer.cpp", 1181e934351Sopenharmony_ci ] 1191e934351Sopenharmony_ci deps = [ 1201e934351Sopenharmony_ci "$ARKUI_ROOT/napi:ace_napi", 1211e934351Sopenharmony_ci "$NETSTACK_DIR/utils/napi_utils:napi_utils_static", 1221e934351Sopenharmony_ci "$THIRD_PARTY_ROOT/bounds_checking_function:libsec_static", 1231e934351Sopenharmony_ci "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp_static", 1241e934351Sopenharmony_ci ] 1251e934351Sopenharmony_ci external_deps = [ 1261e934351Sopenharmony_ci "cJSON:cjson", 1271e934351Sopenharmony_ci "curl:curl_shared", 1281e934351Sopenharmony_ci ] 1291e934351Sopenharmony_ci ldflags = [ "-lpthread" ] 1301e934351Sopenharmony_ci } else { 1311e934351Sopenharmony_ci deps = [ 1321e934351Sopenharmony_ci "$NETSTACK_DIR/utils:stack_utils_common", 1331e934351Sopenharmony_ci "$NETSTACK_DIR/utils/napi_utils:napi_utils", 1341e934351Sopenharmony_ci "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp", 1351e934351Sopenharmony_ci ] 1361e934351Sopenharmony_ci external_deps = [ 1371e934351Sopenharmony_ci "ability_runtime:wantagent_innerkits", 1381e934351Sopenharmony_ci "cJSON:cjson", 1391e934351Sopenharmony_ci "curl:curl_shared_http3", 1401e934351Sopenharmony_ci "hilog:libhilog", 1411e934351Sopenharmony_ci "hiprofiler:libnetwork_profiler", 1421e934351Sopenharmony_ci "hitrace:hitrace_meter", 1431e934351Sopenharmony_ci "napi:ace_napi", 1441e934351Sopenharmony_ci "time_service:time_client", 1451e934351Sopenharmony_ci ] 1461e934351Sopenharmony_ci if (netstack_http_boringssl) { 1471e934351Sopenharmony_ci deps += [ 1481e934351Sopenharmony_ci "//vendor/open_source/boringssl:crypto_boringssl", 1491e934351Sopenharmony_ci "//vendor/open_source/boringssl:ssl_boringssl", 1501e934351Sopenharmony_ci ] 1511e934351Sopenharmony_ci } else { 1521e934351Sopenharmony_ci external_deps += [ 1531e934351Sopenharmony_ci "openssl:libcrypto_shared", 1541e934351Sopenharmony_ci "openssl:libssl_shared", 1551e934351Sopenharmony_ci ] 1561e934351Sopenharmony_ci } 1571e934351Sopenharmony_ci if (defined(global_parts_info) && 1581e934351Sopenharmony_ci defined(global_parts_info.communication_netmanager_base) && 1591e934351Sopenharmony_ci global_parts_info.communication_netmanager_base) { 1601e934351Sopenharmony_ci external_deps += [ "netmanager_base:net_conn_manager_if" ] 1611e934351Sopenharmony_ci external_deps += [ "netmanager_base:netsys_client" ] 1621e934351Sopenharmony_ci defines = [ "HAS_NETMANAGER_BASE=1" ] 1631e934351Sopenharmony_ci sources += [ 1641e934351Sopenharmony_ci "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 1651e934351Sopenharmony_ci "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 1661e934351Sopenharmony_ci ] 1671e934351Sopenharmony_ci } else { 1681e934351Sopenharmony_ci defines = [ "HAS_NETMANAGER_BASE=0" ] 1691e934351Sopenharmony_ci } 1701e934351Sopenharmony_ci if (product_name != "ohos-sdk") { 1711e934351Sopenharmony_ci external_deps += [ "init:libbegetutil" ] 1721e934351Sopenharmony_ci } 1731e934351Sopenharmony_ci } 1741e934351Sopenharmony_ci include_dirs += [ 1751e934351Sopenharmony_ci "$NETSTACK_DIR/utils/profiler_utils/include", 1761e934351Sopenharmony_ci "$NETSTACK_DIR/utils/tlv_utils/include", 1771e934351Sopenharmony_ci ] 1781e934351Sopenharmony_ci cflags = [ 1791e934351Sopenharmony_ci "-fstack-protector-strong", 1801e934351Sopenharmony_ci "-D_FORTIFY_SOURCE=2", 1811e934351Sopenharmony_ci "-O2", 1821e934351Sopenharmony_ci ] 1831e934351Sopenharmony_ci 1841e934351Sopenharmony_ci relative_install_dir = "module/net" 1851e934351Sopenharmony_ci part_name = "netstack" 1861e934351Sopenharmony_ci subsystem_name = "communication" 1871e934351Sopenharmony_ci} 188