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

hdf_audio_path = "./../.."
hdf_hdi_service_path = "./.."
import("//build/ohos.gni")
import("$hdf_audio_path/audio.gni")

ohos_shared_library("audio_primary_impl_vendor") {
  defines = []
  if (drivers_peripheral_audio_feature_community) {
    sources = [
      "src/audio_adapter.c",
      "src/audio_adapter_info_common.c",
      "src/audio_capture.c",
      "src/audio_common.c",
      "src/audio_manager.c",
      "src/audio_render.c",
    ]

    include_dirs = [
      "include",
      "$hdf_hdi_service_path/pathselect/include",
      "$hdf_audio_path/supportlibs/adm_adapter/include",
      "$hdf_audio_path/supportlibs/interfaces/include",
      "$hdf_hdi_service_path/vendor_interface/utils",
    ]

    if (drivers_peripheral_audio_feature_hal_notsupport_pathselect) {
      defines += [ "AUDIO_HAL_NOTSUPPORT_PATHSELECT" ]
    }
  } else {
    sources = [
      "vdi_src/audio_adapter_vdi.c",
      "vdi_src/audio_capture_vdi.c",
      "vdi_src/audio_common_vdi.c",
      "vdi_src/audio_manager_vdi.c",
      "vdi_src/audio_render_vdi.c",
    ]

    if (drivers_peripheral_audio_feature_reclaim_memory) {
      defines += [ "AUDIO_RECLAIM_MEMORY_ENABLE" ]
    }

    deps = [ "$hdf_audio_path/audio_dfx:libaudio_dfx_static" ]

    include_dirs = [
      "$hdf_audio_path/interfaces/sound/v1_0",
      "$hdf_hdi_service_path/vendor_interface/utils",
    ]
  }

  if (enable_audio_hal_hdf_log) {
    defines += [ "AUDIO_HDF_LOG" ]
  }

  if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
    defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ]
  }

  if (is_standard_system) {
    external_deps = [
      "drivers_interface_audio:libaudio_proxy_6.1",
      "hdf_core:libhdf_ipc_adapter",
      "hdf_core:libhdi",
      "hdf_core:libpub_utils",
      "hilog:libhilog",
      "ipc:ipc_single",
    ]
    if (enable_c_utils) {
      external_deps += [ "c_utils:utils" ]
    }
  } else if (defined(ohos_lite)) {
    external_deps = [ "hilog_lite:hilog_shared" ]
  } else {
    external_deps = [ "hilog:libhilog" ]
  }

  external_deps += [ "bounds_checking_function:libsec_shared" ]

  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_audio"
}