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