blob: b10311adc0a3dff466827fafc17eb75d44d7165f [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/rust/rustc_artifact.gni")
# Defines a Rust library
#
# Parameters
#
# name
# Name of the crate as defined in its manifest file. If not specified, it is
# assumed to be the same as the target name.
#
# version
# Semver version of the crate as seen on crates.io.
#
# edition
# Edition of the Rust language to be used.
# Options are "2015" and "2018". If unsure, choose "2018".
#
# deps (optional)
# List of rust_library GN targets on which this crate depends.
# Third party crates can be included through paths like
# "//third_party/rust-crates/rustc_deps:<cratename>",
#
# non_rust_deps (optional)
# List of non-rust_library GN targets on which this crate depends.
#
# with_unit_tests (optional)
# Builds unit tests associated with the binary. This will create a
# `<name>_lib_test` test file in the output directory.
#
# source_root (optional)
# Location of the crate root (e.g. `src/main.rs` or `src/lib.rs`).
# This defaults to `./src/main.rs` for binaries and `./src/lib.rs` for libraries,
# and should only be changed when absolutely necessary
# (such as in the case of generated code).
#
# Example of usage:
#
# rustc_library("foo") {
# deps = [
# "//garnet/public/rust/bar",
# "//third_party/rust-crates/rustc_deps:clap",
# "//third_party/rust-crates/rustc_deps:serde",
# "//third_party/rust-crates/rustc_deps:slab",
# ]
# with_unit_tests = true
# }
template("rustc_library") {
rustc_artifact(target_name) {
forward_variables_from(invoker,
[
"name",
"version",
"edition",
"deps",
"non_rust_deps",
"with_unit_tests",
"source_root",
"testonly",
])
type = "lib"
}
}