# Copyright (c) 2021 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")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")

HDF_FRAMEWORKS = "//drivers/hdf_core/framework"

config("libhdf_platform_pub_config") {
  visibility = [ ":*" ]

  include_dirs = [
    "$hdf_framework_path/include/core",
    "$hdf_framework_path/include/utils",
    "$hdf_framework_path/include/osal",
    "$hdf_framework_path/utils/include",
    "$hdf_framework_path/include/platform",
    "$hdf_uhdf_path/osal/include",
    "$hdf_uhdf_path/utils/include",
  ]
}

ohos_shared_library("libhdf_platform") {
  public_configs = [ ":libhdf_platform_pub_config" ]
  sources = [
    "$HDF_FRAMEWORKS/support/platform/src/adc/adc_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/fwk/platform_listener_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/gpio/gpio_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/i2c/i2c_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/pwm/pwm_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/rtc/rtc_base.c",
    "$HDF_FRAMEWORKS/support/platform/src/rtc/rtc_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/spi/spi_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/timer/timer_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/uart/uart_if_u.c",
    "$HDF_FRAMEWORKS/support/platform/src/watchdog/watchdog_if_u.c",
  ]

  include_dirs = [
    "$HDF_FRAMEWORKS/support/platform/include",
    "$HDF_FRAMEWORKS/support/platform/include/fwk",
  ]

  deps = [
    "//drivers/hdf_core/adapter/uhdf2/host:libhdf_host",
    "//drivers/hdf_core/adapter/uhdf2/ipc:libhdf_ipc_adapter",
    "//drivers/hdf_core/adapter/uhdf2/utils:libhdf_utils",
  ]

  defines = [ "__USER__" ]

  if (is_standard_system) {
    external_deps = [
      "hiviewdfx_hilog_native:libhilog",
      "utils_base:utils",
    ]
  } else {
    external_deps = [ "hilog:libhilog" ]
  }

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

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