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 += [ 36 "$NETMANAGER_BASE_INNERKITS_DIR/include", 37 "$NETMANAGER_BASE_INNERKITS_DIR/netconnclient/include", 38 "$NETSTACK_DIR/utils/http_over_curl/include", 39 ] 40 } 41 defines = [] 42 43 if (is_mingw || is_mac) { 44 cflags = [ 45 "-std=c++17", 46 "-stdlib=libc++", 47 ] 48 } 49 if (is_mingw) { 50 defines += [ "WINDOWS_PLATFORM" ] 51 } else if (is_mac) { 52 defines += [ "MAC_PLATFORM" ] 53 cflags_cc = [ 54 "-fstack-protector-strong", 55 "-D_FORTIFY_SOURCE=2", 56 "-O2", 57 ] 58 } else if (product_name != "ohos-sdk") { 59 defines += [ "HTTP_PROXY_ENABLE" ] 60 cflags_cc = [ 61 "-fstack-protector-strong", 62 "-D_FORTIFY_SOURCE=2", 63 "-O2", 64 ] 65 } 66 67 if (product_name != "ohos-sdk") { 68 defines += [ 69 "HTTP_MULTIPATH_CERT_ENABLE", 70 "HTTP_ONLY_VERIFY_ROOT_CA_ENABLE", 71 ] 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_module/src/http_module.cpp", 107 "options/src/http_request_options.cpp", 108 "options/src/http_response.cpp", 109 ] 110 111 configs = [ ":http_config" ] 112 113 if (is_mingw || is_mac) { 114 sources += 115 [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ] 116 deps = [ 117 "$ARKUI_ROOT/napi:ace_napi", 118 "$NETSTACK_DIR/utils/napi_utils:napi_utils_static", 119 "$THIRD_PARTY_ROOT/bounds_checking_function:libsec_static", 120 "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp_static", 121 ] 122 external_deps = [ 123 "cJSON:cjson", 124 "curl:curl_shared", 125 ] 126 ldflags = [ "-lpthread" ] 127 } else { 128 deps = [ 129 "$NETSTACK_DIR/utils:stack_utils_common", 130 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 131 "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp", 132 ] 133 external_deps = [ 134 "ability_runtime:wantagent_innerkits", 135 "cJSON:cjson", 136 "curl:curl_shared_http3", 137 "hilog:libhilog", 138 "hiprofiler:libnetwork_profiler", 139 "hitrace:hitrace_meter", 140 "napi:ace_napi", 141 "time_service:time_client", 142 ] 143 if (netstack_http_boringssl) { 144 deps += [ 145 "//vendor/open_source/boringssl:crypto_boringssl", 146 "//vendor/open_source/boringssl:ssl_boringssl", 147 ] 148 } else { 149 external_deps += [ 150 "openssl:libcrypto_shared", 151 "openssl:libssl_shared", 152 ] 153 } 154 if (defined(global_parts_info) && 155 defined(global_parts_info.communication_netmanager_base) && 156 global_parts_info.communication_netmanager_base) { 157 external_deps += [ "netmanager_base:net_conn_manager_if" ] 158 external_deps += [ "netmanager_base:netsys_client" ] 159 defines = [ "HAS_NETMANAGER_BASE=1" ] 160 sources += [ 161 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 162 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 163 ] 164 } else { 165 defines = [ "HAS_NETMANAGER_BASE=0" ] 166 } 167 if (product_name != "ohos-sdk") { 168 external_deps += [ "init:libbegetutil" ] 169 } 170 } 171 include_dirs += [ 172 "$NETSTACK_DIR/utils/profiler_utils/include", 173 "$NETSTACK_DIR/utils/tlv_utils/include", 174 ] 175 cflags = [ 176 "-fstack-protector-strong", 177 "-D_FORTIFY_SOURCE=2", 178 "-O2", 179 ] 180 181 relative_install_dir = "module/net" 182 part_name = "netstack" 183 subsystem_name = "communication" 184} 185