Struct SysrootBuilder

Source
pub struct SysrootBuilder { /* private fields */ }
Expand description

A builder interface for constructing the Sysroot

See the individual methods for more details on what this means and what defaults exist.

Implementations§

Source§

impl SysrootBuilder

Source

pub fn new(sysroot_crate: Sysroot) -> Self

New SysrootBuilder.

sysroot_crate specifies which libraries to build as part of the sysroot. See Sysroot for more details.

Source

pub fn manifest(&mut self, manifest: PathBuf) -> &mut Self

Set path to the Cargo.toml of the project requiring a custom sysroot.

If provided, any Cargo Profile’s in the provided manifest will be copied into the sysroot crate being compiled.

If not provided, profiles use their default settings.

By default this will be None.

Source

pub fn output(&mut self, output: PathBuf) -> &mut Self

Set where the sysroot directory will be placed.

By default this is ./target/sysroot.

Source

pub fn target(&mut self, target: PathBuf) -> &mut Self

The target to compile for. This can be a target-triple, or a JSON Target Specification.

By default this is None, and if not set when SysrootBuilder::build is called, will cause an error.

Source

pub fn rust_src(&mut self, rust_src: PathBuf) -> &mut Self

The rust source directory. These are used to compile the sysroot.

By default this uses the rust-src component from the current rustup toolchain.

Source

pub fn features(&mut self, features: &[Features]) -> &mut Self

Which features to enable.

This adds to, not replaces, any previous calls to this method.

By default this is empty.

See Features for details.

Source

pub fn rustc_flags<I, S>(&mut self, flags: I) -> &mut Self
where I: IntoIterator<Item = S>, S: Into<OsString>,

Custom flags to pass to all rustc compiler invocations.

This adds to, not replaces, any previous calls to this method.

By default this is empty.

§Internal

This will use the RUSTFLAGS to ensure flags are set for all invocations.

Flags passed to this method will be appended to any existing RUSTFLAGS.

Source

pub fn build(&self) -> Result<PathBuf>

Build the Sysroot, and return a path suitable to pass to rustc.

§Errors
  • SysrootBuilder::target was not called
  • If manifest is provided and does not exist
  • If target is a JSON specification, but doesn’t exist.
  • If the rust_src directory does not exist, or could not be detected.
  • If the sysroot cannot be setup, or fails to compile

Trait Implementations§

Source§

impl Clone for SysrootBuilder

Source§

fn clone(&self) -> SysrootBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SysrootBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.