11e934351Sopenharmony_ci# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
21e934351Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
31e934351Sopenharmony_ci# you may not use this file except in compliance with the License.
41e934351Sopenharmony_ci# You may obtain a copy of the License at
51e934351Sopenharmony_ci#
61e934351Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
71e934351Sopenharmony_ci#
81e934351Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
91e934351Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
101e934351Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111e934351Sopenharmony_ci# See the License for the specific language governing permissions and
121e934351Sopenharmony_ci# limitations under the License.
131e934351Sopenharmony_ci
141e934351Sopenharmony_ciimport("//build/ohos.gni")
151e934351Sopenharmony_ciimport("//foundation/communication/netstack/netstack_config.gni")
161e934351Sopenharmony_ci
171e934351Sopenharmony_ciconfig("http_client_config") {
181e934351Sopenharmony_ci  # header file path
191e934351Sopenharmony_ci  include_dirs = [
201e934351Sopenharmony_ci    "$THIRD_PARTY_ROOT/curl/include",
211e934351Sopenharmony_ci    "$NETSTACK_DIR/interfaces/innerkits/http_client/include",
221e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/profiler_utils/include",
231e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/tlv_utils/include",
241e934351Sopenharmony_ci  ]
251e934351Sopenharmony_ci
261e934351Sopenharmony_ci  cflags = []
271e934351Sopenharmony_ci  if (is_double_framework) {
281e934351Sopenharmony_ci    cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ]
291e934351Sopenharmony_ci  }
301e934351Sopenharmony_ci  if (target_cpu == "arm") {
311e934351Sopenharmony_ci    cflags += [ "-DBINDER_IPC_32BIT" ]
321e934351Sopenharmony_ci  }
331e934351Sopenharmony_ci  if (is_standard_system) {
341e934351Sopenharmony_ci    cflags += [ "-DCONFIG_STANDARD_SYSTEM" ]
351e934351Sopenharmony_ci  }
361e934351Sopenharmony_ci  if (defined(build_public_version) && build_public_version) {
371e934351Sopenharmony_ci    cflags += [ "-DBUILD_PUBLIC_VERSION" ]
381e934351Sopenharmony_ci  }
391e934351Sopenharmony_ci
401e934351Sopenharmony_ci  if (is_mingw) {
411e934351Sopenharmony_ci    defines = [ "WINDOWS_PLATFORM" ]
421e934351Sopenharmony_ci  } else if (is_mac) {
431e934351Sopenharmony_ci    defines = [ "MAC_PLATFORM" ]
441e934351Sopenharmony_ci  } else {
451e934351Sopenharmony_ci    defines = []
461e934351Sopenharmony_ci  }
471e934351Sopenharmony_ci
481e934351Sopenharmony_ci  if (product_name != "ohos-sdk") {
491e934351Sopenharmony_ci    defines += [ "HTTP_MULTIPATH_CERT_ENABLE" ]
501e934351Sopenharmony_ci  }
511e934351Sopenharmony_ci}
521e934351Sopenharmony_ci
531e934351Sopenharmony_ciohos_shared_library("http_client") {
541e934351Sopenharmony_ci  sanitize = {
551e934351Sopenharmony_ci    cfi = true
561e934351Sopenharmony_ci    cfi_cross_dso = true
571e934351Sopenharmony_ci    debug = false
581e934351Sopenharmony_ci  }
591e934351Sopenharmony_ci
601e934351Sopenharmony_ci  branch_protector_ret = "pac_ret"
611e934351Sopenharmony_ci
621e934351Sopenharmony_ci  sources = [
631e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp",
641e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp",
651e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/profiler_utils/src/http_client_network_message.cpp",
661e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/profiler_utils/src/i_network_message.cpp",
671e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/profiler_utils/src/netstack_network_profiler.cpp",
681e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/tlv_utils/src/tlv_utils.cpp",
691e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client.cpp",
701e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_constant.cpp",
711e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_error.cpp",
721e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_request.cpp",
731e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_response.cpp",
741e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_task.cpp",
751e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/http_client_time.cpp",
761e934351Sopenharmony_ci  ]
771e934351Sopenharmony_ci
781e934351Sopenharmony_ci  include_dirs = [
791e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/common_utils/include",
801e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/http_over_curl/include",
811e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/log/include",
821e934351Sopenharmony_ci    "$NETSTACK_NATIVE_ROOT/http/http_client/include",
831e934351Sopenharmony_ci  ]
841e934351Sopenharmony_ci
851e934351Sopenharmony_ci  cflags = [
861e934351Sopenharmony_ci    "-fstack-protector-strong",
871e934351Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
881e934351Sopenharmony_ci    "-O2",
891e934351Sopenharmony_ci  ]
901e934351Sopenharmony_ci  cflags_cc = [
911e934351Sopenharmony_ci    "-fstack-protector-strong",
921e934351Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
931e934351Sopenharmony_ci    "-O2",
941e934351Sopenharmony_ci  ]
951e934351Sopenharmony_ci
961e934351Sopenharmony_ci  version_script = "libhttp_client.map"
971e934351Sopenharmony_ci
981e934351Sopenharmony_ci  public_configs = [ ":http_client_config" ]
991e934351Sopenharmony_ci
1001e934351Sopenharmony_ci  deps = [
1011e934351Sopenharmony_ci    "$NETSTACK_DIR/utils:stack_utils_common",
1021e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/napi_utils:napi_utils",
1031e934351Sopenharmony_ci  ]
1041e934351Sopenharmony_ci
1051e934351Sopenharmony_ci  if (is_mingw || is_mac) {
1061e934351Sopenharmony_ci    sources += [
1071e934351Sopenharmony_ci      "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp",
1081e934351Sopenharmony_ci      "$NETSTACK_DIR/utils/common_utils/src/request_tracer.cpp",
1091e934351Sopenharmony_ci    ]
1101e934351Sopenharmony_ci
1111e934351Sopenharmony_ci    external_deps = [ "netmanager_base:net_conn_manager_if" ]
1121e934351Sopenharmony_ci  } else {
1131e934351Sopenharmony_ci    deps += [ "$NETSTACK_DIR/utils:stack_utils_common" ]
1141e934351Sopenharmony_ci    external_deps = [
1151e934351Sopenharmony_ci      "ability_runtime:wantagent_innerkits",
1161e934351Sopenharmony_ci      "hilog:libhilog",
1171e934351Sopenharmony_ci      "hiprofiler:libnetwork_profiler",
1181e934351Sopenharmony_ci      "hitrace:hitrace_meter",
1191e934351Sopenharmony_ci      "netmanager_base:net_conn_manager_if",
1201e934351Sopenharmony_ci      "time_service:time_client",
1211e934351Sopenharmony_ci    ]
1221e934351Sopenharmony_ci    if (product_name != "ohos-sdk") {
1231e934351Sopenharmony_ci      external_deps += [ "init:libbegetutil" ]
1241e934351Sopenharmony_ci    }
1251e934351Sopenharmony_ci  }
1261e934351Sopenharmony_ci
1271e934351Sopenharmony_ci  external_deps += [
1281e934351Sopenharmony_ci    "curl:curl_shared",
1291e934351Sopenharmony_ci    "openssl:libcrypto_shared",
1301e934351Sopenharmony_ci    "openssl:libssl_shared",
1311e934351Sopenharmony_ci  ]
1321e934351Sopenharmony_ci
1331e934351Sopenharmony_ci  innerapi_tags = [ "platformsdk" ]
1341e934351Sopenharmony_ci  part_name = "netstack"
1351e934351Sopenharmony_ci  subsystem_name = "communication"
1361e934351Sopenharmony_ci}
137