• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2023 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    "$THIRD_PARTY_ROOT/curl/include",
31    "$NETSTACK_DIR/utils/common_utils/include",
32  ]
33  if (defined(global_parts_info) &&
34      defined(global_parts_info.communication_netmanager_base) &&
35      global_parts_info.communication_netmanager_base) {
36    include_dirs += [
37      "$NETMANAGER_BASE_INNERKITS_DIR/include",
38      "$NETMANAGER_BASE_INNERKITS_DIR/netconnclient/include",
39    ]
40  }
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
67ohos_shared_library("http") {
68  sources = [
69    "async_context/src/request_context.cpp",
70    "async_work/src/http_async_work.cpp",
71    "cache/base64/src/base64_utils.cpp",
72    "cache/cache_proxy/src/cache_proxy.cpp",
73    "cache/cache_strategy/src/http_cache_request.cpp",
74    "cache/cache_strategy/src/http_cache_response.cpp",
75    "cache/cache_strategy/src/http_cache_strategy.cpp",
76    "cache/cache_strategy/src/http_time.cpp",
77    "cache/lru_cache/src/disk_handler.cpp",
78    "cache/lru_cache/src/lru_cache.cpp",
79    "cache/lru_cache/src/lru_cache_disk_handler.cpp",
80    "constant/src/constant.cpp",
81    "http_exec/src/http_exec.cpp",
82    "http_module/src/http_module.cpp",
83    "options/src/http_request_options.cpp",
84    "options/src/http_response.cpp",
85  ]
86
87  configs = [ ":http_config" ]
88
89  if (is_mingw || is_mac) {
90    sources +=
91        [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ]
92    deps = [
93      "$ARKUI_ROOT/napi:ace_napi",
94      "$NETSTACK_DIR/utils/napi_utils:napi_utils_static",
95      "$THIRD_PARTY_ROOT/bounds_checking_function:libsec_static",
96      "$THIRD_PARTY_ROOT/curl:curl_shared",
97      "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp_static",
98    ]
99  } else {
100    deps = [
101      "$NETSTACK_DIR/utils:stack_utils_common",
102      "$NETSTACK_DIR/utils/napi_utils:napi_utils",
103      "$THIRD_PARTY_ROOT/curl:curl_shared_http3",
104      "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp",
105    ]
106    external_deps = [
107      "hilog:libhilog",
108      "napi:ace_napi",
109    ]
110    if (defined(global_parts_info) &&
111        defined(global_parts_info.communication_netmanager_base) &&
112        global_parts_info.communication_netmanager_base) {
113      external_deps += [ "netmanager_base:net_conn_manager_if" ]
114      defines = [ "HAS_NETMANAGER_BASE=1" ]
115    } else {
116      defines = [ "HAS_NETMANAGER_BASE=0" ]
117    }
118    if (product_name != "ohos-sdk") {
119      external_deps += [ "init:libbegetutil" ]
120    }
121  }
122  cflags = [
123    "-fstack-protector-strong",
124    "-D_FORTIFY_SOURCE=2",
125    "-O2",
126  ]
127
128  relative_install_dir = "module/net"
129  part_name = "netstack"
130  subsystem_name = "communication"
131}
132