| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/bind/bind.gni") |
| import("//build/components.gni") |
| import("//build/drivers.gni") |
| import("//build/test.gni") |
| |
| driver_bind_rules("usb_peripheral_bind") { |
| rules = "usb_peripheral.bind" |
| header_output = "usb_peripheral-bind.h" |
| bind_output = "usb-peripheral.bindbc" |
| tests = "tests.json" |
| deps = [ "//src/devices/bind/fuchsia.usb" ] |
| } |
| |
| fuchsia_driver("usb-peripheral-driver") { |
| output_name = "usb-peripheral" |
| configs += [ |
| "//build/config:all_source", |
| "//build/config/fuchsia:enable_zircon_asserts", |
| ] |
| sources = [ |
| "usb-function.cc", |
| "usb-peripheral.cc", |
| ] |
| deps = [ |
| ":usb_peripheral_bind", |
| "//sdk/banjo/fuchsia.hardware.usb:fuchsia.hardware.usb_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.dci:fuchsia.hardware.usb.dci_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.function:fuchsia.hardware.usb.function_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.modeswitch:fuchsia.hardware.usb.modeswitch_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.request:fuchsia.hardware.usb.request_banjo_cpp", |
| "//sdk/fidl/fuchsia.hardware.usb.peripheral:fuchsia.hardware.usb.peripheral_llcpp", |
| "//src/devices/lib/driver", |
| "//src/devices/usb/lib/usb", |
| "//src/lib/ddk", |
| "//src/lib/ddk:ddk-metadata-headers", |
| "//src/lib/ddktl", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/fidl", |
| ] |
| |
| # Set default configuration here, rather than relying on usbctl to do it. |
| defines = [ |
| "USB_DEVICE_VID=0x18D1", |
| "USB_DEVICE_PID=0xA020", |
| "USB_DEVICE_MANUFACTURER=\"Zircon\"", |
| "USB_DEVICE_PRODUCT=\"CDC-Ethernet\"", |
| "USB_DEVICE_SERIAL=\"0123456789ABCDEF\"", |
| "USB_DEVICE_FUNCTIONS=\"cdc\"", |
| ] |
| |
| # TODO(fxbug.dev/69585): This target uses raw zx::channel with LLCPP which is deprecated. |
| # Please migrate to typed channel APIs (fidl::ClientEnd<T>, fidl::ServerEnd<T>). |
| # See linked bug for details. |
| configs += [ "//build/cpp:fidl-llcpp-deprecated-raw-channels" ] |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| fuchsia_driver_component("usb-peripheral") { |
| info = "usb-peripheral-info.json" |
| component_name = "usb-peripheral" |
| deps = [ ":usb-peripheral-driver" ] |
| colocate = true |
| } |
| |
| test("usb-peripheral-unittest-bin") { |
| sources = [ |
| "usb-function.cc", |
| "usb-peripheral-test.cc", |
| "usb-peripheral.cc", |
| ] |
| output_name = "usb-peripheral-unittest" |
| deps = [ |
| ":usb_peripheral_bind", |
| "//sdk/banjo/fuchsia.hardware.platform.device:fuchsia.hardware.platform.device_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb:fuchsia.hardware.usb_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.dci:fuchsia.hardware.usb.dci_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.function:fuchsia.hardware.usb.function_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.modeswitch:fuchsia.hardware.usb.modeswitch_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.phy:fuchsia.hardware.usb.phy_banjo_cpp", |
| "//sdk/banjo/fuchsia.hardware.usb.request:fuchsia.hardware.usb.request_banjo_cpp", |
| "//sdk/fidl/fuchsia.hardware.usb.peripheral:fuchsia.hardware.usb.peripheral_llcpp", |
| "//src/devices/bus/lib/device-protocol-pdev", |
| "//src/devices/lib/amlogic", |
| "//src/devices/lib/driver", |
| "//src/devices/lib/mmio", |
| "//src/devices/testing/fake-mmio-reg", |
| "//src/devices/testing/fake_ddk", |
| "//src/devices/usb/lib/usb", |
| "//src/lib/ddk", |
| |
| # TODO(fxb/38132): Migrate to the new bind rules and delete the below |
| "//src/lib/ddk:ddk-deprecated-binding-headers", |
| "//src/lib/ddk:ddk-metadata-headers", |
| "//src/lib/ddktl", |
| "//src/lib/utf_conversion", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/hwreg", |
| "//zircon/system/ulib/pretty", |
| "//zircon/system/ulib/sync", |
| "//zircon/system/ulib/zxtest", |
| ] |
| |
| # TODO(fxbug.dev/69585): This target uses raw zx::channel with LLCPP which is deprecated. |
| # Please migrate to typed channel APIs (fidl::ClientEnd<T>, fidl::ServerEnd<T>). |
| # See linked bug for details. |
| configs += [ "//build/cpp:fidl-llcpp-deprecated-raw-channels" ] |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| fuchsia_unittest_package("usb-peripheral-unittest") { |
| deps = [ ":usb-peripheral-unittest-bin" ] |
| test_specs = { |
| environments = basic_envs |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":usb-peripheral-unittest", |
| ":usb_peripheral_bind_test", |
| ] |
| } |