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 17ohos_shared_library("websocket") { 18 sanitize = { 19 cfi = true 20 cfi_cross_dso = true 21 debug = false 22 } 23 24 branch_protector_ret = "pac_ret" 25 26 include_dirs = [ 27 "async_context/include", 28 "async_work/include", 29 "constant/include", 30 "websocket_exec/include", 31 "websocket_module/include", 32 ] 33 34 sources = [ 35 "async_context/src/close_context.cpp", 36 "async_context/src/connect_context.cpp", 37 "async_context/src/send_context.cpp", 38 "async_work/src/websocket_async_work.cpp", 39 "constant/src/constant.cpp", 40 "websocket_exec/src/websocket_exec.cpp", 41 "websocket_module/src/websocket_module.cpp", 42 ] 43 44 defines = [ "OHOS_LIBWEBSOCKETS=1" ] 45 46 cflags = [ 47 "-fstack-protector-strong", 48 "-D_FORTIFY_SOURCE=2", 49 "-O2", 50 ] 51 52 cflags_cc = [ 53 "-fstack-protector-strong", 54 "-D_FORTIFY_SOURCE=2", 55 "-O2", 56 ] 57 58 deps = [ "$NETSTACK_DIR/utils/napi_utils:napi_utils" ] 59 60 external_deps = [ 61 "hilog:libhilog", 62 "libwebsockets:websockets", 63 "napi:ace_napi", 64 "openssl:libcrypto_shared", 65 "openssl:libssl_shared", 66 "samgr:samgr_proxy", 67 ] 68 69 if (defined(global_parts_info) && 70 defined(global_parts_info.communication_netmanager_base) && 71 global_parts_info.communication_netmanager_base) { 72 external_deps += [ 73 "netmanager_base:net_conn_manager_if", 74 "netmanager_base:net_security_config_if", 75 ] 76 defines += [ "HAS_NETMANAGER_BASE=1" ] 77 } else { 78 defines += [ "HAS_NETMANAGER_BASE=0" ] 79 } 80 81 if (netstack_websocket_server_enable) { 82 defines += [ "NETSTACK_WEBSOCKETSERVER" ] 83 sources += [ 84 "async_context/src/list_all_connections_context.cpp", 85 "async_context/src/server_close_context.cpp", 86 "async_context/src/server_send_context.cpp", 87 "async_context/src/server_start_context.cpp", 88 "async_context/src/server_stop_context.cpp", 89 "websocket_exec/src/websocket_server_exec.cpp", 90 ] 91 } 92 93 if (product_name != "ohos-sdk") { 94 external_deps += [ "init:libbegetutil" ] 95 } 96 97 relative_install_dir = "module/net" 98 part_name = "netstack" 99 subsystem_name = "communication" 100} 101