Struct bootstrap::builder::Builder

source ·
pub struct Builder<'a> {
    pub build: &'a Build,
    pub top_stage: u32,
    pub kind: Kind,
    cache: Cache,
    stack: RefCell<Vec<Box<dyn Any>>>,
    time_spent_on_dependencies: Cell<Duration>,
    pub paths: Vec<PathBuf>,
}

Fields§

§build: &'a Build§top_stage: u32§kind: Kind§cache: Cache§stack: RefCell<Vec<Box<dyn Any>>>§time_spent_on_dependencies: Cell<Duration>§paths: Vec<PathBuf>

Implementations§

source§

impl<'a> Builder<'a>

source

fn get_step_descriptions(kind: Kind) -> Vec<StepDescription>

source

pub fn get_help(build: &Build, kind: Kind) -> Option<String>

source

fn new_internal(build: &Build, kind: Kind, paths: Vec<PathBuf>) -> Builder<'_>

source

pub fn new(build: &Build) -> Builder<'_>

source

pub fn execute_cli(&self)

source

pub fn default_doc(&self, paths: &[PathBuf])

source

pub fn doc_rust_lang_org_channel(&self) -> String

source

fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf])

source

pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler

Obtain a compiler at a given stage and for a given host. Explicitly does not take Compiler since all Compiler instances are meant to be obtained through this function, since it ensures that they are valid (i.e., built and assembled).

source

pub fn compiler_for( &self, stage: u32, host: TargetSelection, target: TargetSelection ) -> Compiler

Similar to compiler, except handles the full-bootstrap option to silently use the stage1 compiler instead of a stage2 compiler if one is requested.

Note that this does not have the side effect of creating compiler(stage, host), unlike compiler above which does have such a side effect. The returned compiler here can only be used to compile new artifacts, it can’t be used to rely on the presence of a particular sysroot.

See force_use_stage1 and force_use_stage2 for documentation on what each argument is.

source

pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf>

source

pub fn sysroot_libdir( &self, compiler: Compiler, target: TargetSelection ) -> Interned<PathBuf>

Returns the libdir where the standard library and other artifacts are found for a compiler’s sysroot.

source

pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf

source

pub fn rustc_libdir(&self, compiler: Compiler) -> PathBuf

Returns the compiler’s libdir where it stores the dynamic libraries that it itself links against.

For example this returns <sysroot>/lib on Unix and <sysroot>/bin on Windows.

source

pub fn libdir_relative(&self, compiler: Compiler) -> &Path

Returns the compiler’s relative libdir where it stores the dynamic libraries that it itself links against.

For example this returns lib on Unix and bin on Windows.

source

pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path

Returns the compiler’s relative libdir where the standard library and other artifacts are found for a compiler’s sysroot.

For example this returns lib on Unix and Windows.

source

pub fn rustc_lib_paths(&self, compiler: Compiler) -> Vec<PathBuf>

source

pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command)

Adds the compiler’s directory of dynamic libraries to cmd’s dynamic library lookup path.

source

pub fn rustc(&self, compiler: Compiler) -> PathBuf

Gets a path to the compiler specified.

source

fn codegen_backends(&self, compiler: Compiler) -> impl Iterator<Item = PathBuf>

Gets the paths to all of the compiler’s codegen backends.

source

pub fn rustdoc(&self, compiler: Compiler) -> PathBuf

source

pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command

source

fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf>

Return the path to llvm-config for the target, if it exists.

Note that this returns None if LLVM is disabled, or if we’re in a check build or dry-run, where there’s no need to build all of LLVM.

source

pub fn bare_cargo( &self, compiler: Compiler, mode: Mode, target: TargetSelection, cmd: &str ) -> Command

Like cargo, but only passes flags that are valid for all commands.

source

pub fn cargo( &self, compiler: Compiler, mode: Mode, source_type: SourceType, target: TargetSelection, cmd: &str ) -> Cargo

Prepares an invocation of cargo to be run.

This will create a Command that represents a pending execution of Cargo. This cargo will be configured to use compiler as the actual rustc compiler, its output will be scoped by mode’s output directory, it will pass the --target flag for the specified target, and will be executing the Cargo command cmd.

source

