Module input

Source
Expand description

Inputs to the build script, in the form of environment variables.

Functions§

cargo
Path to the cargo binary 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 to rustc (such as those defined in RUSTFLAGS).
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, RUSTFLAGS is removed from the environment; scripts should use CARGO_ENCODED_RUSTFLAGS instead.
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 bar depends on foo, then if foo generates key=value as part of its build script metadata, then the build script of bar will have the environment variables DEP_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 -j parameter to a system like make. 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 run make -j, and instead can set the MAKEFLAGS env var to the content of CARGO_MAKEFLAGS to 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
release for release builds, debug for other builds. This is determined based on if the profile inherits from the dev or release profile. Using this environment variable is not recommended. Using other environment variables like OPT_LEVEL provide 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 rustc wrapper, if any, that Cargo is using for workspace members. See build.rustc-workspace-wrapper.
rustc_wrapper
The rustc wrapper, if any, that Cargo is using. See build.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.