# Copyright (c) 2021-2023 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.

import("//build/ohos.gni")

ohos_shared_library("libwlan_interface_service_1.3") {
  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
  }
  include_dirs = [
    "../interfaces/include",
    "../client/include",
    "../hal/include",
    "./service_common",
    "./service_extend",
  ]
  sources = [
    "service_common/wlan_common_cmd.c",
    "wlan_interface_service.c",
  ]

  deps = [
    "../hal:wifi_hal",
    "service_extend:libwlan_service_extend",
  ]
  external_deps = [ "drivers_interface_wlan:libwlan_stub_1.3" ]

  defines = [ "__OHOS__USER__" ]

  cflags = [
    "-Wall",
    "-Wextra",
    "-Werror",
    "-fsigned-char",
    "-fno-common",
    "-fno-strict-aliasing",
  ]
  cflags += [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
    "-fno-merge-all-constants",
  ]
  ldflags = [
    "-Wl,--exclude-libs=ALL",
    "-Wl,--gc-sections",
  ]
  if (is_standard_system) {
    external_deps += [
      "c_utils:utils",
      "hdf_core:libhdf_host",
      "hdf_core:libhdf_utils",
      "hilog:libhilog",
    ]
  } else {
    external_deps += [ "hilog:libhilog" ]
  }

  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  version_script = "libwlan_interface_service.map"
  part_name = "drivers_peripheral_wlan"
}

ohos_shared_library("libwifi_hdi_c_device") {
  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
  }
  include_dirs = [
    "../interfaces/include",
    "../client/include",
    "../hal/include",
    "./service_extend",
  ]

  sources = [ "wlan_interface_drivers.c" ]

  deps = [
    ":libwlan_interface_service_1.3",
    "service_extend:libwlan_service_extend",
  ]
  external_deps = [ "drivers_interface_wlan:libwlan_stub_1.3" ]

  cflags = [
    "-Wall",
    "-Wextra",
    "-Werror",
    "-fsigned-char",
    "-fno-common",
    "-fno-strict-aliasing",
  ]
  cflags += [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
    "-fno-merge-all-constants",
  ]
  ldflags = [
    "-Wl,--exclude-libs=ALL",
    "-Wl,--gc-sections",
  ]
  if (is_standard_system) {
    external_deps += [
      "c_utils:utils",
      "hdf_core:libhdf_host",
      "hdf_core:libhdf_ipc_adapter",
      "hdf_core:libhdf_utils",
      "hdf_core:libhdi",
      "hilog:libhilog",
    ]
  } else {
    external_deps += [ "hilog:libhilog" ]
  }

  shlib_type = "hdi"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_wlan"
}

group("hdi_wlan_service") {
  deps = [
    ":libwifi_hdi_c_device",
    ":libwlan_interface_service_1.3",
  ]
}