pub struct Cargo { /* private fields */ }
Available on crate feature
cargo
only.Expand description
Configure the emission of VERGEN_CARGO_*
instructions
NOTE - All cargo instructions are considered deterministic. If you change the version of cargo you are compiling with, these values should change if being used in the generated binary.
Variable | Sample |
---|---|
VERGEN_CARGO_DEBUG | true |
VERGEN_CARGO_FEATURES | git,build |
VERGEN_CARGO_OPT_LEVEL | 1 |
VERGEN_CARGO_TARGET_TRIPLE | x86_64-unknown-linux-gnu |
§Example
Emit all of the cargo instructions
fn main() -> Result<()> {
temp_env::with_vars([
("CARGO_FEATURE_BUILD", Some("")),
("DEBUG", Some("true")),
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = CargoBuilder::all_cargo()?;
Emitter::default().add_instructions(&cargo)?.emit()?;
});
Emit some of the cargo instructions
temp_env::with_vars([
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = CargoBuilder::default().opt_level(true).build()?;
Emitter::default().add_instructions(&cargo)?.emit()?;
});
Override output with your own value
fn main() -> Result<()> {
temp_env::with_vars([
("CARGO_FEATURE_BUILD", Some("")),
("VERGEN_CARGO_DEBUG", Some("my own debug value")),
("OPT_LEVEL", Some("1")),
("TARGET", Some("x86_64-unknown-linux-gnu"))
], || {
let cargo = CargoBuilder::all_cargo()?;
Emitter::default().add_instructions(&cargo)?.emit()?;
});
Implementations§
Source§impl Cargo
impl Cargo
Sourcepub fn set_name_filter(&mut self, val: Option<&'static str>) -> &mut Self
pub fn set_name_filter(&mut self, val: Option<&'static str>) -> &mut Self
Add a name Regex
filter for cargo dependencies
cargo:rustc-env=VERGEN_CARGO_DEPENDENCIES=<deps_filtered_by_name>
Sourcepub fn set_dep_kind_filter(&mut self, val: Option<DependencyKind>) -> &mut Self
pub fn set_dep_kind_filter(&mut self, val: Option<DependencyKind>) -> &mut Self
Add a DependencyKind
filter for cargo dependencies
cargo:rustc-env=VERGEN_CARGO_DEPENDENCIES=<deps_filtered_by_kind>
Trait Implementations§
Source§impl Add for Cargo
impl Add for Cargo
Source§fn add_map_entries(
&self,
_idempotent: bool,
cargo_rustc_env: &mut CargoRustcEnvMap,
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
_cargo_warning: &mut CargoWarning,
) -> Result<()>
fn add_map_entries( &self, _idempotent: bool, cargo_rustc_env: &mut CargoRustcEnvMap, _cargo_rerun_if_changed: &mut CargoRerunIfChanged, _cargo_warning: &mut CargoWarning, ) -> Result<()>
Try to add instructions entries to the various given arguments. Read more
Source§fn add_default_entries(
&self,
config: &DefaultConfig,
cargo_rustc_env_map: &mut CargoRustcEnvMap,
_cargo_rerun_if_changed: &mut CargoRerunIfChanged,
cargo_warning: &mut CargoWarning,
) -> Result<()>
fn add_default_entries( &self, config: &DefaultConfig, cargo_rustc_env_map: &mut CargoRustcEnvMap, _cargo_rerun_if_changed: &mut CargoRerunIfChanged, cargo_warning: &mut CargoWarning, ) -> Result<()>
Based on the given configuration, emit either default idempotent output or generate a failue. Read more
impl Copy for Cargo
impl StructuralPartialEq for Cargo
Auto Trait Implementations§
impl Freeze for Cargo
impl RefUnwindSafe for Cargo
impl Send for Cargo
impl Sync for Cargo
impl Unpin for Cargo
impl UnwindSafe for Cargo
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more