Struct BuildScript

Source
pub struct BuildScript<'w> { /* private fields */ }
Expand description

A build script. This is the main struct for creating cargo arguments.

§Notes

99% of the time, you won’t need this. Instead, use the functions in basic.

Implementations§

Source§

impl<'w> BuildScript<'w>

Source

pub fn new(writer: &'w mut (dyn Write + Send)) -> Self

Create a new BuildScript.

§Notes

99% of the time, you won’t need to yse this associated function. The defaults can be used instead (BuildScript::default()).

Source

pub fn now(&mut self) -> &mut Self

Sets now to true.

Source

pub fn build(&mut self)

Write and remove all the instructions in the stack, starting from the first.

Source

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

Wrapper for cargo:rerun-if-changed=PATH. This tells Cargo when to rerun the script.

Source

pub fn cargo_rerun_if_env_changed(&mut self, var: &str) -> &mut Self

Wrapper for cargo:rerun-if-env-changed=VAR. This tells Cargo when to rerun the script.

Wrapper for cargo:rustc-link-lib=[KIND=]NAME. This adds a library to link.

Wrapper for cargo:rustc-link-search=[KIND=]PATH. This adds to the library search path.

Source

pub fn cargo_rustc_flags(&mut self, flags: &str) -> &mut Self

Wrapper for cargo:rustc-flags=FLAGS. This passes certain flags to the compiler.

Source

pub fn cargo_rustc_cfg(&mut self, key: &str, value: Option<&str>) -> &mut Self

Wrapper for cargo:rustc-cfg=KEY[="VALUE"]. This enable compile-time cfg settings.

Source

pub fn cargo_rustc_env(&mut self, var: &str, value: &str) -> &mut Self

Wrapper for cargo:rustc-env=VAR=VALUE. This sets an environment variable.

Wrapper for cargo:rustc-cdylib-link-arg=FLAG. This passes custom flags to a linker for cdylib crates.

Source

pub fn cargo_warning(&mut self, message: &str) -> &mut Self

Wrapper for cargo:warning=MESSAGE. This displays a warning on the terminal.

Source

pub fn cargo_mapping(&mut self, key: &str, value: &str) -> &mut Self

Wrapper for cargo:KEY=VALUE. This is metadata, used by links scripts.

Source

pub fn custom_instruction(&mut self, instruction: Instruction) -> &mut Self

Pass a custom instruction. Internally, BuildScript uses this. This may be used when build_script isn’t updated for new instructions yet in the future.

Trait Implementations§

Source§

impl Default for BuildScript<'static>

Source§

fn default() -> Self

Get the default build script. Writer is io::stdout().

§Notes

99% of the time, you can use this associated function instead.

Auto Trait Implementations§

§

impl<'w> Freeze for BuildScript<'w>

§

impl<'w> !RefUnwindSafe for BuildScript<'w>

§

impl<'w> Send for BuildScript<'w>

§

impl<'w> !Sync for BuildScript<'w>

§

impl<'w> Unpin for BuildScript<'w>

§

impl<'w> !UnwindSafe for BuildScript<'w>

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