71 lines
2.2 KiB
Plaintext
71 lines
2.2 KiB
Plaintext
# Copyright 2021 The Chromium Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import("//build/rust/rust_target.gni")
|
|
|
|
# Defines a Rust executable.
|
|
#
|
|
# This is identical to the built-in gn intrinsic 'executable' but
|
|
# supports some additional parameters, as below:
|
|
#
|
|
# edition (optional)
|
|
# Edition of the Rust language to be used.
|
|
# Options are "2015", "2018" and "2021". Defaults to "2021".
|
|
#
|
|
# test_deps (optional)
|
|
# List of GN targets on which this crate's tests depend, in addition
|
|
# to deps.
|
|
#
|
|
# build_native_rust_unit_tests (optional)
|
|
# Builds native unit tests (under #[cfg(test)]) written inside the Rust
|
|
# crate. This will create a `<name>_unittests` executable in the output
|
|
# directory when set to true.
|
|
# Chromium code should not set this, and instead prefer to split the code
|
|
# into a library and write gtests against it. See how to do that in
|
|
# //testing/rust_gtest_interop/README.md.
|
|
#
|
|
# unit_test_target (optional)
|
|
# Overrides the default name for the unit tests target
|
|
#
|
|
# features (optional)
|
|
# A list of conditional compilation flags to enable. This can be used
|
|
# to set features for crates built in-tree which are also published to
|
|
# crates.io. Each feature in the list will be passed to rustc as
|
|
# '--cfg feature=XXX'
|
|
#
|
|
# inputs (optional)
|
|
# Additional input files needed for compilation (such as `include!`ed files)
|
|
#
|
|
# test_inputs (optional)
|
|
# Same as above but for the unit tests target
|
|
#
|
|
# Example of usage:
|
|
#
|
|
# rust_executable("foo_bar") {
|
|
# deps = [
|
|
# "//boo/public/rust/bar",
|
|
# ]
|
|
# sources = [ "src/main.rs" ]
|
|
# }
|
|
#
|
|
# This template is intended to serve the same purpose as 'rustc_library'
|
|
# in Fuchsia.
|
|
template("rust_executable") {
|
|
exclude_forwards = TESTONLY_AND_VISIBILITY + [ "configs" ]
|
|
rust_target(target_name) {
|
|
forward_variables_from(invoker, "*", exclude_forwards)
|
|
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
|
|
if (defined(invoker.configs)) {
|
|
library_configs = []
|
|
library_configs = invoker.configs
|
|
}
|
|
target_type = "executable"
|
|
assert(!defined(cxx_bindings))
|
|
}
|
|
}
|
|
|
|
set_defaults("rust_executable") {
|
|
configs = default_executable_configs
|
|
}
|