1# Copyright (c) 2023-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("websocket_client_config") { 18 # header file path 19 include_dirs = [ 20 "$THIRD_PARTY_ROOT/libwebsockets/include", 21 "$NETSTACK_DIR/interfaces/innerkits/websocket_client/include", 22 ] 23 24 cflags = [] 25 if (is_double_framework) { 26 cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] 27 } 28 if (target_cpu == "arm") { 29 cflags += [ "-DBINDER_IPC_32BIT" ] 30 } 31 if (is_standard_system) { 32 cflags += [ "-DCONFIG_STANDARD_SYSTEM" ] 33 } 34 if (defined(build_public_version) && build_public_version) { 35 cflags += [ "-DBUILD_PUBLIC_VERSION" ] 36 } 37 38 if (is_mingw) { 39 defines = [ "WINDOWS_PLATFORM" ] 40 } else if (is_mac) { 41 defines = [ "MAC_PLATFORM" ] 42 } 43} 44 45ohos_shared_library("websocket_client") { 46 sanitize = { 47 cfi = true 48 cfi_cross_dso = true 49 debug = false 50 } 51 52 branch_protector_ret = "pac_ret" 53 54 sources = [ "$NETSTACK_NATIVE_ROOT/websocket_client/websocket_client.cpp" ] 55 56 include_dirs = [ 57 "$NETSTACK_DIR/utils/common_utils/include", 58 "$NETSTACK_DIR/utils/log/include", 59 "$NETSTACK_NATIVE_ROOT/websocket_client/include", 60 ] 61 62 cflags = [ 63 "-fstack-protector-strong", 64 "-D_FORTIFY_SOURCE=2", 65 "-O2", 66 ] 67 cflags_cc = [ 68 "-fstack-protector-strong", 69 "-D_FORTIFY_SOURCE=2", 70 "-O2", 71 ] 72 73 version_script = "libwebsocket_client.map" 74 75 public_configs = [ ":websocket_client_config" ] 76 77 defines = [ "OHOS_LIBWEBSOCKETS=1" ] 78 79 deps = [ 80 "$NETSTACK_DIR/utils:stack_utils_common", 81 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 82 "$THIRD_PARTY_ROOT/libwebsockets:websockets", 83 ] 84 external_deps = [ "openssl:libssl_shared" ] 85 if (is_mingw || is_mac) { 86 sources += 87 [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ] 88 } else { 89 deps += [ "$NETSTACK_DIR/utils:stack_utils_common" ] 90 external_deps += [ "hilog:libhilog" ] 91 if (product_name != "ohos-sdk") { 92 external_deps += [ "init:libbegetutil" ] 93 } 94 } 95 96 innerapi_tags = [ "platformsdk" ] 97 part_name = "netstack" 98 subsystem_name = "communication" 99} 100