pub struct BuildScript<'w> { /* private fields */ }
Expand description
Implementations§
Source§impl<'w> BuildScript<'w>
impl<'w> BuildScript<'w>
Sourcepub fn new(writer: &'w mut (dyn Write + Send)) -> Self
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()
).
Sourcepub fn build(&mut self)
pub fn build(&mut self)
Write and remove all the instructions in the stack, starting from the first.
Sourcepub fn cargo_rerun_if_changed(&mut self, path: PathBuf) -> &mut Self
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.
Sourcepub fn cargo_rerun_if_env_changed(&mut self, var: &str) -> &mut Self
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.
Sourcepub fn cargo_rustc_link_lib(
&mut self,
kind: Option<Kind>,
name: &str,
) -> &mut Self
pub fn cargo_rustc_link_lib( &mut self, kind: Option<Kind>, name: &str, ) -> &mut Self
Wrapper for cargo:rustc-link-lib=[KIND=]NAME
. This adds a library to link.
Sourcepub fn cargo_rustc_link_search(
&mut self,
kind: Option<Kind>,
path: PathBuf,
) -> &mut Self
pub fn cargo_rustc_link_search( &mut self, kind: Option<Kind>, path: PathBuf, ) -> &mut Self
Wrapper for cargo:rustc-link-search=[KIND=]PATH
. This adds to the library search path.
Sourcepub fn cargo_rustc_flags(&mut self, flags: &str) -> &mut Self
pub fn cargo_rustc_flags(&mut self, flags: &str) -> &mut Self
Wrapper for cargo:rustc-flags=FLAGS
. This passes certain flags to the compiler.
Sourcepub fn cargo_rustc_cfg(&mut self, key: &str, value: Option<&str>) -> &mut Self
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.
Sourcepub fn cargo_rustc_env(&mut self, var: &str, value: &str) -> &mut Self
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.
Sourcepub fn cargo_rustc_cdylib_link_arg(&mut self, flag: &str) -> &mut Self
pub fn cargo_rustc_cdylib_link_arg(&mut self, flag: &str) -> &mut Self
Wrapper for cargo:rustc-cdylib-link-arg=FLAG
. This passes custom flags to a linker for
cdylib crates.
Sourcepub fn cargo_warning(&mut self, message: &str) -> &mut Self
pub fn cargo_warning(&mut self, message: &str) -> &mut Self
Wrapper for cargo:warning=MESSAGE
. This displays a warning on the terminal.
Sourcepub fn cargo_mapping(&mut self, key: &str, value: &str) -> &mut Self
pub fn cargo_mapping(&mut self, key: &str, value: &str) -> &mut Self
Wrapper for cargo:KEY=VALUE
. This is metadata, used by links
scripts.
Sourcepub fn custom_instruction(&mut self, instruction: Instruction) -> &mut Self
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>
impl Default for BuildScript<'static>
Source§fn default() -> Self
fn default() -> Self
Get the default build script. Writer is io::stdout()
.
§Notes
99% of the time, you can use this associated function instead.