1# Copyright (c) 2021-2024 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("//build/ohos.gni") 15import("//foundation/communication/netstack/netstack_config.gni") 16 17config("http_config") { 18 include_dirs = [ 19 "async_context/include", 20 "async_work/include", 21 "cache/base64/include", 22 "cache/cache_constant/include", 23 "cache/cache_proxy/include", 24 "cache/cache_strategy/include", 25 "cache/lru_cache/include", 26 "constant/include", 27 "http_exec/include", 28 "http_module/include", 29 "options/include", 30 "$NETSTACK_DIR/utils/common_utils/include", 31 ] 32 if (defined(global_parts_info) && 33 defined(global_parts_info.communication_netmanager_base) && 34 global_parts_info.communication_netmanager_base) { 35 include_dirs += [ "$NETSTACK_DIR/utils/http_over_curl/include" ] 36 } 37 defines = [] 38 39 if (is_mingw || is_mac) { 40 cflags = [ 41 "-std=c++17", 42 "-stdlib=libc++", 43 ] 44 } 45 if (is_mingw) { 46 defines += [ "WINDOWS_PLATFORM" ] 47 } else if (is_mac) { 48 defines += [ "MAC_PLATFORM" ] 49 cflags_cc = [ 50 "-fstack-protector-strong", 51 "-D_FORTIFY_SOURCE=2", 52 "-O2", 53 ] 54 } else if (product_name != "ohos-sdk") { 55 defines += [ "HTTP_PROXY_ENABLE" ] 56 cflags_cc = [ 57 "-fstack-protector-strong", 58 "-D_FORTIFY_SOURCE=2", 59 "-O2", 60 ] 61 } 62 63 if (product_name != "ohos-sdk") { 64 defines += [ 65 "HTTP_MULTIPATH_CERT_ENABLE", 66 "HTTP_ONLY_VERIFY_ROOT_CA_ENABLE", 67 ] 68 } 69 70 if (netstack_http_boringssl) { 71 defines += [ "HTTP_CACHE_FILE_PATH_USE_BASE" ] 72 } 73} 74 75ohos_shared_library("http") { 76 if (product_name != "ohos-sdk") { 77 sanitize = { 78 cfi = true 79 cfi_cross_dso = true 80 debug = false 81 } 82 } 83 84 branch_protector_ret = "pac_ret" 85 86 include_dirs = [] 87 88 sources = [ 89 "$NETSTACK_DIR/utils/profiler_utils/src/http_network_message.cpp", 90 "$NETSTACK_DIR/utils/profiler_utils/src/i_network_message.cpp", 91 "$NETSTACK_DIR/utils/profiler_utils/src/netstack_network_profiler.cpp", 92 "$NETSTACK_DIR/utils/tlv_utils/src/tlv_utils.cpp", 93 "async_context/src/request_context.cpp", 94 "async_work/src/http_async_work.cpp", 95 "cache/base64/src/base64_utils.cpp", 96 "cache/cache_proxy/src/cache_proxy.cpp", 97 "cache/cache_strategy/src/http_cache_request.cpp", 98 "cache/cache_strategy/src/http_cache_response.cpp", 99 "cache/cache_strategy/src/http_cache_strategy.cpp", 100 "cache/cache_strategy/src/http_time.cpp", 101 "cache/lru_cache/src/disk_handler.cpp", 102 "cache/lru_cache/src/lru_cache.cpp", 103 "cache/lru_cache/src/lru_cache_disk_handler.cpp", 104 "constant/src/constant.cpp", 105 "http_exec/src/http_exec.cpp", 106 "http_exec/src/http_tls_config.cpp", 107 "http_module/src/http_module.cpp", 108 "options/src/http_request_options.cpp", 109 "options/src/http_response.cpp", 110 ] 111 112 configs = [ ":http_config" ] 113 114 if (is_mingw || is_mac) { 115 sources += [ 116 "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp", 117 "$NETSTACK_DIR/utils/common_utils/src/request_tracer.cpp", 118 ] 119 deps = [ 120 "$ARKUI_ROOT/napi:ace_napi", 121 "$NETSTACK_DIR/utils/napi_utils:napi_utils_static", 122 ] 123 external_deps = [ 124 "bounds_checking_function:libsec_shared", 125 "cJSON:cjson", 126 "curl:curl_shared", 127 "jsoncpp:jsoncpp_static", 128 ] 129 ldflags = [ "-lpthread" ] 130 } else { 131 deps = [ 132 "$NETSTACK_DIR/utils:stack_utils_common", 133 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 134 ] 135 external_deps = [ 136 "ability_runtime:wantagent_innerkits", 137 "cJSON:cjson", 138 "curl:curl_shared_http3", 139 "hilog:libhilog", 140 "hiprofiler:libnetwork_profiler", 141 "hitrace:hitrace_meter", 142 "napi:ace_napi", 143 "samgr:samgr_proxy", 144 "time_service:time_client", 145 ] 146 if (netstack_http_boringssl) { 147 external_deps += [ 148 "netmanager_enhanced:crypto_boringssl", 149 "netmanager_enhanced:ssl_boringssl", 150 ] 151 } else { 152 external_deps += [ 153 "openssl:libcrypto_shared", 154 "openssl:libssl_shared", 155 ] 156 } 157 if (defined(global_parts_info) && 158 defined(global_parts_info.communication_netmanager_base) && 159 global_parts_info.communication_netmanager_base) { 160 external_deps += [ "netmanager_base:net_conn_manager_if" ] 161 external_deps += [ "netmanager_base:netsys_client" ] 162 defines = [ "HAS_NETMANAGER_BASE=1" ] 163 sources += [ 164 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 165 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 166 ] 167 } else { 168 defines = [ "HAS_NETMANAGER_BASE=0" ] 169 } 170 if (product_name != "ohos-sdk") { 171 external_deps += [ "init:libbegetutil" ] 172 } 173 } 174 include_dirs += [ 175 "$NETSTACK_DIR/utils/profiler_utils/include", 176 "$NETSTACK_DIR/utils/tlv_utils/include", 177 ] 178 cflags = [ 179 "-fstack-protector-strong", 180 "-D_FORTIFY_SOURCE=2", 181 "-O2", 182 ] 183 184 relative_install_dir = "module/net" 185 part_name = "netstack" 186 subsystem_name = "communication" 187} 188