| # 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/config/fuchsia/rules.gni") |
| import("//build/test.gni") |
| import("//src/sys/build/components.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":uart16550-test", |
| ":uart16550_bind_test", |
| ] |
| } |
| |
| # We need to build both a "normal" and a "testonly" version of the library, |
| # because its headers (and implementation) want to include testonly headers |
| # like hwreg/mock.h for the benefit of uart16550-test below. |
| # |
| # The config below is used to define a macro that is used by uart16550.h to |
| # conditionally include hwreg/mock.h, and define certain mocking-related |
| # types and methods. |
| config("testing.config") { |
| defines = [ "UART16550_TESTING=1" ] |
| } |
| |
| # A template to define a source_set() target for the library. The `testonly` |
| # parameter is required. |
| template("define_common_lib") { |
| source_set(target_name) { |
| visibility = [ ":*" ] |
| configs += [ |
| "//build/config:all_source", |
| "//build/unification/config:zircon-migrated", |
| "//build/config/fuchsia:enable_zircon_asserts", |
| ] |
| sources = [ "uart16550.cc" ] |
| deps = [ |
| ":uart16550_bind", |
| "//sdk/fidl/fuchsia.hardware.serial:fuchsia.hardware.serial_c", |
| ] |
| public_deps = [ |
| "//sdk/banjo/fuchsia.hardware.acpi", |
| "//sdk/banjo/fuchsia.hardware.serial", |
| "//sdk/banjo/fuchsia.hardware.serialimpl", |
| "//src/lib/ddk", |
| "//src/lib/ddktl", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/hwreg", |
| "//zircon/public/lib/zx", |
| "//zircon/system/ulib/uart", |
| ] |
| if (invoker.testonly) { |
| testonly = true |
| public_deps += [ "//zircon/public/lib/hwreg-mock" ] |
| public_configs = [ ":testing.config" ] |
| } |
| } |
| } |
| |
| # This version of the library doesn't have any mocking support, but can |
| # be used by all other targets. |
| define_common_lib("uart16550_lib") { |
| testonly = false |
| } |
| |
| # This version of the library has mocking support, but requires testonly = true. |
| define_common_lib("uart16550_lib_for_testing") { |
| testonly = true |
| } |
| |
| bind_rules("uart16550_bind") { |
| rules = "uart16550.bind" |
| output = "uart16550_bind.h" |
| tests = "bind_tests.json" |
| deps = [ "//src/devices/bind/fuchsia.acpi" ] |
| } |
| |
| driver_module("uart16550") { |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| deps = [ |
| ":uart16550_bind", |
| ":uart16550_lib", |
| "//src/devices/lib/driver", |
| ] |
| } |
| |
| test("uart16550-test-bin") { |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| output_name = "uart16550-test" |
| sources = [ "uart16550-test.cc" ] |
| deps = [ |
| ":uart16550_lib_for_testing", |
| "//src/devices/testing/fake_ddk", |
| "//zircon/public/lib/hwreg-mock", |
| "//zircon/public/lib/zx", |
| "//zircon/public/lib/zxtest", |
| ] |
| } |
| |
| fuchsia_unittest_package("uart16550-test") { |
| deps = [ ":uart16550-test-bin" ] |
| } |