• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      "$NETSTACK_DIR/utils/http_over_curl/include",
37      "$NETSTACK_DIR/utils/netstack_chr_client/include",
38    ]
39  }
40  defines = []
41
42  if (is_mingw || is_mac) {
43    cflags = [
44      "-std=c++17",
45      "-stdlib=libc++",
46    ]
47  }
48  if (is_mingw) {
49    defines += [ "WINDOWS_PLATFORM" ]
50  } else if (is_mac) {
51    defines += [ "MAC_PLATFORM" ]
52    cflags_cc = [
53      "-fstack-protector-strong",
54      "-D_FORTIFY_SOURCE=2",
55      "-O2",
56    ]
57  } else if (product_name != "ohos-sdk") {
58    defines += [ "HTTP_PROXY_ENABLE" ]
59    cflags_cc = [
60      "-fstack-protector-strong",
61      "-D_FORTIFY_SOURCE=2",
62      "-O2",
63    ]
64  }
65
66  if (product_name != "ohos-sdk") {
67    defines += [
68      "HTTP_MULTIPATH_CERT_ENABLE",
69      "HTTP_ONLY_VERIFY_ROOT_CA_ENABLE",
70    ]
71  }
72
73  if (netstack_http_boringssl) {
74    defines += [ "HTTP_CACHE_FILE_PATH_USE_BASE" ]
75  }
76}
77
78ohos_shared_library("http") {
79  if (product_name != "ohos-sdk") {
80    sanitize = {
81      cfi = true
82      cfi_cross_dso = true
83      debug = false
84    }
85  }
86
87  branch_protector_ret = "pac_ret"
88
89  include_dirs = []
90
91  sources = [
92    "$NETSTACK_DIR/utils/profiler_utils/src/http_network_message.cpp",
93    "$NETSTACK_DIR/utils/profiler_utils/src/i_network_message.cpp",
94    "$NETSTACK_DIR/utils/profiler_utils/src/netstack_network_profiler.cpp",
95    "$NETSTACK_DIR/utils/tlv_utils/src/tlv_utils.cpp",
96    "async_context/src/request_context.cpp",
97    "async_work/src/http_async_work.cpp",
98    "cache/base64/src/base64_utils.cpp",
99    "cache/cache_proxy/src/cache_proxy.cpp",
100    "cache/cache_strategy/src/http_cache_request.cpp",
101    "cache/cache_strategy/src/http_cache_response.cpp",
102    "cache/cache_strategy/src/http_cache_strategy.cpp",
103    "cache/cache_strategy/src/http_time.cpp",
104    "cache/lru_cache/src/disk_handler.cpp",
105    "cache/lru_cache/src/lru_cache.cpp",
106    "cache/lru_cache/src/lru_cache_disk_handler.cpp",
107    "constant/src/constant.cpp",
108    "http_exec/src/http_exec.cpp",
109    "http_exec/src/http_tls_config.cpp",
110    "http_exec/src/http_utils.cpp",
111    "http_module/src/http_module.cpp",
112    "options/src/http_request_options.cpp",
113    "options/src/http_response.cpp",
114  ]
115
116  configs = [ ":http_config" ]
117
118  if (is_mingw || is_mac) {
119    sources += [
120      "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp",
121      "$NETSTACK_DIR/utils/common_utils/src/request_tracer.cpp",
122    ]
123    deps = [
124      "$NETSTACK_DIR/utils/napi_utils:napi_utils_static",
125    ]
126    external_deps = [
127      "bounds_checking_function:libsec_shared",
128      "cJSON:cjson",
129      "curl:curl_shared",
130      "jsoncpp:jsoncpp_static",
131      "napi:ace_napi",
132    ]
133    ldflags = [ "-lpthread" ]
134  } else {
135    deps = [
136      "$NETSTACK_DIR/utils:stack_utils_common",
137      "$NETSTACK_DIR/utils/napi_utils:napi_utils",
138    ]
139    external_deps = [
140      "ability_runtime:wantagent_innerkits",
141      "cJSON:cjson",
142      "curl:curl_shared_http3",
143      "hilog:libhilog",
144      "hiprofiler:libnetwork_profiler",
145      "hitrace:hitrace_meter",
146      "napi:ace_napi",
147      "samgr:samgr_proxy",
148      "time_service:time_client",
149    ]
150
151    external_deps += [
152      "openssl:libcrypto_shared",
153      "openssl:libssl_shared",
154    ]
155
156    if (defined(global_parts_info) &&
157        defined(global_parts_info.communication_netmanager_base) &&
158        global_parts_info.communication_netmanager_base) {
159      external_deps += [
160        "netmanager_base:net_conn_manager_if",
161        "netmanager_base:netsys_client",
162        "netmanager_base:net_security_config_if",
163        "samgr:samgr_proxy",
164        "bundle_framework:appexecfwk_base",
165        "bundle_framework:appexecfwk_core",
166        "safwk:system_ability_fwk",
167      ]
168      defines = [
169        "HAS_NETMANAGER_BASE=1",
170        "HAS_NETSTACK_CHR=1",
171      ]
172      sources += [
173        "$NETSTACK_DIR/utils/netstack_chr_client/src/netstack_chr_client.cpp",
174        "$NETSTACK_DIR/utils/netstack_chr_client/src/netstack_chr_report.cpp",
175        "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp",
176        "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp",
177        "$NETSTACK_DIR/utils/http_over_curl/src/http_handover_handler.cpp",
178      ]
179      defines += [
180        "HTTP_HANDOVER_FEATURE",
181        "HTTP_STACK_NAME=\"http\"",
182      ]
183      include_dirs += [
184        "$NETSTACK_DIR/interfaces/innerkits/http_client/include",
185      ]
186    } else {
187      defines = [
188        "HAS_NETMANAGER_BASE=0",
189        "HAS_NETSTACK_CHR=0",
190      ]
191    }
192    if (product_name != "ohos-sdk") {
193      external_deps += [ "init:libbegetutil" ]
194    }
195  }
196  if (!build_ohos_sdk) {
197    external_deps += [ "hiappevent:hiappevent_innerapi" ]
198  }
199  include_dirs += [
200    "$NETSTACK_DIR/utils/profiler_utils/include",
201    "$NETSTACK_DIR/utils/tlv_utils/include",
202  ]
203  cflags = [
204    "-fstack-protector-strong",
205    "-D_FORTIFY_SOURCE=2",
206    "-O2",
207  ]
208
209  relative_install_dir = "module/net"
210  part_name = "netstack"
211  subsystem_name = "communication"
212}
213