• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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
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  sources = [ "$NETSTACK_NATIVE_ROOT/websocket_client/websocket_client.cpp" ]
47
48  include_dirs = [
49    "$NETSTACK_DIR/utils/common_utils/include",
50    "$NETSTACK_DIR/utils/log/include",
51    "$NETSTACK_NATIVE_ROOT/websocket_client/include",
52  ]
53
54  cflags = [
55    "-fstack-protector-strong",
56    "-D_FORTIFY_SOURCE=2",
57    "-O2",
58  ]
59  cflags_cc = [
60    "-fstack-protector-strong",
61    "-D_FORTIFY_SOURCE=2",
62    "-O2",
63  ]
64
65  version_script = "libwebsocket_client.map"
66
67  public_configs = [ ":websocket_client_config" ]
68
69  defines = [ "OHOS_LIBWEBSOCKETS=1" ]
70
71  deps = [
72    "$THIRD_PARTY_ROOT/libwebsockets:websockets",
73    "$THIRD_PARTY_ROOT/openssl:libssl_shared",
74  ]
75  deps += [
76    "$NETSTACK_DIR/utils:stack_utils_common",
77    "$NETSTACK_DIR/utils/napi_utils:napi_utils",
78  ]
79
80  if (is_mingw || is_mac) {
81    sources +=
82        [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ]
83    deps += [ "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp_static" ]
84  } else {
85    deps += [
86      "$NETSTACK_DIR/utils:stack_utils_common",
87      "$THIRD_PARTY_ROOT/jsoncpp:jsoncpp",
88    ]
89    external_deps = [ "hilog:libhilog" ]
90    if (product_name != "ohos-sdk") {
91      external_deps += [ "init:libbegetutil" ]
92    }
93  }
94
95  innerapi_tags = [ "platformsdk" ]
96  part_name = "netstack"
97  subsystem_name = "communication"
98}
99