| # Copyright 2018 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/compiled_action.gni") |
| import("//build/package.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| |
| # Generate the rust sources using the gen. |
| compiled_action("gen_qmi_protocol_source") { |
| tool = "//src/connectivity/telephony/lib/qmi-protocol:qmigen" |
| output = "$target_gen_dir/qmi-protocol.rs" |
| sources = [ |
| "protocol/common.json", |
| "protocol/ctl.json", |
| "protocol/dms.json", |
| "protocol/wda.json", |
| "protocol/wds.json", |
| "protocol/nas.json", |
| ] |
| outputs = [ |
| output, |
| ] |
| args = [ "-i" ] + rebase_path(sources) + [ "-o" ] + [ rebase_path(output) ] |
| } |
| |
| # Build the library. |
| rustc_library("qmi-protocol") { |
| edition = "2018" |
| |
| non_rust_deps = [ ":gen_qmi_protocol_source" ] |
| deps = [ |
| "//garnet/public/rust/fuchsia-zircon", |
| "//third_party/rust_crates:bytes", |
| "//third_party/rust_crates:failure", |
| ] |
| source_root = "$target_gen_dir/qmi-protocol.rs" |
| } |
| |
| group("tests") { |
| testonly = true |
| |
| deps = [ |
| ":qmigen_unittests($host_toolchain)", |
| ] |
| } |
| |
| if (host_toolchain == current_toolchain) { |
| rustc_binary("qmigen") { |
| edition = "2018" |
| deps = [ |
| "//third_party/rust_crates:failure", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_derive", |
| "//third_party/rust_crates:serde_json", |
| ] |
| } |
| |
| rustc_library("qmigen_lib") { |
| edition = "2018" |
| deps = [ |
| "//third_party/rust_crates:failure", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_derive", |
| "//third_party/rust_crates:serde_json", |
| ] |
| } |
| |
| rustc_library("qmigen_unittests") { |
| edition = "2018" |
| with_unit_tests = true |
| testonly = true |
| |
| deps = [ |
| ":qmigen", |
| ":qmigen_lib($host_toolchain)", |
| "//third_party/rust_crates:pretty_assertions", |
| ] |
| source_root = "tests/codegen_tests.rs" |
| } |
| } |