# 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.

if (defined(ohos_lite)) {
  import("//build/ohos.gni")

  ohos_executable("usbhost_ddk_test") {
    include_dirs = [
      "//third_party/bounds_checking_function/include",
      "./../../../../../base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
      "./include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    sources = [
      "src/usbhost_ddk_test.c",
      "src/usbhost_test.c",
    ]

    deps = [ "./../../../../../base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ]
    external_deps = [ "hdf_core:libhdf_utils" ]
    defines = [ "__LITEOS_USB_HOST_DDK_TEST__" ]

    install_enable = false
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }
} else {
  import("//build/ohos.gni")
  import("./../../../../hdf_core/adapter/uhdf2/uhdf.gni")

  ohos_executable("usbhost_ddk_test") {
    include_dirs = [
      "include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "./../../serial/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    sources = [
      "src/usbhost_ddk_test.c",
      "src/usbhost_test.c",
    ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hdf_core:libhdi",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    install_enable = false
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }

  group("usb_pnp_sample_driver") {
    deps = [ ":libusb_pnp_sample_driver" ]
  }

  ohos_shared_library("libusb_pnp_sample_driver") {
    sources = [ "src/usb_pnp_sample.c" ]

    include_dirs = [
      "./../../common/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "include",
      "./../../serial/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    deps = [ "./../../ddk:libusb_core" ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

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

  ohos_executable("usbhost_pnp_test") {
    include_dirs = [
      "include",
      "./../../serial/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    sources = [ "src/usbhost_pnp_test.c" ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hdf_core:libhdi",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    install_enable = false
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }

  ohos_executable("usbhost_sdkapi_speed_test") {
    sources = [ "src/usbhost_sdkapi_speed.c" ]

    include_dirs = [
      "./../../common/include",
      "./../../host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "include",
      "/./../../serial/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    deps = [ "./../../ddk:libusb_core" ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    install_enable = false
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }

  ohos_executable("usbhost_sdkraw_speed_test") {
    sources = [ "src/usbhost_sdkraw_speed.c" ]

    include_dirs = [
      "./../../common/include",
      "./../../ddk/host/include",
      "./../../gadget/function/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "include",
      "./../../serial/include",
      "//drivers/hdf_core/framework/model/usb/include",
    ]

    deps = [ "./../../ddk:libusb_core" ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    install_enable = false
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }

  ohos_executable("usbhost_nosdk_speed_test") {
    include_dirs = [
      "include",
      "./../../ddk/common/include",
      "./../../ddk/device/include",
      "./../../ddk/host/include",
      "./../../interfaces/ddk/common",
      "./../../interfaces/ddk/host",
      "./../../gadget/function/include",
      "./../../serial/include",
    ]

    sources = [ "src/usbhost_nosdk_speed.c" ]

    if (is_standard_system) {
      external_deps = [
        "hdf_core:libhdf_host",
        "hdf_core:libhdf_ipc_adapter",
        "hdf_core:libhdf_utils",
        "hdf_core:libhdi",
        "hilog:libhilog",
      ]
      if (usb_c_utils_enable) {
        external_deps += [ "c_utils:utils" ]
      }
    } else {
      external_deps = [ "hilog:libhilog" ]
    }
    install_enable = false
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "drivers_peripheral_usb"
  }
}