pub struct Build {Show 33 fields
pub(crate) config: Config,
pub(crate) version: String,
pub(crate) src: PathBuf,
pub(crate) out: PathBuf,
pub(crate) bootstrap_out: PathBuf,
pub(crate) cargo_info: GitInfo,
pub(crate) rust_analyzer_info: GitInfo,
pub(crate) clippy_info: GitInfo,
pub(crate) miri_info: GitInfo,
pub(crate) rustfmt_info: GitInfo,
pub(crate) in_tree_llvm_info: GitInfo,
pub(crate) local_rebuild: bool,
pub(crate) fail_fast: bool,
pub(crate) doc_tests: DocTests,
pub(crate) verbosity: usize,
pub(crate) build: TargetSelection,
pub(crate) hosts: Vec<TargetSelection>,
pub(crate) targets: Vec<TargetSelection>,
pub(crate) initial_rustc: PathBuf,
pub(crate) initial_cargo: PathBuf,
pub(crate) initial_lld: PathBuf,
pub(crate) initial_libdir: PathBuf,
pub(crate) initial_sysroot: PathBuf,
pub(crate) cc: RefCell<HashMap<TargetSelection, Tool>>,
pub(crate) cxx: RefCell<HashMap<TargetSelection, Tool>>,
pub(crate) ar: RefCell<HashMap<TargetSelection, PathBuf>>,
pub(crate) ranlib: RefCell<HashMap<TargetSelection, PathBuf>>,
pub(crate) crates: HashMap<Interned<String>, Crate>,
pub(crate) crate_paths: HashMap<PathBuf, Interned<String>>,
pub(crate) is_sudo: bool,
pub(crate) ci_env: CiEnv,
pub(crate) delayed_failures: RefCell<Vec<String>>,
pub(crate) prerelease_version: Cell<Option<u32>>,
}
Expand description
Global configuration for the build system.
This structure transitively contains all configuration for the build system.
All filesystem-encoded configuration is in config
, all flags are in
flags
, and then parsed or probed information is listed in the keys below.
This structure is a parameter of almost all methods in the build system, although most functions are implemented as free functions rather than methods specifically on this structure itself (to make it easier to organize).
Fields§
§config: Config
User-specified configuration from config.toml
.
version: String
§src: PathBuf
§out: PathBuf
§bootstrap_out: PathBuf
§cargo_info: GitInfo
§rust_analyzer_info: GitInfo
§clippy_info: GitInfo
§miri_info: GitInfo
§rustfmt_info: GitInfo
§in_tree_llvm_info: GitInfo
§local_rebuild: bool
§fail_fast: bool
§doc_tests: DocTests
§verbosity: usize
§build: TargetSelection
§hosts: Vec<TargetSelection>
§targets: Vec<TargetSelection>
§initial_rustc: PathBuf
§initial_cargo: PathBuf
§initial_lld: PathBuf
§initial_libdir: PathBuf
§initial_sysroot: PathBuf
§cc: RefCell<HashMap<TargetSelection, Tool>>
§cxx: RefCell<HashMap<TargetSelection, Tool>>
§ar: RefCell<HashMap<TargetSelection, PathBuf>>
§ranlib: RefCell<HashMap<TargetSelection, PathBuf>>
§crates: HashMap<Interned<String>, Crate>
§crate_paths: HashMap<PathBuf, Interned<String>>
§is_sudo: bool
§ci_env: CiEnv
§delayed_failures: RefCell<Vec<String>>
§prerelease_version: Cell<Option<u32>>
Implementations§
source§impl Build
impl Build
pub(crate) fn verbose(&self, msg: &str)
pub(crate) fn is_verbose(&self) -> bool
pub(crate) fn create(&self, path: &Path, s: &str)
pub(crate) fn remove(&self, f: &Path)
pub(crate) fn tempdir(&self) -> PathBuf
pub(crate) fn download_rustc(&self) -> bool
pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf>
source§impl Build
impl Build
sourcepub fn new(config: Config) -> Build
pub fn new(config: Config) -> Build
Creates a new set of build configuration from the flags
on the command
line and the filesystem config
.
By default all build output will be placed in the current directory.
sourcepub(crate) fn update_submodule(&self, relative_path: &Path)
pub(crate) fn update_submodule(&self, relative_path: &Path)
Given a path to the directory of a submodule, update it.
relative_path
should be relative to the root of the git repository, not an absolute path.
sourcepub fn update_existing_submodules(&self)
pub fn update_existing_submodules(&self)
If any submodule has been initialized already, sync it unconditionally. This avoids contributors checking in a submodule change by accident.
sourcepub fn build(&mut self)
pub fn build(&mut self)
Executes the entire build, as configured by the flags and configuration.
sourcepub(crate) fn clear_if_dirty(&self, dir: &Path, input: &Path) -> bool
pub(crate) fn clear_if_dirty(&self, dir: &Path, input: &Path) -> bool
Clear out dir
if input
is newer.
After this executes, it will also ensure that dir
exists.
pub(crate) fn rust_info(&self) -> &GitInfo
sourcepub(crate) fn std_features(&self, target: TargetSelection) -> String
pub(crate) fn std_features(&self, target: TargetSelection) -> String
Gets the space-separated set of activated features for the standard library.
sourcepub(crate) fn rustc_features(&self, kind: Kind) -> String
pub(crate) fn rustc_features(&self, kind: Kind) -> String
Gets the space-separated set of activated features for the compiler.
sourcepub(crate) fn cargo_dir(&self) -> &'static str
pub(crate) fn cargo_dir(&self) -> &'static str
Component directory that Cargo will produce output into (e.g. release/debug)
pub(crate) fn tools_dir(&self, compiler: Compiler) -> PathBuf
sourcepub(crate) fn stage_out(&self, compiler: Compiler, mode: Mode) -> PathBuf
pub(crate) fn stage_out(&self, compiler: Compiler, mode: Mode) -> PathBuf
Returns the root directory for all output generated in a particular stage when running with a particular host compiler.
The mode indicates what the root directory is for.
sourcepub(crate) fn cargo_out(
&self,
compiler: Compiler,
mode: Mode,
target: TargetSelection
) -> PathBuf
pub(crate) fn cargo_out( &self, compiler: Compiler, mode: Mode, target: TargetSelection ) -> PathBuf
Returns the root output directory for all Cargo output in a given stage, running a particular compiler, whether or not we’re building the standard library, and targeting the specified architecture.
sourcepub(crate) fn llvm_out(&self, target: TargetSelection) -> PathBuf
pub(crate) fn llvm_out(&self, target: TargetSelection) -> PathBuf
Root output directory for LLVM compiled for target
Note that if LLVM is configured externally then the directory returned will likely be empty.
pub(crate) fn lld_out(&self, target: TargetSelection) -> PathBuf
sourcepub(crate) fn doc_out(&self, target: TargetSelection) -> PathBuf
pub(crate) fn doc_out(&self, target: TargetSelection) -> PathBuf
Output directory for all documentation for a target
sourcepub(crate) fn json_doc_out(&self, target: TargetSelection) -> PathBuf
pub(crate) fn json_doc_out(&self, target: TargetSelection) -> PathBuf
Output directory for all JSON-formatted documentation for a target
pub(crate) fn test_out(&self, target: TargetSelection) -> PathBuf
sourcepub(crate) fn compiler_doc_out(&self, target: TargetSelection) -> PathBuf
pub(crate) fn compiler_doc_out(&self, target: TargetSelection) -> PathBuf
Output directory for all documentation for a target
sourcepub(crate) fn md_doc_out(&self, target: TargetSelection) -> Interned<PathBuf>
pub(crate) fn md_doc_out(&self, target: TargetSelection) -> Interned<PathBuf>
Output directory for some generated md crate documentation for a target (temporary)
sourcepub(crate) fn is_rust_llvm(&self, target: TargetSelection) -> bool
pub(crate) fn is_rust_llvm(&self, target: TargetSelection) -> bool
Returns true
if no custom llvm-config
is set for the specified target.
If no custom llvm-config
was specified then Rust’s llvm will be used.
sourcepub(crate) fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf
pub(crate) fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf
Returns the path to FileCheck
binary for the specified target
sourcepub(crate) fn native_dir(&self, target: TargetSelection) -> PathBuf
pub(crate) fn native_dir(&self, target: TargetSelection) -> PathBuf
Directory for libraries built from C/C++ code and shared between stages.
sourcepub(crate) fn test_helpers_out(&self, target: TargetSelection) -> PathBuf
pub(crate) fn test_helpers_out(&self, target: TargetSelection) -> PathBuf
Root output directory for rust_test_helpers library compiled for
target
sourcepub(crate) fn add_rust_test_threads(&self, cmd: &mut Command)
pub(crate) fn add_rust_test_threads(&self, cmd: &mut Command)
Adds the RUST_TEST_THREADS
env var if necessary
sourcepub(crate) fn rustc_snapshot_libdir(&self) -> PathBuf
pub(crate) fn rustc_snapshot_libdir(&self) -> PathBuf
Returns the libdir of the snapshot compiler.
sourcepub(crate) fn rustc_snapshot_sysroot(&self) -> &Path
pub(crate) fn rustc_snapshot_sysroot(&self) -> &Path
Returns the sysroot of the snapshot compiler.
sourcepub(crate) fn run(&self, cmd: &mut Command)
pub(crate) fn run(&self, cmd: &mut Command)
Runs a command, printing out nice contextual information if it fails.
sourcepub(crate) fn run_quiet(&self, cmd: &mut Command)
pub(crate) fn run_quiet(&self, cmd: &mut Command)
Runs a command, printing out nice contextual information if it fails.
sourcepub(crate) fn run_quiet_delaying_failure(&self, cmd: &mut Command) -> bool
pub(crate) fn run_quiet_delaying_failure(&self, cmd: &mut Command) -> bool
Runs a command, printing out nice contextual information if it fails.
Exits if the command failed to execute at all, otherwise returns its
status.success()
.
sourcepub(crate) fn run_delaying_failure(&self, cmd: &mut Command) -> bool
pub(crate) fn run_delaying_failure(&self, cmd: &mut Command) -> bool
Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
pub fn is_verbose_than(&self, level: usize) -> bool
sourcepub(crate) fn verbose_than(&self, level: usize, msg: &str)
pub(crate) fn verbose_than(&self, level: usize, msg: &str)
Prints a message if this build is configured in more verbose mode than level
.
pub(crate) fn info(&self, msg: &str)
pub(crate) fn msg_check( &self, what: impl Display, target: impl Into<Option<TargetSelection>> ) -> Option<Group>
pub(crate) fn msg_doc( &self, compiler: Compiler, what: impl Display, target: impl Into<Option<TargetSelection>> + Copy ) -> Option<Group>
pub(crate) fn msg_build( &self, compiler: Compiler, what: impl Display, target: impl Into<Option<TargetSelection>> ) -> Option<Group>
sourcepub(crate) fn msg(
&self,
action: impl Into<Kind>,
stage: u32,
what: impl Display,
host: impl Into<Option<TargetSelection>>,
target: impl Into<Option<TargetSelection>>
) -> Option<Group>
pub(crate) fn msg( &self, action: impl Into<Kind>, stage: u32, what: impl Display, host: impl Into<Option<TargetSelection>>, target: impl Into<Option<TargetSelection>> ) -> Option<Group>
Return a Group
guard for a Step
that is built for each --stage
.
sourcepub(crate) fn msg_unstaged(
&self,
action: impl Into<Kind>,
what: impl Display,
target: TargetSelection
) -> Option<Group>
pub(crate) fn msg_unstaged( &self, action: impl Into<Kind>, what: impl Display, target: TargetSelection ) -> Option<Group>
Return a Group
guard for a Step
that is only built once and isn’t affected by --stage
.
pub(crate) fn msg_sysroot_tool( &self, action: impl Into<Kind>, stage: u32, what: impl Display, host: TargetSelection, target: TargetSelection ) -> Option<Group>
pub(crate) fn group(&self, msg: &str) -> Option<Group>
sourcepub(crate) fn jobs(&self) -> u32
pub(crate) fn jobs(&self) -> u32
Returns the number of parallel jobs that have been configured for this build.
pub(crate) fn debuginfo_map_to(&self, which: GitRepo) -> Option<String>
sourcepub(crate) fn cc(&self, target: TargetSelection) -> PathBuf
pub(crate) fn cc(&self, target: TargetSelection) -> PathBuf
Returns the path to the C compiler for the target specified.
sourcepub(crate) fn cflags(
&self,
target: TargetSelection,
which: GitRepo,
c: CLang
) -> Vec<String>
pub(crate) fn cflags( &self, target: TargetSelection, which: GitRepo, c: CLang ) -> Vec<String>
Returns a list of flags to pass to the C compiler for the target specified.
sourcepub(crate) fn ar(&self, target: TargetSelection) -> Option<PathBuf>
pub(crate) fn ar(&self, target: TargetSelection) -> Option<PathBuf>
Returns the path to the ar
archive utility for the target specified.
sourcepub(crate) fn ranlib(&self, target: TargetSelection) -> Option<PathBuf>
pub(crate) fn ranlib(&self, target: TargetSelection) -> Option<PathBuf>
Returns the path to the ranlib
utility for the target specified.
sourcepub(crate) fn cxx(&self, target: TargetSelection) -> Result<PathBuf, String>
pub(crate) fn cxx(&self, target: TargetSelection) -> Result<PathBuf, String>
Returns the path to the C++ compiler for the target specified.
sourcepub(crate) fn linker(&self, target: TargetSelection) -> Option<PathBuf>
pub(crate) fn linker(&self, target: TargetSelection) -> Option<PathBuf>
Returns the path to the linker for the given target if it needs to be overridden.
pub(crate) fn is_fuse_ld_lld(&self, target: TargetSelection) -> bool
pub(crate) fn lld_flags( &self, target: TargetSelection ) -> impl Iterator<Item = String>
sourcepub(crate) fn crt_static(&self, target: TargetSelection) -> Option<bool>
pub(crate) fn crt_static(&self, target: TargetSelection) -> Option<bool>
Returns if this target should statically link the C runtime, if specified
sourcepub(crate) fn musl_root(&self, target: TargetSelection) -> Option<&Path>
pub(crate) fn musl_root(&self, target: TargetSelection) -> Option<&Path>
Returns the “musl root” for this target
, if defined
sourcepub(crate) fn musl_libdir(&self, target: TargetSelection) -> Option<PathBuf>
pub(crate) fn musl_libdir(&self, target: TargetSelection) -> Option<PathBuf>
Returns the “musl libdir” for this target
.
sourcepub(crate) fn wasi_root(&self, target: TargetSelection) -> Option<&Path>
pub(crate) fn wasi_root(&self, target: TargetSelection) -> Option<&Path>
Returns the sysroot for the wasi target, if defined
sourcepub(crate) fn no_std(&self, target: TargetSelection) -> Option<bool>
pub(crate) fn no_std(&self, target: TargetSelection) -> Option<bool>
Returns true
if this is a no-std target
, if defined
sourcepub(crate) fn remote_tested(&self, target: TargetSelection) -> bool
pub(crate) fn remote_tested(&self, target: TargetSelection) -> bool
Returns true
if the target will be tested using the remote-test-client
and remote-test-server
binaries.
sourcepub(crate) fn qemu_rootfs(&self, target: TargetSelection) -> Option<&Path>
pub(crate) fn qemu_rootfs(&self, target: TargetSelection) -> Option<&Path>
Returns the root of the “rootfs” image that this target will be using, if one was configured.
If Some
is returned then that means that tests for this target are
emulated with QEMU and binaries will need to be shipped to the emulator.
sourcepub(crate) fn extended_error_dir(&self) -> PathBuf
pub(crate) fn extended_error_dir(&self) -> PathBuf
Temporary directory that extended error information is emitted to.
sourcepub(crate) fn force_use_stage1(
&self,
stage: u32,
target: TargetSelection
) -> bool
pub(crate) fn force_use_stage1( &self, stage: u32, target: TargetSelection ) -> bool
Tests whether the compiler
compiling for target
should be forced to
use a stage1 compiler instead.
Currently, by default, the build system does not perform a “full bootstrap” by default where we compile the compiler three times. Instead, we compile the compiler two times. The final stage (stage2) just copies the libraries from the previous stage, which is what this method detects.
Here we return true
if:
- The build isn’t performing a full bootstrap
- The
compiler
is in the final stage, 2 - We’re not cross-compiling, so the artifacts are already available in stage1
When all of these conditions are met the build will lift artifacts from the previous stage forward.
sourcepub(crate) fn force_use_stage2(&self, stage: u32) -> bool
pub(crate) fn force_use_stage2(&self, stage: u32) -> bool
Checks whether the compiler
compiling for target
should be forced to
use a stage2 compiler instead.
When we download the pre-compiled version of rustc and compiler stage is >= 2, it should be forced to use a stage2 compiler.
sourcepub(crate) fn release(&self, num: &str) -> String
pub(crate) fn release(&self, num: &str) -> String
Given num
in the form “a.b.c” return a “release string” which
describes the release version number.
For example on nightly this returns “a.b.c-nightly”, on beta it returns “a.b.c-beta.1” and on stable it just returns “a.b.c”.
pub(crate) fn beta_prerelease_version(&self) -> u32
sourcepub(crate) fn rust_release(&self) -> String
pub(crate) fn rust_release(&self) -> String
Returns the value of release
above for Rust itself.
sourcepub(crate) fn package_vers(&self, num: &str) -> String
pub(crate) fn package_vers(&self, num: &str) -> String
Returns the “package version” for a component given the num
release
number.
The package version is typically what shows up in the names of tarballs.
For channels like beta/nightly it’s just the channel name, otherwise
it’s the num
provided.
sourcepub(crate) fn rust_package_vers(&self) -> String
pub(crate) fn rust_package_vers(&self) -> String
Returns the value of package_vers
above for Rust itself.
sourcepub(crate) fn rust_version(&self) -> String
pub(crate) fn rust_version(&self) -> String
Returns the version
string associated with this compiler for Rust
itself.
Note that this is a descriptive string which includes the commit date, sha, version, etc.
sourcepub(crate) fn release_num(&self, package: &str) -> String
pub(crate) fn release_num(&self, package: &str) -> String
Returns the a.b.c
version that the given package is at.
sourcepub(crate) fn unstable_features(&self) -> bool
pub(crate) fn unstable_features(&self) -> bool
Returns true
if unstable features should be enabled for the compiler
we’re building.
sourcepub(crate) fn in_tree_crates(
&self,
root: &str,
target: Option<TargetSelection>
) -> Vec<&Crate>
pub(crate) fn in_tree_crates( &self, root: &str, target: Option<TargetSelection> ) -> Vec<&Crate>
Returns a Vec of all the dependencies of the given root crate, including transitive dependencies and the root itself. Only includes “local” crates (those in the local source tree, not from a registry).
pub(crate) fn read_stamp_file( &self, stamp: &Path ) -> Vec<(PathBuf, DependencyType)>
pub(crate) fn copy_internal( &self, src: &Path, dst: &Path, dereference_symlinks: bool )
sourcepub fn cp_r(&self, src: &Path, dst: &Path)
pub fn cp_r(&self, src: &Path, dst: &Path)
Copies the src
directory recursively to dst
. Both are assumed to exist
when this function is called.
sourcepub fn cp_filtered(
&self,
src: &Path,
dst: &Path,
filter: &dyn Fn(&Path) -> bool
)
pub fn cp_filtered( &self, src: &Path, dst: &Path, filter: &dyn Fn(&Path) -> bool )
Copies the src
directory recursively to dst
. Both are assumed to exist
when this function is called. Unwanted files or directories can be skipped
by returning false
from the filter function.
pub(crate) fn recurse_( &self, src: &Path, dst: &Path, relative: &Path, filter: &dyn Fn(&Path) -> bool )
pub(crate) fn copy_to_folder(&self, src: &Path, dest_folder: &Path)
pub(crate) fn install(&self, src: &Path, dstdir: &Path, perms: u32)
pub(crate) fn read(&self, path: &Path) -> String
pub(crate) fn create_dir(&self, dir: &Path)
pub(crate) fn remove_dir(&self, dir: &Path)
pub(crate) fn read_dir(&self, dir: &Path) -> impl Iterator<Item = DirEntry>
pub(crate) fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>( &self, src: P, link: Q ) -> Result<()>
sourcepub(crate) fn ninja(&self) -> bool
pub(crate) fn ninja(&self) -> bool
Returns if config.ninja is enabled, and checks for ninja existence, exiting with a nicer error message if not.
pub fn colored_stdout<R, F: FnOnce(&mut dyn WriteColor) -> R>(&self, f: F) -> R
pub fn colored_stderr<R, F: FnOnce(&mut dyn WriteColor) -> R>(&self, f: F) -> R
pub(crate) fn colored_stream_inner<R, F, C>( &self, constructor: C, is_tty: bool, f: F ) -> Rwhere C: Fn(ColorChoice) -> StandardStream, F: FnOnce(&mut dyn WriteColor) -> R,
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Build
impl Send for Build
impl !Sync for Build
impl Unpin for Build
impl UnwindSafe for Build
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 3312 bytes