| # 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/components.gni") |
| import("//build/fidl/fidl.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| |
| declare_args() { |
| # Set this to true when configuring gn args to use the modern input injection |
| # protocol `fuchsia.input.injection.InputDeviceRegistry`. If not set, input-synthesis |
| # defaults to connect to `fuchsia.ui.input.InputDeviceRegistry`. |
| use_modern_input_injection = false |
| } |
| |
| fidl("test.inputsynthesis") { |
| testonly = true |
| sources = [ "input_synthesis.test.fidl" ] |
| public_deps = [ "//sdk/fidl/fuchsia.input.report" ] |
| } |
| |
| rustc_library("input-synthesis") { |
| name = "input-synthesis" |
| with_unit_tests = true |
| version = "0.1.0" |
| edition = "2021" |
| deps = [ |
| "//sdk/fidl/fuchsia.input:fuchsia.input-rustc", |
| "//sdk/fidl/fuchsia.input.injection:fuchsia.input.injection-rustc", |
| "//sdk/fidl/fuchsia.input.report:fuchsia.input.report-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.ui.input:fuchsia.ui.input-rustc", |
| "//sdk/fidl/fuchsia.ui.input3:fuchsia.ui.input3-rustc", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/syslog/rust:syslog", |
| "//src/lib/ui/keymaps", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:async-trait", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:test-case", |
| ] |
| |
| test_deps = [ "//third_party/rust_crates:pretty_assertions" ] |
| |
| sources = [ |
| "src/legacy_backend.rs", |
| "src/lib.rs", |
| "src/modern_backend/input_device.rs", |
| "src/modern_backend/input_device_registry.rs", |
| "src/modern_backend/input_reports_reader.rs", |
| "src/modern_backend/mod.rs", |
| "src/synthesizer.rs", |
| ] |
| |
| configs += [ ":use_modern_input_injection" ] |
| } |
| |
| rustc_binary("input-synthesis-bin") { |
| output_name = "input_synthesis_bin" |
| testonly = true |
| edition = "2021" |
| deps = [ |
| ":input-synthesis", |
| ":test.inputsynthesis-rustc", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/syslog/rust:syslog", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| ] |
| |
| sources = [ "src/main.rs" ] |
| |
| configs += [ ":use_modern_input_injection" ] |
| } |
| |
| fuchsia_component("input-synthesis-component") { |
| testonly = true |
| manifest = "meta/input-synthesis.cml" |
| deps = [ ":input-synthesis-bin" ] |
| } |
| |
| config("use_modern_input_injection") { |
| if (use_modern_input_injection) { |
| rustflags = [ |
| # Injects input through `fuchsia.input.injection.InputDeviceRegistry`. |
| "--cfg=use_modern_input_injection", |
| ] |
| defines = [ "INPUT_USE_MODERN_INPUT_INJECTION" ] |
| } |
| } |
| |
| fuchsia_unittest_package("input-synthesis-tests") { |
| deps = [ ":input-synthesis_test" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":input-synthesis-tests" ] |
| } |