# Copyright (c) 2022-2025 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 = "./../.."

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

if (defined(ohos_lite)) {
} else {
  ohos_executable("audio_sample_event") {
    include_dirs = [
      "$hdf_audio_path/interfaces/include",
      "$hdf_audio_path/hal/hdi_passthrough/include",
      "$hdf_audio_path/hal/hdi_binder/server/include",
    ]

    sources = [
      "$hdf_audio_path/hal/hdi_binder/server/src/hdf_audio_events.c",
      "framework_event.c",
    ]

    defines = []

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hdf_core:libhdi",
        "hilog:libhilog",
      ]
      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" ]
    }

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

  ohos_executable("idl_render") {
    include_dirs = [ "./" ]

    sources = [
      "framework_common.c",
      "idl_render.c",
    ]

    defines = [ "IDL_SAMPLE" ]
    if (drivers_peripheral_audio_feature_alsa_lib) {
      defines += [ "ALSA_LIB_MODE" ]
    }

    if (is_standard_system) {
      external_deps = [
        "drivers_interface_audio:libaudio_proxy_6.1",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hdf_core:libhdi",
        "hilog:libhilog",
      ]
      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" ]
    }

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

  ohos_executable("idl_capture") {
    include_dirs = [ "./" ]

    sources = [
      "framework_common.c",
      "idl_capture.c",
    ]

    defines = [ "IDL_SAMPLE" ]
    if (drivers_peripheral_audio_feature_alsa_lib) {
      defines += [ "ALSA_LIB_MODE" ]
    }
    if (drivers_peripheral_audio_feature_community) {
      defines += [ "AUDIO_FEATURE_COMMUNITY" ]
    }

    if (is_standard_system) {
      external_deps = [
        "drivers_interface_audio:libaudio_proxy_6.1",
        "hdf_core:libhdf_utils",
        "hilog:libhilog",
      ]
      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" ]
    }

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

  ohos_executable("voip_test") {
    include_dirs = [ "./" ]

    sources = [
      "framework_common.c",
      "voip_test.c",
    ]

    defines = [ "IDL_SAMPLE" ]

    if (is_standard_system) {
      external_deps = [
        "drivers_interface_audio:libaudio_proxy_6.1",
        "hdf_core:libhdf_utils",
        "hilog:libhilog",
      ]
      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" ]
    }

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

  ohos_shared_library("libaudio_ipc_test") {
    include_dirs = [ "./" ]

    sources = [
      "framework_common.c",
      "audio_ipc_test.c",
    ]
    defines = [ "IDL_SAMPLE" ]
    external_deps = [
      "drivers_interface_audio:libaudio_proxy_6.1",
      "hdf_core:libhdf_utils",
      "hilog:libhilog",
    ]
    if (enable_c_utils) {
      external_deps += [ "c_utils:utils" ]
    }

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

  ohos_executable("hdf_sbuf_test") {
    include_dirs = [ "./" ]

    sources = [
      "hdf_sbuf_test.c",
    ]
    defines = [ "IDL_SAMPLE" ]

    external_deps = [
      "hdf_core:libhdf_utils",
      "hilog:libhilog",
    ]
    if (enable_c_utils) {
      external_deps += [ "c_utils:utils" ]
    }

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

group("idl_audio_sample") {
  if (!defined(ohos_lite)) {
    if (drivers_peripheral_audio_feature_hdf_proxy_stub == true) {
      deps = [
        ":libaudio_ipc_test",
        ":hdf_sbuf_test",
      ]
    }
  }
}