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

if (is_standard_system) {
  HDF_FRAMEWORKS = "../../../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_framework_path/support/platform/include/i2c",
      "$hdf_framework_path/support/platform/include/spi",
      "$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/clock/clock_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",
    ]

    defines = [ "__USER__" ]

    if (is_standard_system) {
      deps = [ "../utils:libhdf_utils" ]

      external_deps = [
        "c_utils:utils",
        "hilog:libhilog",
      ]
    } 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"
  }
} else {
  group("libhdf_platform") {
  }
}