11e934351Sopenharmony_ci# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
21e934351Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
31e934351Sopenharmony_ci# you may not use this file except in compliance with the License.
41e934351Sopenharmony_ci# You may obtain a copy of the License at
51e934351Sopenharmony_ci#
61e934351Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
71e934351Sopenharmony_ci#
81e934351Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
91e934351Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
101e934351Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111e934351Sopenharmony_ci# See the License for the specific language governing permissions and
121e934351Sopenharmony_ci# limitations under the License.
131e934351Sopenharmony_ci
141e934351Sopenharmony_ciimport("//build/ohos.gni")
151e934351Sopenharmony_ciimport("//foundation/communication/netstack/netstack_config.gni")
161e934351Sopenharmony_ci
171e934351Sopenharmony_ciohos_shared_library("websocket") {
181e934351Sopenharmony_ci  sanitize = {
191e934351Sopenharmony_ci    cfi = true
201e934351Sopenharmony_ci    cfi_cross_dso = true
211e934351Sopenharmony_ci    debug = false
221e934351Sopenharmony_ci  }
231e934351Sopenharmony_ci
241e934351Sopenharmony_ci  branch_protector_ret = "pac_ret"
251e934351Sopenharmony_ci
261e934351Sopenharmony_ci  include_dirs = [
271e934351Sopenharmony_ci    "async_context/include",
281e934351Sopenharmony_ci    "async_work/include",
291e934351Sopenharmony_ci    "constant/include",
301e934351Sopenharmony_ci    "websocket_exec/include",
311e934351Sopenharmony_ci    "websocket_module/include",
321e934351Sopenharmony_ci    "$THIRD_PARTY_ROOT/libwebsockets/include",
331e934351Sopenharmony_ci  ]
341e934351Sopenharmony_ci
351e934351Sopenharmony_ci  sources = [
361e934351Sopenharmony_ci    "async_context/src/close_context.cpp",
371e934351Sopenharmony_ci    "async_context/src/connect_context.cpp",
381e934351Sopenharmony_ci    "async_context/src/send_context.cpp",
391e934351Sopenharmony_ci    "async_work/src/websocket_async_work.cpp",
401e934351Sopenharmony_ci    "constant/src/constant.cpp",
411e934351Sopenharmony_ci    "websocket_exec/src/websocket_exec.cpp",
421e934351Sopenharmony_ci    "websocket_module/src/websocket_module.cpp",
431e934351Sopenharmony_ci  ]
441e934351Sopenharmony_ci
451e934351Sopenharmony_ci  defines = [ "OHOS_LIBWEBSOCKETS=1" ]
461e934351Sopenharmony_ci
471e934351Sopenharmony_ci  cflags = [
481e934351Sopenharmony_ci    "-fstack-protector-strong",
491e934351Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
501e934351Sopenharmony_ci    "-O2",
511e934351Sopenharmony_ci  ]
521e934351Sopenharmony_ci
531e934351Sopenharmony_ci  cflags_cc = [
541e934351Sopenharmony_ci    "-fstack-protector-strong",
551e934351Sopenharmony_ci    "-D_FORTIFY_SOURCE=2",
561e934351Sopenharmony_ci    "-O2",
571e934351Sopenharmony_ci  ]
581e934351Sopenharmony_ci
591e934351Sopenharmony_ci  deps = [
601e934351Sopenharmony_ci    "$NETSTACK_DIR/utils/napi_utils:napi_utils",
611e934351Sopenharmony_ci    "$THIRD_PARTY_ROOT/libwebsockets:websockets",
621e934351Sopenharmony_ci  ]
631e934351Sopenharmony_ci
641e934351Sopenharmony_ci  external_deps = [
651e934351Sopenharmony_ci    "hilog:libhilog",
661e934351Sopenharmony_ci    "napi:ace_napi",
671e934351Sopenharmony_ci    "openssl:libssl_shared",
681e934351Sopenharmony_ci  ]
691e934351Sopenharmony_ci
701e934351Sopenharmony_ci  if (defined(global_parts_info) &&
711e934351Sopenharmony_ci      defined(global_parts_info.communication_netmanager_base) &&
721e934351Sopenharmony_ci      global_parts_info.communication_netmanager_base) {
731e934351Sopenharmony_ci    external_deps += [ "netmanager_base:net_conn_manager_if" ]
741e934351Sopenharmony_ci    defines += [ "HAS_NETMANAGER_BASE=1" ]
751e934351Sopenharmony_ci  } else {
761e934351Sopenharmony_ci    defines += [ "HAS_NETMANAGER_BASE=0" ]
771e934351Sopenharmony_ci  }
781e934351Sopenharmony_ci
791e934351Sopenharmony_ci  if (product_name != "ohos-sdk") {
801e934351Sopenharmony_ci    external_deps += [ "init:libbegetutil" ]
811e934351Sopenharmony_ci  }
821e934351Sopenharmony_ci
831e934351Sopenharmony_ci  relative_install_dir = "module/net"
841e934351Sopenharmony_ci  part_name = "netstack"
851e934351Sopenharmony_ci  subsystem_name = "communication"
861e934351Sopenharmony_ci}
87