blob: 69fbe44935b002e2e387e99c94fea1ba9a86dd1c [file] [log] [blame]
# 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/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_test.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/nas.json",
"protocol/wda.json",
"protocol/wds.json",
]
outputs = [ output ]
args = [ "-i" ] + rebase_path(sources, root_build_dir) + [ "-o" ] +
[ rebase_path(output, root_build_dir) ]
}
# Build the library.
rustc_library("qmi-protocol") {
edition = "2018"
non_rust_deps = [ ":gen_qmi_protocol_source" ]
deps = [
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:bytes",
"//third_party/rust_crates:thiserror",
]
source_root = "$target_gen_dir/qmi-protocol.rs"
sources = [ "$target_gen_dir/qmi-protocol.rs" ]
}
group("tests") {
testonly = true
deps = [ ":qmigen_unittests($host_toolchain)" ]
}
if (host_toolchain == current_toolchain) {
rustc_binary("qmigen") {
edition = "2021"
deps = [
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:serde_json",
"//third_party/rust_crates:thiserror",
]
sources = [
"src/ast.rs",
"src/codegen.rs",
"src/main.rs",
]
}
rustc_library("qmigen_lib") {
edition = "2021"
deps = [
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:serde_json",
"//third_party/rust_crates:thiserror",
]
sources = [
"src/ast.rs",
"src/codegen.rs",
"src/lib.rs",
]
}
rustc_test("qmigen_unittests") {
edition = "2021"
deps = [
":qmigen",
":qmigen_lib($host_toolchain)",
"//third_party/rust_crates:pretty_assertions",
]
source_root = "tests/codegen_tests.rs"
sources = [
"tests/codegen_tests.rs",
"tests/macros.rs",
"tests/optional_response.test.rs",
"tests/simple_request.test.rs",
"tests/simple_response.test.rs",
"tests/string_request_decode.test.rs",
"tests/subparam_request.test.rs",
"tests/subparam_response.test.rs",
]
inputs = [
"tests/subparam_request.test.json",
"tests/subparam_response.test.json",
"tests/string_request_decode.test.json",
"tests/simple_request.test.json",
"tests/simple_response.test.json",
"tests/optional_response.test.json",
]
}
}