# Copyright (c) 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")

config("wpa_hdi_client_public_config") {
  include_dirs = [
    "include",
    "../interfaces/hdi_service/service_common",
  ]
}

if (defined(ohos_lite)) {
  ohos_shared_library("wpa_hdi_client") {
    output_extension = "z.so"
    sources = [ "src/wpa_client.c" ]

    include_dirs = [ "include" ]

    external_deps = [
      "hdf_core:libhdf_utils",
      "hilog_lite:hilog_shared"
    ]

    defines = [ "__USER__" ]

    cflags = [
      "-Wall",
      "-Wextra",
      "-Werror",
      "-fsigned-char",
      "-fno-common",
      "-fno-strict-aliasing",
      "-Wno-format",
      "-Wno-format-extra-args",
    ]

    subsystem_name = "hdf"
    part_name = "drivers_peripheral_wlan"
    install_images = [ "system" ]
  }
} else {
  ohos_shared_library("wpa_hdi_client") {
    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 = [ "include" ]
    sources = [ "src/wpa_client.c" ]
    public_configs = [ ":wpa_hdi_client_public_config" ]

    external_deps = [
      "c_utils:utils",
      "hdf_core:libhdf_utils",
      "hilog:libhilog",
    ]
    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",
    ]
    install_images = [
      chipset_base_dir,
      updater_vendor_base_dir,
    ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_wlan"
  }
}