1# Copyright (c) 2023-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_client_config") { 18 # header file path 19 include_dirs = [ 20 "$NETSTACK_DIR/interfaces/innerkits/http_client/include", 21 "$NETSTACK_DIR/utils/profiler_utils/include", 22 "$NETSTACK_DIR/utils/tlv_utils/include", 23 "$NETSTACK_DIR/utils/netstack_chr_client/include", 24 ] 25 26 cflags = [] 27 if (is_double_framework) { 28 cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] 29 } 30 if (target_cpu == "arm") { 31 cflags += [ "-DBINDER_IPC_32BIT" ] 32 } 33 if (is_standard_system) { 34 cflags += [ "-DCONFIG_STANDARD_SYSTEM" ] 35 } 36 if (defined(build_public_version) && build_public_version) { 37 cflags += [ "-DBUILD_PUBLIC_VERSION" ] 38 } 39 40 if (is_mingw) { 41 defines = [ "WINDOWS_PLATFORM" ] 42 } else if (is_mac) { 43 defines = [ "MAC_PLATFORM" ] 44 } else { 45 defines = [] 46 } 47 48 if (product_name != "ohos-sdk") { 49 defines += [ 50 "HTTP_MULTIPATH_CERT_ENABLE", 51 "HAS_NETSTACK_CHR", 52 ] 53 include_dirs += [ 54 "$NETSTACK_DIR/frameworks/js/napi/http/async_context/include", 55 "$NETSTACK_DIR/frameworks/js/napi/http/constant/include", 56 "$NETSTACK_DIR/frameworks/js/napi/http/options/include", 57 "$NETSTACK_DIR/frameworks/js/napi/http/http_exec/include", 58 ] 59 } 60 if (defined(global_parts_info) && 61 defined(global_parts_info.communication_netmanager_base) && 62 global_parts_info.communication_netmanager_base) { 63 defines += [ 64 "HAS_NETMANAGER_BASE=1", 65 "HTTP_HANDOVER_FEATURE", 66 "HTTP_STACK_NAME=\"HTTP_CLIEND\"", 67 ] 68 } 69} 70 71ohos_shared_library("http_client") { 72 sanitize = { 73 cfi = true 74 cfi_cross_dso = true 75 debug = false 76 } 77 78 branch_protector_ret = "pac_ret" 79 80 sources = [ 81 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 82 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 83 "$NETSTACK_DIR/utils/netstack_chr_client/src/netstack_chr_client.cpp", 84 "$NETSTACK_DIR/utils/netstack_chr_client/src/netstack_chr_report.cpp", 85 "$NETSTACK_DIR/utils/profiler_utils/src/http_client_network_message.cpp", 86 "$NETSTACK_DIR/utils/profiler_utils/src/i_network_message.cpp", 87 "$NETSTACK_DIR/utils/profiler_utils/src/netstack_network_profiler.cpp", 88 "$NETSTACK_DIR/utils/tlv_utils/src/tlv_utils.cpp", 89 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client.cpp", 90 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_constant.cpp", 91 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_error.cpp", 92 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_request.cpp", 93 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_response.cpp", 94 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_task.cpp", 95 "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_time.cpp", 96 "$NETSTACK_DIR/frameworks/js/napi/http/async_context/src/request_context.cpp", 97 "$NETSTACK_DIR/frameworks/js/napi/http/options/src/http_request_options.cpp", 98 "$NETSTACK_DIR/utils/http_over_curl/src/http_handover_handler.cpp", 99 ] 100 101 include_dirs = [ 102 "$NETSTACK_DIR/utils/common_utils/include", 103 "$NETSTACK_DIR/utils/http_over_curl/include", 104 "$NETSTACK_DIR/utils/log/include", 105 "$NETSTACK_NATIVE_ROOT/http/http_client/include", 106 ] 107 108 cflags = [ 109 "-fstack-protector-strong", 110 "-D_FORTIFY_SOURCE=2", 111 "-O2", 112 ] 113 cflags_cc = [ 114 "-fstack-protector-strong", 115 "-D_FORTIFY_SOURCE=2", 116 "-O2", 117 ] 118 119 version_script = "libhttp_client.map" 120 121 public_configs = [ ":http_client_config" ] 122 123 deps = [ 124 "$NETSTACK_DIR/utils:stack_utils_common", 125 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 126 ] 127 128 public_external_deps = [ "curl:curl_shared" ] 129 130 if (is_mingw || is_mac) { 131 sources += [ 132 "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp", 133 "$NETSTACK_DIR/utils/common_utils/src/request_tracer.cpp", 134 ] 135 136 external_deps = [ 137 "netmanager_base:net_conn_manager_if", 138 "netmanager_base:net_security_config_if", 139 ] 140 } else { 141 deps += [ "$NETSTACK_DIR/utils:stack_utils_common" ] 142 external_deps = [ 143 "ability_runtime:wantagent_innerkits", 144 "hilog:libhilog", 145 "hiprofiler:libnetwork_profiler", 146 "hitrace:hitrace_meter", 147 "netmanager_base:net_conn_manager_if", 148 "netmanager_base:net_security_config_if", 149 "time_service:time_client", 150 "napi:ace_napi", 151 ] 152 if (product_name != "ohos-sdk") { 153 external_deps += [ "init:libbegetutil" ] 154 } 155 } 156 157 external_deps += [ 158 "curl:curl_shared", 159 "openssl:libcrypto_shared", 160 "openssl:libssl_shared", 161 ] 162 163 if (defined(global_parts_info) && 164 defined(global_parts_info.communication_netmanager_base) && 165 global_parts_info.communication_netmanager_base) { 166 external_deps += [ "netmanager_base:netsys_client" ] 167 } 168 innerapi_tags = [ "platformsdk" ] 169 part_name = "netstack" 170 subsystem_name = "communication" 171} 172