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 "samgr:samgr_proxy", 86 ] 87 88 if (build_ohos_sdk) { 89 defines += [ "PREVIEWER" ] 90 sources = [ "src/net_http_mock.cpp" ] 91 } else { 92 external_deps += [ "init:libbegetutil" ] 93 } 94 95 deps = [ "$NETSTACK_DIR/utils:stack_utils_common" ] 96 97 if (defined(global_parts_info) && 98 defined(global_parts_info.communication_netmanager_base) && 99 global_parts_info.communication_netmanager_base) { 100 external_deps += [ 101 "netmanager_base:net_conn_manager_if", 102 "netmanager_base:net_security_config_if", 103 ] 104 defines = [ "HAS_NETMANAGER_BASE=1" ] 105 sources += [ 106 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_multi_driver.cpp", 107 "$NETSTACK_DIR/utils/http_over_curl/src/epoll_request_handler.cpp", 108 ] 109 } else { 110 defines = [ "HAS_NETMANAGER_BASE=0" ] 111 } 112 113 cflags = [ 114 "-fstack-protector-strong", 115 "-D_FORTIFY_SOURCE=2", 116 "-O2", 117 ] 118 119 innerapi_tags = [ "platformsdk" ] 120 part_name = "netstack" 121 subsystem_name = "communication" 122} 123