pub fn ensure<S: Step>(&'a self, step: S) -> S::Output

Ensure that a given step is built, returning its output. This will cache the step, so it is safe (and good!) to call this as often as needed to ensure that all dependencies are built.

source

pub(crate) fn ensure_if_default<T, S: Step<Output = Option<T>>>( &'a self, step: S, kind: Kind ) -> S::Output

Ensure that a given step is built only if it’s supposed to be built by default, returning its output. This will cache the step, so it’s safe (and good!) to call this as often as needed to ensure that all dependencies are build.

source

pub(crate) fn was_invoked_explicitly<S: Step>(&'a self, kind: Kind) -> bool

Checks if any of the “should_run” paths is in the Builder paths.

source

pub(crate) fn maybe_open_in_browser<S: Step>(&self, path: impl AsRef<Path>)

source

pub(crate) fn open_in_browser(&self, path: impl AsRef<Path>)

source§

impl Builder<'_>

source

fn msg_tool( &self, mode: Mode, tool: &str, build_stage: u32, host: &TargetSelection, target: &TargetSelection ) -> Option<Group>

source§

impl<'a> Builder<'a>

source

pub fn tool_exe(&self, tool: Tool) -> PathBuf

source§

impl<'a> Builder<'a>

source

pub fn tool_cmd(&self, tool: Tool) -> Command

Gets a Command which is ready to run tool in stage built for host.

source§

impl Builder<'_>

source

fn toolstates(&self) -> HashMap<Box<str>, ToolState>

source

pub fn save_toolstate(&self, tool: &str, state: ToolState)

Updates the actual toolstate of a tool.

The toolstates are saved to the file specified by the key rust.save-toolstates in config.toml. If unspecified, nothing will be done. The file is updated immediately after this function completes.

Methods from Deref<Target = Build>§

source

pub(crate) fn verbose(&self, msg: &str)

source

pub(crate) fn is_verbose(&self) -> bool

source

pub(crate) fn create(&self, path: &Path, s: &str)

source

pub(crate) fn remove(&self, f: &Path)

source

pub(crate) fn tempdir(&self) -> PathBuf

source

pub(crate) fn download_rustc(&self) -> bool

source

pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf>

source

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.

source

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.

source

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.

source

pub(crate) fn rust_info(&self) -> &GitInfo

source

pub(crate) fn std_features(&self, target: TargetSelection) -> String

Gets the space-separated set of activated features for the standard library.

source

pub(crate) fn rustc_features(&self, kind: Kind) -> String

Gets the space-separated set of activated features for the compiler.

source

pub(crate) fn cargo_dir(&self) -> &'static str

Component directory that Cargo will produce output into (e.g. release/debug)

source

pub(crate) fn tools_dir(&self, compiler: Compiler) -> PathBuf

source

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.

source

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.

source

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.

source

pub(crate) fn lld_out(&self, target: TargetSelection) -> PathBuf

source

pub(crate) fn doc_out(&self, target: TargetSelection) -> PathBuf

Output directory for all documentation for a target

source

pub(crate) fn json_doc_out(&self, target: TargetSelection) -> PathBuf

Output directory for all JSON-formatted documentation for a target

source

pub(crate) fn test_out(&self, target: TargetSelection) -> PathBuf

source

pub(crate) fn compiler_doc_out(&self, target: TargetSelection) -> PathBuf

Output directory for all documentation for a target

source

pub(crate) fn md_doc_out(&self, target: TargetSelection) -> Interned<PathBuf>

Output directory for some generated md crate documentation for a target (temporary)

source

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.

source

pub(crate) fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf

Returns the path to FileCheck binary for the specified target

source

pub(crate) fn native_dir(&self, target: TargetSelection) -> PathBuf

Directory for libraries built from C/C++ code and shared between stages.

source

pub(crate) fn test_helpers_out(&self, target: TargetSelection) -> PathBuf

Root output directory for rust_test_helpers library compiled for target

source

pub(crate) fn add_rust_test_threads(&self, cmd: &mut Command)

Adds the RUST_TEST_THREADS env var if necessary

source

pub(crate) fn rustc_snapshot_libdir(&self) -> PathBuf

Returns the libdir of the snapshot compiler.

source

pub(crate) fn rustc_snapshot_sysroot(&self) -> &Path

Returns the sysroot of the snapshot compiler.

source

pub(crate) fn run(&self, cmd: &mut Command)

Runs a command, printing out nice contextual information if it fails.

source

pub(crate) fn run_quiet(&self, cmd: &mut Command)

Runs a command, printing out nice contextual information if it fails.

source

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().

source

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.

source

pub fn is_verbose_than(&self, level: usize) -> bool

source

pub(crate) fn verbose_than(&self, level: usize, msg: &str)

Prints a message if this build is configured in more verbose mode than level.

source

pub(crate) fn info(&self, msg: &str)

source

pub(crate) fn msg_check( &self, what: impl Display, target: impl Into<Option<TargetSelection>> ) -> Option<Group>

source

pub(crate) fn msg_doc( &self, compiler: Compiler, what: impl Display, target: impl Into<Option<TargetSelection>> + Copy ) -> Option<Group>

source

pub(crate) fn msg_build( &self, compiler: Compiler, what: impl Display, target: impl Into<Option<TargetSelection>> ) -> Option<Group>

source

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.

source

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.

source

pub(crate) fn msg_sysroot_tool( &self, action: impl Into<Kind>, stage: u32, what: impl Display, host: TargetSelection, target: TargetSelection ) -> Option<Group>

source

pub(crate) fn group(&self, msg: &str) -> Option<Group>

source

pub(crate) fn jobs(&self) -> u32

Returns the number of parallel jobs that have been configured for this build.

source

pub(crate) fn debuginfo_map_to(&self, which: GitRepo) -> Option<String>

source

pub(crate) fn cc(&self, target: TargetSelection) -> PathBuf

Returns the path to the C compiler for the target specified.

source

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.

source

pub(crate) fn ar(&self, target: TargetSelection) -> Option<PathBuf>

Returns the path to the ar archive utility for the target specified.

source

pub(crate) fn ranlib(&self, target: TargetSelection) -> Option<PathBuf>

Returns the path to the ranlib utility for the target specified.

source

pub(crate) fn cxx(&self, target: TargetSelection) -> Result<PathBuf, String>

Returns the path to the C++ compiler for the target specified.

source

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.

source

pub(crate) fn is_fuse_ld_lld(&self, target: TargetSelection) -> bool

source

pub(crate) fn lld_flags( &self, target: TargetSelection ) -> impl Iterator<Item = String>

source

pub(crate) fn crt_static(&self, target: TargetSelection) -> Option<bool>

Returns if this target should statically link the C runtime, if specified

source

pub(crate) fn musl_root(&self, target: TargetSelection) -> Option<&Path>

Returns the “musl root” for this target, if defined

source

pub(crate) fn musl_libdir(&self, target: TargetSelection) -> Option<PathBuf>

Returns the “musl libdir” for this target.

source

pub(crate) fn wasi_root(&self, target: TargetSelection) -> Option<&Path>

Returns the sysroot for the wasi target, if defined

source

pub(crate) fn no_std(&self, target: TargetSelection) -> Option<bool>

Returns true if this is a no-std target, if defined

source

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.

source

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.

source

pub(crate) fn python(&self) -> &Path

Path to the python interpreter to use

source

pub(crate) fn extended_error_dir(&self) -> PathBuf

Temporary directory that extended error information is emitted to.

source

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.

source

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.

source

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”.

source

pub(crate) fn beta_prerelease_version(&self) -> u32

source

pub(crate) fn rust_release(&self) -> String

Returns the value of release above for Rust itself.

source

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.

source

pub(crate) fn rust_package_vers(&self) -> String

Returns the value of package_vers above for Rust itself.

source

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.

source

pub(crate) fn rust_sha(&self) -> Option<&str>

Returns the full commit hash.

source

pub(crate) fn release_num(&self, package: &str) -> String

Returns the a.b.c version that the given package is at.

source

pub(crate) fn unstable_features(&self) -> bool

Returns true if unstable features should be enabled for the compiler we’re building.

source

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).

source

pub(crate) fn read_stamp_file( &self, stamp: &Path ) -> Vec<(PathBuf, DependencyType)>

source

pub fn copy(&self, src: &Path, dst: &Path)

Copies a file from src to dst

source

pub(crate) fn copy_internal( &self, src: &Path, dst: &Path, dereference_symlinks: bool )

source

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.

source

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.

source

pub(crate) fn recurse_( &self, src: &Path, dst: &Path, relative: &Path, filter: &dyn Fn(&Path) -> bool )

source

pub(crate) fn copy_to_folder(&self, src: &Path, dest_folder: &Path)

source

pub(crate) fn install(&self, src: &Path, dstdir: &Path, perms: u32)

source

pub(crate) fn read(&self, path: &Path) -> String

source

pub(crate) fn create_dir(&self, dir: &Path)

source

pub(crate) fn remove_dir(&self, dir: &Path)

source

pub(crate) fn read_dir(&self, dir: &Path) -> impl Iterator<Item = DirEntry>

source

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.

source

pub fn colored_stdout<R, F: FnOnce(&mut dyn WriteColor) -> R>(&self, f: F) -> R

source

pub fn colored_stderr<R, F: FnOnce(&mut dyn WriteColor) -> R>(&self, f: F) -> R

source

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§

source§

impl<'a> Deref for Builder<'a>

§

type Target = Build

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Builder<'a>

§

impl<'a> !Send for Builder<'a>

§

impl<'a> !Sync for Builder<'a>

§

impl<'a> Unpin for Builder<'a>

§

impl<'a> !UnwindSafe for Builder<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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: 144 bytes