1# Copyright (c) 2021-2023 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_napi_context.cpp", 38 "$TLS_NAPI/src/context/tls_send_context.cpp", 39 "$TLS_NAPI/src/context/tls_server_close_context.cpp", 40 "$TLS_NAPI/src/context/tls_server_napi_context.cpp", 41 "$TLS_NAPI/src/context/tls_server_send_context.cpp", 42 "$TLS_NAPI/src/monitor.cpp", 43 "$TLS_NAPI/src/monitor_server.cpp", 44 "$TLS_NAPI/src/tlssocket_async_work.cpp", 45 "$TLS_NAPI/src/tlssocket_exec.cpp", 46 "$TLS_NAPI/src/tlssocket_module.cpp", 47 "$TLS_NAPI/src/tlssocketserver_async_work.cpp", 48 "$TLS_NAPI/src/tlssocketserver_exec.cpp", 49 "$TLS_NAPI/src/tlssocketserver_module.cpp", 50] 51 52ohos_shared_library("socket") { 53 include_dirs = [ 54 "$TLS/include", 55 "$TLS_NAPI/include", 56 "$TLS_NAPI/include/context", 57 "$NETSTACK_INNERKITS_DIR/tls_socket/include", 58 "$NETSTACK_DIR/utils/napi_utils/include", 59 "async_context/include", 60 "async_work/include", 61 "constant/include", 62 "socket_exec/include", 63 "socket_module/include", 64 "options/include", 65 "task_queue/include", 66 ] 67 68 sources = [ 69 "async_context/src/bind_context.cpp", 70 "async_context/src/common_context.cpp", 71 "async_context/src/connect_context.cpp", 72 "async_context/src/local_socket_context.cpp", 73 "async_context/src/local_socket_server_context.cpp", 74 "async_context/src/multicast_get_loopback_context.cpp", 75 "async_context/src/multicast_get_ttl_context.cpp", 76 "async_context/src/multicast_membership_context.cpp", 77 "async_context/src/multicast_set_loopback_context.cpp", 78 "async_context/src/multicast_set_ttl_context.cpp", 79 "async_context/src/tcp_extra_context.cpp", 80 "async_context/src/tcp_send_context.cpp", 81 "async_context/src/tcp_server_common_context.cpp", 82 "async_context/src/tcp_server_extra_context.cpp", 83 "async_context/src/tcp_server_listen_context.cpp", 84 "async_context/src/tcp_server_send_context.cpp", 85 "async_context/src/udp_extra_context.cpp", 86 "async_context/src/udp_send_context.cpp", 87 "async_work/src/socket_async_work.cpp", 88 "options/src/extra_options_base.cpp", 89 "options/src/local_socket_options.cpp", 90 "options/src/net_address.cpp", 91 "options/src/socket_remote_info.cpp", 92 "options/src/socket_state_base.cpp", 93 "options/src/tcp_connect_options.cpp", 94 "options/src/tcp_extra_options.cpp", 95 "options/src/tcp_send_options.cpp", 96 "options/src/udp_extra_options.cpp", 97 "options/src/udp_send_options.cpp", 98 "socket_exec/src/local_socket_exec.cpp", 99 "socket_exec/src/socket_exec.cpp", 100 "socket_module/src/socket_module.cpp", 101 ] 102 sources += tls_sources 103 sources += tls_napi_sources 104 105 cflags = [ 106 "-fstack-protector-strong", 107 "-D_FORTIFY_SOURCE=2", 108 "-O2", 109 ] 110 111 cflags_cc = [ 112 "-fstack-protector-strong", 113 "-D_FORTIFY_SOURCE=2", 114 "-O2", 115 ] 116 117 deps = [ 118 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 119 "$THIRD_PARTY_ROOT/openssl:libcrypto_shared", 120 "$THIRD_PARTY_ROOT/openssl:libssl_shared", 121 ] 122 123 external_deps = [ 124 "hilog:libhilog", 125 "napi:ace_napi", 126 ] 127 128 relative_install_dir = "module/net" 129 part_name = "netstack" 130 subsystem_name = "communication" 131 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 132} 133