| # Copyright 2020 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/drivers.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| |
| # Common code for codegen binary and tests |
| rustc_library("codegen_lib") { |
| edition = "2021" |
| deps = [ |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:pest", |
| "//third_party/rust_crates:pest_derive", |
| "//third_party/rust_crates:thiserror", |
| ] |
| sources = [ |
| "src/codegen/common.rs", |
| "src/codegen/error.rs", |
| "src/codegen/lower.rs", |
| "src/codegen/raise.rs", |
| "src/codegen/toplevel.rs", |
| "src/codegen/types.rs", |
| "src/definition.rs", |
| "src/grammar.rs", |
| "src/lib.rs", |
| "src/parser.rs", |
| ] |
| |
| configs -= [ "//build/config/rust/lints:allow_unused_results" ] |
| } |
| |
| # Build the code generator |
| if (host_toolchain == current_toolchain) { |
| rustc_binary("codegen") { |
| output_name = "at_command_gen" |
| edition = "2021" |
| deps = [ |
| ":codegen_lib", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:argh", |
| "//third_party/rust_crates:simplelog", |
| "//third_party/rust_crates:tracing", |
| ] |
| sources = [ "src/main.rs" ] |
| |
| configs -= [ "//build/config/rust/lints:allow_unused_results" ] |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":codegen_parser_tests($host_toolchain)" ] |
| } |
| |
| rustc_test("codegen_parser_tests") { |
| edition = "2018" |
| source_root = "src/parser_tests.rs" |
| deps = [ ":codegen_lib" ] |
| sources = [ "src/parser_tests.rs" ] |
| |
| configs -= [ "//build/config/rust/lints:allow_unused_results" ] |
| } |