Expand description
Inputs to the build script, in the form of environment variables.
Functions§
- cargo
- Path to the
cargobinary performing the build. - cargo_
cfg - For each configuration option of the package being built, this will
contain the value of the configuration. Boolean configurations are present
if they are set, and not present otherwise. This includes values built-in
to the compiler (which can be seen with
rustc --print=cfg) and values set by build scripts and extra flags passed torustc(such as those defined inRUSTFLAGS). - cargo_
cfg_ pointer_ width - The CPU pointer width.
- cargo_
cfg_ target_ arch - The CPU target architecture.
- cargo_
cfg_ target_ endian - Teh CPU target endianness.
- cargo_
cfg_ target_ env - The target environment ABI.
- cargo_
cfg_ target_ family - The target family.
- cargo_
cfg_ target_ feature - List of CPU target features enabled.
- cargo_
cfg_ target_ os - The target operating system.
- cargo_
cfg_ target_ vendor - The target vendor.
- cargo_
cfg_ unix - Set on unix-like platforms.
- cargo_
cfg_ windows - Set on windows-like platforms.
- cargo_
encoded_ rustflags - Extra flags that Cargo invokes rustc with. See
build.rustflags. Note that since Rust 1.55,RUSTFLAGSis removed from the environment; scripts should useCARGO_ENCODED_RUSTFLAGSinstead. - cargo_
feature - For each activated feature of the package being built, this will be true.
- cargo_
makeflags - Contains parameters needed for Cargo’s jobserver implementation to parallelize subprocesses. Rustc or cargo invocations from build.rs can already read CARGO_MAKEFLAGS, but GNU Make requires the flags to be specified either directly as arguments, or through the MAKEFLAGS environment variable. Currently Cargo doesn’t set the MAKEFLAGS variable, but it’s free for build scripts invoking GNU Make to set it to the contents of CARGO_MAKEFLAGS.
- cargo_
manifest_ dir - The directory containing the manifest for the package being built (the package containing the build script). Also note that this is the value of the current working directory of the build script when it starts.
- cargo_
manifest_ links - The manifest links value.
- cargo_
pkg_ authors - List of authors from the manifest of your package.
- cargo_
pkg_ description - The description from the manifest of your package.
- cargo_
pkg_ homepage - The home page from the manifest of your package.
- cargo_
pkg_ license - The license from the manifest of your package.
- cargo_
pkg_ license_ file - The license file from the manifest of your package.
- cargo_
pkg_ name - The name of your package.
- cargo_
pkg_ repository - The repository from the manifest of your package.
- cargo_
pkg_ version - The full version of your package.
- cargo_
pkg_ version_ major - The major version of your package.
- cargo_
pkg_ version_ minor - The minor version of your package.
- cargo_
pkg_ version_ patch - The patch version of your package.
- cargo_
pkg_ version_ pre - The pre-release of your package.
- debug
- Value of the corresponding variable for the profile currently being built.
- dep
- Each build script can generate an arbitrary set of metadata in the form of
key-value pairs. This metadata is passed to the build scripts of
dependent packages. For example, if the package
bardepends onfoo, then iffoogenerateskey=valueas part of its build script metadata, then the build script ofbarwill have the environment variablesDEP_FOO_KEY=value. - host
- The host triple of the Rust compiler.
- num_
jobs - The parallelism specified as the top-level parallelism. This can be
useful to pass a
-jparameter to a system likemake. Note that care should be taken when interpreting this environment variable. For historical purposes this is still provided but recent versions of Cargo, for example, do not need to runmake -j, and instead can set theMAKEFLAGSenv var to the content ofCARGO_MAKEFLAGSto activate the use of Cargo’s GNU Make compatible jobserver for sub-make invocations. - opt_
level - Value of the corresponding variable for the profile currently being built.
- out_dir
- The folder in which all output should be placed. This folder is inside the build directory for the package being built, and it is unique for the package in question.
- profile
releasefor release builds,debugfor other builds. This is determined based on if the profile inherits from thedevorreleaseprofile. Using this environment variable is not recommended. Using other environment variables likeOPT_LEVELprovide a more correct view of the actual settings being used.- rustc
- The compiler that Cargo has resolved to use, passed to the build script so it might use it as well.
- rustc_
linker - The path to the linker binary that Cargo has resolved to use for the current target, if specified.
- rustc_
workspace_ wrapper - The
rustcwrapper, if any, that Cargo is using for workspace members. Seebuild.rustc-workspace-wrapper. - rustc_
wrapper - The
rustcwrapper, if any, that Cargo is using. Seebuild.rustc-wrapper. - rustdoc
- The documentation generator that Cargo has resolved to use, passed to the build script so it might use it as well.
- target
- The target triple that is being compiled for. Native code should be compiled for this triple. See the Target Triple description for more information.