1# Copyright (c) 2021-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 17TLS = "$NETSTACK_NATIVE_ROOT/tls_socket" 18TLS_NAPI = "$NETSTACK_DIR/frameworks/js/napi/tls" 19 20tls_sources = [ 21 "$TLS/src/secure_data.cpp", 22 "$TLS/src/socket_error.cpp", 23 "$TLS/src/tls_certificate.cpp", 24 "$TLS/src/tls_configuration.cpp", 25 "$TLS/src/tls_context.cpp", 26 "$TLS/src/tls_context_server.cpp", 27 "$TLS/src/tls_key.cpp", 28 "$TLS/src/tls_socket.cpp", 29 "$TLS/src/tls_socket_server.cpp", 30 "$TLS/src/tls_utils.cpp", 31] 32 33tls_napi_sources = [ 34 "$TLS_NAPI/src/context/tls_bind_context.cpp", 35 "$TLS_NAPI/src/context/tls_connect_context.cpp", 36 "$TLS_NAPI/src/context/tls_extra_context.cpp", 37 "$TLS_NAPI/src/context/tls_init_context.cpp", 38 "$TLS_NAPI/src/context/tls_napi_context.cpp", 39 "$TLS_NAPI/src/context/tls_send_context.cpp", 40 "$TLS_NAPI/src/context/tls_server_close_context.cpp", 41 "$TLS_NAPI/src/context/tls_server_napi_context.cpp", 42 "$TLS_NAPI/src/context/tls_server_send_context.cpp", 43 "$TLS_NAPI/src/monitor.cpp", 44 "$TLS_NAPI/src/monitor_server.cpp", 45 "$TLS_NAPI/src/tlssocket_async_work.cpp", 46 "$TLS_NAPI/src/tlssocket_exec.cpp", 47 "$TLS_NAPI/src/tlssocket_module.cpp", 48 "$TLS_NAPI/src/tlssocketserver_async_work.cpp", 49 "$TLS_NAPI/src/tlssocketserver_exec.cpp", 50 "$TLS_NAPI/src/tlssocketserver_module.cpp", 51] 52 53ohos_shared_library("socket") { 54 sanitize = { 55 cfi = true 56 cfi_cross_dso = true 57 debug = false 58 } 59 60 branch_protector_ret = "pac_ret" 61 62 include_dirs = [ 63 "$TLS/include", 64 "$TLS_NAPI/include", 65 "$TLS_NAPI/include/context", 66 "$NETSTACK_INNERKITS_DIR/tls_socket/include", 67 "$NETSTACK_DIR/utils/napi_utils/include", 68 "async_context/include", 69 "async_work/include", 70 "constant/include", 71 "socket_exec/include", 72 "socket_module/include", 73 "options/include", 74 "task_queue/include", 75 ] 76 77 sources = [ 78 "async_context/src/bind_context.cpp", 79 "async_context/src/common_context.cpp", 80 "async_context/src/connect_context.cpp", 81 "async_context/src/local_socket_context.cpp", 82 "async_context/src/local_socket_server_context.cpp", 83 "async_context/src/multicast_get_loopback_context.cpp", 84 "async_context/src/multicast_get_ttl_context.cpp", 85 "async_context/src/multicast_membership_context.cpp", 86 "async_context/src/multicast_set_loopback_context.cpp", 87 "async_context/src/multicast_set_ttl_context.cpp", 88 "async_context/src/tcp_extra_context.cpp", 89 "async_context/src/tcp_send_context.cpp", 90 "async_context/src/tcp_server_common_context.cpp", 91 "async_context/src/tcp_server_extra_context.cpp", 92 "async_context/src/tcp_server_listen_context.cpp", 93 "async_context/src/tcp_server_send_context.cpp", 94 "async_context/src/udp_extra_context.cpp", 95 "async_context/src/udp_send_context.cpp", 96 "async_work/src/socket_async_work.cpp", 97 "options/src/extra_options_base.cpp", 98 "options/src/local_socket_options.cpp", 99 "options/src/net_address.cpp", 100 "options/src/socket_remote_info.cpp", 101 "options/src/socket_state_base.cpp", 102 "options/src/tcp_connect_options.cpp", 103 "options/src/tcp_extra_options.cpp", 104 "options/src/tcp_send_options.cpp", 105 "options/src/udp_extra_options.cpp", 106 "options/src/udp_send_options.cpp", 107 "socket_exec/src/local_socket_exec.cpp", 108 "socket_exec/src/socket_exec.cpp", 109 "socket_exec/src/socket_extra_exec.cpp", 110 "socket_module/src/socket_module.cpp", 111 ] 112 sources += tls_sources 113 sources += tls_napi_sources 114 115 cflags = [ 116 "-fstack-protector-strong", 117 "-D_FORTIFY_SOURCE=2", 118 "-O2", 119 ] 120 121 cflags_cc = [ 122 "-fstack-protector-strong", 123 "-D_FORTIFY_SOURCE=2", 124 "-O2", 125 ] 126 127 deps = [ "$NETSTACK_DIR/utils/napi_utils:napi_utils" ] 128 129 external_deps = [ 130 "hilog:libhilog", 131 "napi:ace_napi", 132 "openssl:libcrypto_shared", 133 "openssl:libssl_shared", 134 ] 135 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 136 if (defined(global_parts_info) && 137 defined(global_parts_info.communication_netmanager_base) && 138 global_parts_info.communication_netmanager_base) { 139 external_deps += [ "netmanager_base:net_conn_manager_if" ] 140 defines += [ "HAS_NETMANAGER_BASE=1" ] 141 } else { 142 defines += [ "HAS_NETMANAGER_BASE=0" ] 143 } 144 145 relative_install_dir = "module/net" 146 part_name = "netstack" 147 subsystem_name = "communication" 148} 149