blob: 7474286a2a8e56d6dcd927ff5f45e15e7b3c8186 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gn/rust_variables.h"
namespace variables {
// Rust target variables ------------------------------------------------------
const char kRustAliasedDeps[] = "aliased_deps";
const char kRustAliasedDeps_HelpShort[] =
"aliased_deps: [scope] Set of crate-dependency pairs.";
const char kRustAliasedDeps_Help[] =
R"(aliased_deps: [scope] Set of crate-dependency pairs.
Valid for `rust_library` targets and `executable`, `static_library`, and
`shared_library` targets that contain Rust sources.
A scope, each key indicating the renamed crate and the corresponding value
specifying the label of the dependency producing the relevant binary.
All dependencies listed in this field *must* be listed as deps of the target.
executable("foo") {
sources = [ "" ]
deps = [ "//bar" ]
This target would compile the `foo` crate with the following `extern` flag:
`rustc ...command... --extern bar=<build_out_dir>/obj/bar`
executable("foo") {
sources = [ "" ]
deps = [ ":bar" ]
aliased_deps = {
bar_renamed = ":bar"
With the addition of `aliased_deps`, above target would instead compile with:
`rustc ...command... --extern bar_renamed=<build_out_dir>/obj/bar`
const char kRustCrateName[] = "crate_name";
const char kRustCrateName_HelpShort[] =
"crate_name: [string] The name for the compiled crate.";
const char kRustCrateName_Help[] =
R"(crate_name: [string] The name for the compiled crate.
Valid for `rust_library` targets and `executable`, `static_library`,
`shared_library`, and `source_set` targets that contain Rust sources.
If crate_name is not set, then this rule will use the target name.
const char kRustCrateType[] = "crate_type";
const char kRustCrateType_HelpShort[] =
"crate_type: [string] The type of linkage to use on a shared_library.";
const char kRustCrateType_Help[] =
R"(crate_type: [string] The type of linkage to use on a shared_library.
Valid for `rust_library` targets and `executable`, `static_library`,
`shared_library`, and `source_set` targets that contain Rust sources.
Options for this field are "cdylib", "staticlib", "proc-macro", and "dylib".
This field sets the `crate-type` attribute for the `rustc` tool on static
libraries, as well as the appropriate output extension in the
`rust_output_extension` attribute. Since outputs must be explicit, the `lib`
crate type (where the Rust compiler produces what it thinks is the
appropriate library type) is not supported.
It should be noted that the "dylib" crate type in Rust is unstable in the set
of symbols it exposes, and most usages today are potentially wrong and will
be broken in the future.
Static libraries, rust libraries, and executables have this field set
const char kRustCrateRoot[] = "crate_root";
const char kRustCrateRoot_HelpShort[] =
"crate_root: [string] The root source file for a binary or library.";
const char kRustCrateRoot_Help[] =
R"(crate_root: [string] The root source file for a binary or library.
Valid for `rust_library` targets and `executable`, `static_library`,
`shared_library`, and `source_set` targets that contain Rust sources.
This file is usually the `` or `` for binaries and libraries,
If crate_root is not set, then this rule will look for a file (or for executable) or a single file in sources, if sources contains
only one file.
const char kRustflags[] = "rustflags";
const char kRustflags_HelpShort[] =
"rustflags: [string list] Flags passed to the Rust compiler.";
const char kRustflags_Help[] =
R"(rustflags: Flags passed to the Rust compiler.
A list of strings.
"rustflags" are passed to all invocations of the Rust compiler.
void InsertRustVariables(VariableInfoMap* info_map) {
VariableInfo(kRustAliasedDeps_HelpShort, kRustAliasedDeps_Help)));
VariableInfo(kRustCrateName_HelpShort, kRustCrateName_Help)));
VariableInfo(kRustCrateType_HelpShort, kRustCrateType_Help)));
VariableInfo(kRustCrateRoot_HelpShort, kRustCrateRoot_Help)));
VariableInfo(kRustflags_HelpShort, kRustflags_Help)));
} // namespace variables