aeaee765创建于 2025年12月11日历史提交
# Copyright (C) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if (defined(ohos_lite)) {
  import("//build/lite/config/component/lite_component.gni")
  import("//foundation/communication/wifi/wifi/wifi_lite.gni")

  shared_library("wifi_utils") {
    include_dirs = [
      "$WIFI_ROOT_DIR/interfaces/inner_api",
      "$WIFI_ROOT_DIR/frameworks/native/interfaces",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper",
      "$WIFI_ROOT_DIR/utils/inc",
      "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "//third_party/bounds_checking_function/include",
    ]

    sources = [
      "src/wifi_common_util.cpp",
      "src/wifi_event_handler.cpp",
    ]

    deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ]

    external_deps = [ "bounds_checking_function:libsec_shared" ]

    configs -= [ "//build/lite/config:language_cpp" ]
    cflags_cc = [
      "-std=c++17",
      "-fno-rtti",
    ]
    ldflags = [
      "-fPIC",
      "-Wl,-E",
    ]
    defines = [ "OHOS_ARCH_LITE" ]
  }
} else {
  import("//build/ohos.gni")
  import("//foundation/communication/wifi/wifi/wifi.gni")

  ohos_shared_library("wifi_utils") {
    branch_protector_ret = "pac_ret"

    sanitize = {
      cfi = true  # Enable/disable control flow integrity detection
      boundary_sanitize = false  # Enable boundary san detection
      cfi_cross_dso = true  # Cross-SO CFI Checks
      integer_overflow = false  # Enable integer overflow detection
      ubsan = false  # Enable some Ubsan options
      cfi_vcall_icall_only = true
      debug = false
    }
    install_enable = true
    include_dirs = [
      "$WIFI_ROOT_DIR/utils/inc",
      "$WIFI_ROOT_DIR/interfaces/inner_api",
      "$WIFI_ROOT_DIR/frameworks/native/interfaces",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper",
      "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log",
    ]

    sources = [
      "src/wifi_common_util.cpp",
      "src/wifi_event_handler.cpp",
      "src/wifi_hisysevent.cpp",
      "src/wifi_library_utils.cpp",
      "src/wifi_sa_manager.cpp",
      "src/wifi_timer.cpp",
    ]

    deps = []

    external_deps = [
      "ability_base:want",
      "ability_runtime:app_manager",
      "bundle_framework:appexecfwk_base",
      "bundle_framework:appexecfwk_core",
      "c_utils:utils",
      "cJSON:cjson",
      "hilog:libhilog",
      "hisysevent:libhisysevent",
      "ipc:ipc_single",
      "openssl:libcrypto_shared",
      "openssl:libssl_shared",
      "samgr:samgr_proxy",
    ]

    defines = []

    if (wifi_ffrt_enable) {
      external_deps += [ "ffrt:libffrt" ]
      defines += [ "WIFI_FFRT_ENABLE" ]
    } else {
      external_deps += [ "eventhandler:libeventhandler" ]
    }

    if (wifi_feature_with_local_security_detect) {
      defines += [ "WIFI_LOCAL_SECURITY_DETECT_ENABLE" ]
    }

    cflags = memory_optimization_cflags
    cflags_cc = memory_optimization_cflags_cc
    ldflags = memory_optimization_ldflags

    cflags_cc += [
      "-std=c++17",
      "-fno-rtti",
    ]

    ldflags += [
      "-fPIC",
      "-Wl,-E",
    ]

    innerapi_tags = [ "platformsdk_indirect" ]
    part_name = "wifi"
    subsystem_name = "communication"
  }
}