1# Copyright (c) 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_ffi_config") { 18 include_dirs = [ 19 "include", 20 "$NETSTACK_DIR/utils/common_utils/include", 21 ] 22 if (defined(global_parts_info) && 23 defined(global_parts_info.communication_netmanager_base) && 24 global_parts_info.communication_netmanager_base) { 25 include_dirs += [ "$NETSTACK_DIR/utils/http_over_curl/include" ] 26 } 27 defines = [] 28 29 cflags_cc = [ "-fvisibility=hidden" ] 30 31 if (!build_ohos_sdk) { 32 defines += [ 33 "HTTP_PROXY_ENABLE", 34 "HTTP_MULTIPATH_CERT_ENABLE", 35 "HTTP_ONLY_VERIFY_ROOT_CA_ENABLE", 36 ] 37 cflags_cc += [ 38 "-fstack-protector-strong", 39 "-D_FORTIFY_SOURCE=2", 40 "-O2", 41 ] 42 } 43 44 if (current_os == "ohos") { 45 defines += [ "OHOS_PLATFORM" ] 46 } 47} 48 49ohos_shared_library("cj_net_http_ffi") { 50 if (!build_ohos_sdk) { 51 sanitize = { 52 cfi = true 53 cfi_cross_dso = true 54 debug = false 55 } 56 } 57 58 branch_protector_ret = "pac_ret" 59 60 sources = [ 61 "src/lru_cache_disk_handler.cpp", 62 "src/net_http_cache_entity.cpp", 63 "src/net_http_cache_proxy.cpp", 64 "src/net_http_cache_strategy.cpp", 65 "src/net_http_client_exec.cpp", 66 "src/net_http_ffi.cpp", 67 "src/net_http_request.cpp", 68 "src/net_http_request_context.cpp", 69 "src/net_http_response.cpp", 70 "src/net_http_utils.cpp", 71 ] 72 73 configs = [ ":http_ffi_config" ] 74 75 external_deps = [ 76 "cJSON:cjson", 77 "c_utils:utils", 78 "curl:curl_shared", 79 "hilog:libhilog", 80 "hitrace:hitrace_meter", 81 "napi:cj_bind_ffi", 82 "napi:cj_bind_native", 83 "openssl:libcrypto_shared", 84 "openssl:libssl_shared", 85 ] 86 87 if (build_ohos_sdk) { 88 defines += [ "PREVIEWER" ] 89 sources = [ "src/net_http_mock.cpp" ] 90 } else { 91 external_deps += [ "init:libbegetutil" ] 92 } 93 94 deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 95 96 if (defined(global_parts_info) && 97 defined(global_parts_info.communication_netmanager_base) && 98 global_parts_info.communication_netmanager_base) { 99 external_deps += [ "netmanager_base:net_conn_manager_if" ] 100 defines = [ "HAS_NETMANAGER_BASE=1" ] 101 sources += [ 102 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 103 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 104 ] 105 } else { 106 defines = [ "HAS_NETMANAGER_BASE=0" ] 107 } 108 109 cflags = [ 110 "-fstack-protector-strong", 111 "-D_FORTIFY_SOURCE=2", 112 "-O2", 113 ] 114 115 innerapi_tags = [ "platformsdk" ] 116 part_name = "netstack" 117 subsystem_name = "communication" 118} 119