• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_utils.cpp",
29  "$TLS_NAPI/src/tls_socket.cpp",
30  "$TLS_NAPI/src/tls_socket_server.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
53PROXY_NAPI = "$NETSTACK_DIR/frameworks/js/napi/proxy"
54proxy_sources = [
55  "$PROXY_NAPI/src/socks5_instance.cpp",
56  "$PROXY_NAPI/src/socks5_none_method.cpp",
57  "$PROXY_NAPI/src/socks5_package.cpp",
58  "$PROXY_NAPI/src/socks5_passwd_method.cpp",
59  "$PROXY_NAPI/src/socks5_utils.cpp",
60]
61
62ohos_shared_library("socket") {
63  sanitize = {
64    cfi = true
65    cfi_cross_dso = true
66    debug = false
67  }
68
69  branch_protector_ret = "pac_ret"
70
71  include_dirs = [
72    "$TLS/include",
73    "$TLS_NAPI/include",
74    "$TLS_NAPI/include/context",
75    "$PROXY_NAPI/include",
76    "$NETSTACK_INNERKITS_DIR/tls_socket/include",
77    "$NETSTACK_DIR/utils/napi_utils/include",
78    "async_context/include",
79    "async_work/include",
80    "constant/include",
81    "socket_exec/include",
82    "socket_module/include",
83    "options/include",
84    "task_queue/include",
85  ]
86
87  sources = [
88    "async_context/src/bind_context.cpp",
89    "async_context/src/common_context.cpp",
90    "async_context/src/connect_context.cpp",
91    "async_context/src/local_socket_context.cpp",
92    "async_context/src/local_socket_server_context.cpp",
93    "async_context/src/multicast_get_loopback_context.cpp",
94    "async_context/src/multicast_get_ttl_context.cpp",
95    "async_context/src/multicast_membership_context.cpp",
96    "async_context/src/multicast_set_loopback_context.cpp",
97    "async_context/src/multicast_set_ttl_context.cpp",
98    "async_context/src/tcp_extra_context.cpp",
99    "async_context/src/tcp_send_context.cpp",
100    "async_context/src/tcp_server_common_context.cpp",
101    "async_context/src/tcp_server_extra_context.cpp",
102    "async_context/src/tcp_server_listen_context.cpp",
103    "async_context/src/tcp_server_send_context.cpp",
104    "async_context/src/udp_extra_context.cpp",
105    "async_context/src/udp_send_context.cpp",
106    "async_work/src/socket_async_work.cpp",
107    "options/src/extra_options_base.cpp",
108    "options/src/local_socket_options.cpp",
109    "options/src/net_address.cpp",
110    "options/src/proxy_options.cpp",
111    "options/src/socket_remote_info.cpp",
112    "options/src/socket_state_base.cpp",
113    "options/src/tcp_connect_options.cpp",
114    "options/src/tcp_extra_options.cpp",
115    "options/src/tcp_send_options.cpp",
116    "options/src/udp_extra_options.cpp",
117    "options/src/udp_send_options.cpp",
118    "socket_exec/src/local_socket_exec.cpp",
119    "socket_exec/src/socket_exec.cpp",
120    "socket_exec/src/socket_extra_exec.cpp",
121    "socket_module/src/socket_module.cpp",
122  ]
123  sources += tls_sources
124  sources += tls_napi_sources
125  sources += proxy_sources
126
127  cflags = [
128    "-fstack-protector-strong",
129    "-D_FORTIFY_SOURCE=2",
130    "-O2",
131  ]
132
133  cflags_cc = [
134    "-fstack-protector-strong",
135    "-D_FORTIFY_SOURCE=2",
136    "-O2",
137  ]
138
139  deps = [ "$NETSTACK_DIR/utils/napi_utils:napi_utils" ]
140
141  external_deps = [
142    "hilog:libhilog",
143    "napi:ace_napi",
144    "openssl:libcrypto_shared",
145    "openssl:libssl_shared",
146  ]
147  defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
148  if (defined(global_parts_info) &&
149      defined(global_parts_info.communication_netmanager_base) &&
150      global_parts_info.communication_netmanager_base) {
151    external_deps += [ "netmanager_base:net_conn_manager_if" ]
152    defines += [ "HAS_NETMANAGER_BASE=1" ]
153  } else {
154    defines += [ "HAS_NETMANAGER_BASE=0" ]
155  }
156
157  relative_install_dir = "module/net"
158  part_name = "netstack"
159  subsystem_name = "communication"
160}
161