#
# Copyright (c) 2021, Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
#    conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
#    of conditions and the following disclaimer in the documentation and/or other materials
#    provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
#    to endorse or promote products derived from this software without specific prior written
#    permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import("//drivers/hdf_core/adapter/khdf/liteos_m/hdf.gni")

module_switch = defined(LOSCFG_DRIVERS_HDF)
hdf_driver("hdf_platform_lite") {
  sources = [
    "$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_common.c",
    "$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_device.c",
    "$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_event.c",
    "$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_manager.c",
    "$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_queue.c",
    "plat_common.c",
  ]

  include_dirs = []
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_GPIO)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/gpio/gpio_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/gpio/gpio_if.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/gpio/gpio_manager.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_I2C)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/i2c/i2c_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/i2c/i2c_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_ADC)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/adc/adc_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/adc/adc_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_PWM)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/pwm/pwm_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/pwm/pwm_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_RTC)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/rtc/rtc_base.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/rtc/rtc_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/rtc/rtc_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/mipi/mipi_dsi_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/mipi/mipi_dsi_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_CSI)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/mipi/mipi_csi_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/mipi/mipi_csi_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_SPI)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/spi/spi_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/spi/spi_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_UART)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/uart/uart_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/uart/uart_if.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/uart/uart_service.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_I2S)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/i2s/i2s_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/i2s/i2s_if.c",
    ]
  }

  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_WATCHDOG)) {
    sources += [
      "$HDF_FRAMEWORKS_PATH/support/platform/src/watchdog/watchdog_core.c",
      "$HDF_FRAMEWORKS_PATH/support/platform/src/watchdog/watchdog_if.c",
    ]
  }
}

config("public") {
  include_dirs = [ "$HDF_FRAMEWORKS_PATH/support/platform/include/fwk" ]
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_GPIO)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/gpio" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_I2C)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/i2c" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_ADC)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/adc" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_PWM)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/pwm" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_RTC)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/rtc" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/mipi" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_CSI)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/mipi" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_SPI)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/spi" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_UART)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/uart" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_I2S)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/i2s" ]
  }
  if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_WATCHDOG)) {
    include_dirs += [ "$HDF_FRAMEWORKS_PATH/support/platform/include/watchdog" ]
  }
}