Struct vergen::EmitBuilder
source · pub struct EmitBuilder { /* private fields */ }
Expand description
Build the vergen
configuration to enable specific cargo instruction
output
Implementations§
source§impl EmitBuilder
impl EmitBuilder
sourcepub fn idempotent(&mut self) -> &mut Self
pub fn idempotent(&mut self) -> &mut Self
Enable the idempotent
feature
NOTE - This feature can also be enabled via the VERGEN_IDEMPOTENT
environment variable.
When this feature is enabled, certain vergen output (i.e. timestamps, sysinfo)
will be set to an idempotent default. This will allow systems that
depend on deterministic builds to override user requested vergen
impurities. This will mainly allow for package maintainers to build
packages that depend on vergen
in a deterministic manner.
See this issue for more details
Variable | Sample |
---|---|
VERGEN_BUILD_DATE | VERGEN_IDEMPOTENT_OUTPUT |
VERGEN_BUILD_TIMESTAMP | VERGEN_IDEMPOTENT_OUTPUT |
Example
EmitBuilder::builder().idempotent().all_build().emit()?;
// or
env::set_var("VERGEN_IDEMPOTENT", "true");
EmitBuilder::builder().all_build().emit()?;
sourcepub fn fail_on_error(&mut self) -> &mut Self
pub fn fail_on_error(&mut self) -> &mut Self
Enable the fail_on_error
feature
By default vergen
will emit the instructions you requested. If for some
reason those instructions cannot be generated correctly, placeholder values
will be used instead. vergen
will also emit cargo:warning
instructions notifying you this has happened.
For example, if you configure vergen
to emit VERGEN_GIT_*
instructions and
you run a build from a source tarball with no .git
directory, the instructions
will be populated with placeholder values, rather than information gleaned through git.
You can turn off this behavior by enabling fail_on_error
.
Example
EmitBuilder::builder().fail_on_error().all_build().emit()?;
sourcepub fn custom_build_rs(&mut self, path: &'static str) -> &mut Self
pub fn custom_build_rs(&mut self, path: &'static str) -> &mut Self
Set a custom build.rs path if you are using a non-standard path
By default vergen
will use build.rs
as the build path for the
cargo:rerun-if-changed
emit. You can specify a custom build.rs
path here if you have changed this default
Example
EmitBuilder::builder().custom_build_rs("my/custom/build.rs").all_build().emit()?;
sourcepub fn quiet(&mut self) -> &mut Self
pub fn quiet(&mut self) -> &mut Self
Enable the quiet feature
Suppress the emission of the cargo:warning
instructions.
Example
EmitBuilder::builder().quiet().all_build().emit()?;
sourcepub fn disable_build(&mut self) -> &mut Self
Available on crate feature build
only.
pub fn disable_build(&mut self) -> &mut Self
build
only.Disable the build output, even when the build feature is enabled.
Example
EmitBuilder::builder().all_build().disable_build().emit()?;
sourcepub fn disable_cargo(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn disable_cargo(&mut self) -> &mut Self
cargo
only.Disable the cargo output, even when the cargo feature is enabled.
Example
EmitBuilder::builder().all_cargo().disable_cargo().emit()?;
sourcepub fn disable_git(&mut self) -> &mut Self
Available on crate feature git
and (crate features git2
or gitcl
or gix
) only.
pub fn disable_git(&mut self) -> &mut Self
git
and (crate features git2
or gitcl
or gix
) only.Disable the git output, even when the git feature is enabled.
Example
EmitBuilder::builder().all_git().disable_git().emit()?;
sourcepub fn disable_rustc(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn disable_rustc(&mut self) -> &mut Self
rustc
only.Disable the rustc output, even when the rustc feature is enabled.
Example
EmitBuilder::builder().all_rustc().disable_rustc().emit()?;
sourcepub fn disable_sysinfo(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn disable_sysinfo(&mut self) -> &mut Self
si
only.Disable the sysinfo output, even when the sysinfo feature is enabled.
Example
EmitBuilder::builder().all_sysinfo().disable_sysinfo().emit()?;
sourcepub fn emit(self) -> Result<()>
pub fn emit(self) -> Result<()>
Emit cargo instructions from your build script
- Will emit
cargo:rustc-env=VAR=VALUE
for each feature you have enabled. - Will emit
cargo:rerun-if-changed=PATH
if the git feature is enabled. This is done to ensure any git variables are regenerated when commits are made. - Can emit
cargo:warning
outputs if thefail_on_error
feature is not enabled and the requested variable is defaulted through error or theidempotent
flag.
Errors
- The
writeln!
macro can throw astd::io::Error
Example
EmitBuilder::builder()
.all_build()
.all_cargo()
.all_git()
.all_rustc()
.all_sysinfo()
.emit()?;
Sample Output
NOTE - You won’t see this output unless you invoke cargo with the -vv
flag.
The instruction output is not displayed by default.
cargo:rustc-env=VERGEN_BUILD_DATE=2023-01-04
cargo:rustc-env=VERGEN_BUILD_TIMESTAMP=2023-01-04T15:38:11.097507114Z
cargo:rustc-env=VERGEN_CARGO_DEBUG=true
cargo:rustc-env=VERGEN_CARGO_FEATURES=build,git
cargo:rustc-env=VERGEN_CARGO_OPT_LEVEL=1
cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=x86_64-unknown-linux-gnu
cargo:rustc-env=VERGEN_GIT_BRANCH=feature/version8
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_EMAIL=your@email.com
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_NAME=Yoda
cargo:rustc-env=VERGEN_GIT_COMMIT_COUNT=476
cargo:rustc-env=VERGEN_GIT_COMMIT_DATE=2023-01-03
cargo:rustc-env=VERGEN_GIT_COMMIT_MESSAGE=The best message
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=2023-01-03T14:08:12.000000000-05:00
cargo:rustc-env=VERGEN_GIT_DESCRIBE=7.4.4-103-g53ae8a6
cargo:rustc-env=VERGEN_GIT_SHA=53ae8a69ab7917a2909af40f2e5d015f5b29ae28
cargo:rustc-env=VERGEN_RUSTC_CHANNEL=nightly
cargo:rustc-env=VERGEN_RUSTC_COMMIT_DATE=2023-01-03
cargo:rustc-env=VERGEN_RUSTC_COMMIT_HASH=c7572670a1302f5c7e245d069200e22da9df0316
cargo:rustc-env=VERGEN_RUSTC_HOST_TRIPLE=x86_64-unknown-linux-gnu
cargo:rustc-env=VERGEN_RUSTC_LLVM_VERSION=15.0
cargo:rustc-env=VERGEN_RUSTC_SEMVER=1.68.0-nightly
cargo:rustc-env=VERGEN_SYSINFO_NAME=Arch Linux
cargo:rustc-env=VERGEN_SYSINFO_OS_VERSION=Linux Arch Linux
cargo:rustc-env=VERGEN_SYSINFO_USER=jozias
cargo:rustc-env=VERGEN_SYSINFO_TOTAL_MEMORY=31 GiB
cargo:rustc-env=VERGEN_SYSINFO_CPU_VENDOR=AuthenticAMD
cargo:rustc-env=VERGEN_SYSINFO_CPU_CORE_COUNT=8
cargo:rustc-env=VERGEN_SYSINFO_CPU_NAME=cpu0,cpu1,cpu2,cpu3,cpu4,cpu5,cpu6,cpu7
cargo:rustc-env=VERGEN_SYSINFO_CPU_BRAND=AMD Ryzen Threadripper 1900X 8-Core Processor
cargo:rustc-env=VERGEN_SYSINFO_CPU_FREQUENCY=3792
cargo:rerun-if-changed=.git/HEAD
cargo:rerun-if-changed=.git/refs/heads/feature/version8
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=VERGEN_IDEMPOTENT
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH
sourcepub fn emit_and_set(self) -> Result<()>
Available on crate features build
or cargo
or git
or rustc
or si
only.
pub fn emit_and_set(self) -> Result<()>
build
or cargo
or git
or rustc
or si
only.Emit cargo instructions from your build script and set environment variables for use in build.rs
- Will emit
cargo:rustc-env=VAR=VALUE
for each feature you have enabled. - Will emit
cargo:rerun-if-changed=PATH
if the git feature is enabled. This is done to ensure any git variables are regenerated when commits are made. - Can emit
cargo:warning
outputs if thefail_on_error
feature is not enabled and the requested variable is defaulted through error or theidempotent
flag.
Errors
- The
writeln!
macro can throw astd::io::Error
Example
EmitBuilder::builder()
.all_build()
.all_cargo()
.all_git()
.all_rustc()
.all_sysinfo()
.emit_and_set()?;
source§impl EmitBuilder
impl EmitBuilder
The VERGEN_BUILD_*
configuration features
Variable | Sample |
---|---|
VERGEN_BUILD_DATE | 2021-02-25 |
VERGEN_BUILD_TIMESTAMP | 2021-02-25T23:28:39.493201+00:00 |
Example
Emit all of the build instructions
EmitBuilder::builder().all_build().emit()?;
Emit some of the build instructions
EmitBuilder::builder().build_timestamp().emit()?;
Override output with your own value
env::set_var("VERGEN_BUILD_DATE", "this is the date I want output");
EmitBuilder::builder().build_date().emit()?;
Example
This feature can also be used in conjuction with the SOURCE_DATE_EPOCH
environment variable to generate deterministic timestamps based off the
last modification time of the source/package
env::set_var("SOURCE_DATE_EPOCH", "1671809360");
EmitBuilder::builder().all_build().emit()?;
The above will always generate the following output for the timestamp related instructions
cargo:rustc-env=VERGEN_BUILD_DATE=2022-12-23
cargo:rustc-env=VERGEN_BUILD_TIMESTAMP=2022-12-23T15:29:20.000000000Z
Example
This feature also recognizes the idempotent flag.
NOTE - SOURCE_DATE_EPOCH
takes precedence over the idempotent flag. If you
use both, the output will be based off SOURCE_DATE_EPOCH
. This would still be
deterministic.
EmitBuilder::builder().idempotent().all_build().emit()?;
The above will always generate the following output for the timestamp related instructions
cargo:rustc-env=VERGEN_BUILD_DATE=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_BUILD_TIMESTAMP=VERGEN_IDEMPOTENT_OUTPUT
cargo:warning=VERGEN_BUILD_DATE set to default
cargo:warning=VERGEN_BUILD_TIMESTAMP set to default
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=VERGEN_IDEMPOTENT
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH
sourcepub fn all_build(&mut self) -> &mut Self
Available on crate feature build
only.
pub fn all_build(&mut self) -> &mut Self
build
only.Enable all of the VERGEN_BUILD_*
options
sourcepub fn build_date(&mut self) -> &mut Self
Available on crate feature build
only.
pub fn build_date(&mut self) -> &mut Self
build
only.Enable the VERGEN_BUILD_DATE
date output
sourcepub fn build_timestamp(&mut self) -> &mut Self
Available on crate feature build
only.
pub fn build_timestamp(&mut self) -> &mut Self
build
only.Enable the VERGEN_BUILD_TIMESTAMP
date output
sourcepub fn use_local_build(&mut self) -> &mut Self
Available on crate feature build
only.
pub fn use_local_build(&mut self) -> &mut Self
build
only.Enable local offset date/timestamp output
source§impl EmitBuilder
impl EmitBuilder
Copnfigure 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
EmitBuilder::builder().all_cargo().emit()?;
Emit some of the cargo instructions
EmitBuilder::builder().cargo_debug().cargo_opt_level().emit()?;
Override output with your own value
env::set_var("VERGEN_CARGO_DEBUG", "this is the debug I want output");
EmitBuilder::builder().all_cargo().emit()?;
sourcepub fn all_cargo(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn all_cargo(&mut self) -> &mut Self
cargo
only.Emit all of the VERGEN_CARGO_*
instructions
sourcepub fn cargo_debug(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_debug(&mut self) -> &mut Self
cargo
only.Emit the DEBUG value set by cargo
cargo:rustc-env=VERGEN_CARGO_DEBUG=true|false
sourcepub fn cargo_features(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_features(&mut self) -> &mut Self
cargo
only.Emit the CARGO_FEATURE_*
values set by cargo
cargo:rustc-env=VERGEN_CARGO_FEATURES=<features>
sourcepub fn cargo_opt_level(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_opt_level(&mut self) -> &mut Self
cargo
only.Emit the OPT_LEVEL
value set by cargo
cargo:rustc-env=VERGEN_CARGO_OPT_LEVEL=<opt_level>
sourcepub fn cargo_target_triple(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_target_triple(&mut self) -> &mut Self
cargo
only.Emit the TARGET value set by cargo
cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=<target_triple>
sourcepub fn cargo_dependencies(&mut self) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_dependencies(&mut self) -> &mut Self
cargo
only.Emit the dependencies value derived from Cargo.toml
cargo:rustc-env=VERGEN_CARGO_DEPENDENCIES=<dependencies>
sourcepub fn cargo_dependencies_name_filter(
&mut self,
name_filter: Option<&'static str>
) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_dependencies_name_filter( &mut self, name_filter: Option<&'static str> ) -> &mut Self
cargo
only.Add a name Regex
filter for cargo dependencies
cargo:rustc-env=VERGEN_CARGO_DEPENDENCIES=<deps_filtered_by_name>
sourcepub fn cargo_dependencies_dep_kind_filter(
&mut self,
dep_kind_filter: Option<DependencyKind>
) -> &mut Self
Available on crate feature cargo
only.
pub fn cargo_dependencies_dep_kind_filter( &mut self, dep_kind_filter: Option<DependencyKind> ) -> &mut Self
cargo
only.Add a DependencyKind
filter for cargo dependencies
cargo:rustc-env=VERGEN_CARGO_DEPENDENCIES=<deps_filtered_by_kind>
source§impl EmitBuilder
impl EmitBuilder
The VERGEN_GIT_*
configuration features
Variable | Sample |
---|---|
VERGEN_GIT_BRANCH | feature/fun |
VERGEN_GIT_COMMIT_AUTHOR_EMAIL | janedoe@email.com |
VERGEN_GIT_COMMIT_AUTHOR_NAME | Jane Doe |
VERGEN_GIT_COMMIT_COUNT | 330 |
VERGEN_GIT_COMMIT_DATE | 2021-02-24 |
VERGEN_GIT_COMMIT_MESSAGE | feat: add commit messages |
VERGEN_GIT_COMMIT_TIMESTAMP | 2021-02-24T20:55:21+00:00 |
VERGEN_GIT_DESCRIBE | 5.0.0-2-gf49246c |
VERGEN_GIT_SHA | f49246ce334567bff9f950bfd0f3078184a2738a |
VERGEN_GIT_DIRTY | true |
Example
Emit all of the git instructions
EmitBuilder::builder().all_git().emit()?;
Emit some of the git instructions
EmitBuilder::builder().git_describe(true, false, None).emit()?;
Override output with your own value
env::set_var("VERGEN_GIT_BRANCH", "this is the branch I want output");
EmitBuilder::builder().all_git().emit()?;
Example
This feature can also be used in conjuction with the SOURCE_DATE_EPOCH
environment variable to generate deterministic timestamps based off the
last modification time of the source/package
env::set_var("SOURCE_DATE_EPOCH", "1671809360");
EmitBuilder::builder().all_git().emit()?;
The above will always generate the following output for the timestamp related instructions
...
cargo:rustc-env=VERGEN_GIT_COMMIT_DATE=2022-12-23
...
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=2022-12-23T15:29:20.000000000Z
...
Example
This feature also recognizes the idempotent flag.
NOTE - SOURCE_DATE_EPOCH
takes precedence over the idempotent flag. If you
use both, the output will be based off SOURCE_DATE_EPOCH
. This would still be
deterministic.
Example
EmitBuilder::builder().idempotent().all_git().emit()?;
The above will always generate the following instructions
cargo:rustc-env=VERGEN_GIT_BRANCH=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_EMAIL=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_NAME=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_COUNT=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_DATE=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_MESSAGE=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_DESCRIBE=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_GIT_SHA=VERGEN_IDEMPOTENT_OUTPUT
cargo:warning=VERGEN_GIT_BRANCH set to default
cargo:warning=VERGEN_GIT_COMMIT_AUTHOR_EMAIL set to default
cargo:warning=VERGEN_GIT_COMMIT_AUTHOR_NAME set to default
cargo:warning=VERGEN_GIT_COMMIT_COUNT set to default
cargo:warning=VERGEN_GIT_COMMIT_DATE set to default
cargo:warning=VERGEN_GIT_COMMIT_MESSAGE set to default
cargo:warning=VERGEN_GIT_COMMIT_TIMESTAMP set to default
cargo:warning=VERGEN_GIT_DESCRIBE set to default
cargo:warning=VERGEN_GIT_SHA set to default
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=VERGEN_IDEMPOTENT
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH
sourcepub fn all_git(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn all_git(&mut self) -> &mut Self
git
only.Emit all of the VERGEN_GIT_*
instructions
sourcepub fn git_branch(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn git_branch(&mut self) -> &mut Self
git
only.Emit the current git branch
cargo:rustc-env=VERGEN_GIT_BRANCH=<BRANCH_NAME>
The value is determined with the following command
git rev-parse --abbrev-ref --symbolic-full-name HEAD
Available on crate feature git
only.
git
only.Emit the author email of the most recent commit
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_EMAIL=<AUTHOR_EMAIL>
The value is determined with the following command
git log -1 --pretty=format:'%ae'
Available on crate feature git
only.
git
only.Emit the author name of the most recent commit
cargo:rustc-env=VERGEN_GIT_COMMIT_AUTHOR_NAME=<AUTHOR_NAME>
The value is determined with the following command
git log -1 --pretty=format:'%an'
sourcepub fn git_commit_count(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn git_commit_count(&mut self) -> &mut Self
git
only.Emit the total commit count to HEAD
cargo:rustc-env=VERGEN_GIT_COMMIT_COUNT=<COUNT>
The value is determined with the following command
git rev-list --count HEAD
sourcepub fn git_commit_date(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn git_commit_date(&mut self) -> &mut Self
git
only.Emit the commit date of the latest commit
cargo:rustc-env=VERGEN_GIT_COMMIT_DATE=<YYYY-MM-DD>
The value is determined with the following command
git log -1 --pretty=format:'%cs'
sourcepub fn git_commit_message(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn git_commit_message(&mut self) -> &mut Self
git
only.Emit the commit message of the latest commit
cargo:rustc-env=VERGEN_GIT_COMMIT_MESSAGE=<MESSAGE>
The value is determined with the following command
git log -1 --format=%s
sourcepub fn git_commit_timestamp(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn git_commit_timestamp(&mut self) -> &mut Self
git
only.Emit the commit timestamp of the latest commit
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=<YYYY-MM-DDThh:mm:ssZ>
The value is determined with the following command
git log -1 --pretty=format:'%cI'
sourcepub fn git_describe(
&mut self,
dirty: bool,
tags: bool,
match_pattern: Option<&'static str>
) -> &mut Self
Available on crate feature git
only.
pub fn git_describe( &mut self, dirty: bool, tags: bool, match_pattern: Option<&'static str> ) -> &mut Self
git
only.Emit the describe output
cargo:rustc-env=VERGEN_GIT_DESCRIBE=<DESCRIBE>
The value is determined with the following command
git describe --always
Optionally, add the dirty
, tags
, or match
flag to describe.
See git describe
for more details
sourcepub fn git_sha(&mut self, short: bool) -> &mut Self
Available on crate feature git
only.
pub fn git_sha(&mut self, short: bool) -> &mut Self
git
only.Emit the SHA of the latest commit
cargo:rustc-env=VERGEN_GIT_SHA=<SHA>
The value is determined with the following command
git rev-parse HEAD
Optionally, add the short
flag to rev-parse.
See git rev-parse
for more details.
sourcepub fn git_dirty(&mut self, include_untracked: bool) -> &mut Self
Available on crate feature git
only.
pub fn git_dirty(&mut self, include_untracked: bool) -> &mut Self
git
only.Emit the dirty state of the git repository
cargo:rustc-env=VERGEN_GIT_DIRTY=(true|false)
Optionally, include/ignore untracked files in deciding whether the repository is dirty.
sourcepub fn git_cmd(&mut self, cmd: Option<&'static str>) -> &mut Self
Available on crate feature git
only.
pub fn git_cmd(&mut self, cmd: Option<&'static str>) -> &mut Self
git
only.Set the command used to test if git exists on the path.
Defaults to git --version
if not set explicitly.
sourcepub fn use_local_git(&mut self) -> &mut Self
Available on crate feature git
only.
pub fn use_local_git(&mut self) -> &mut Self
git
only.Enable local offset date/timestamp output
source§impl EmitBuilder
impl EmitBuilder
The VERGEN_RUSTC_*
configuration features
NOTE - All rustc instructions are considered deterministic. If you change the version of rustc you are compiling with, these values should change if being used in the generated binary.
Variable | Sample |
---|---|
VERGEN_RUSTC_CHANNEL | nightly |
VERGEN_RUSTC_COMMIT_DATE | 2021-02-24 |
VERGEN_RUSTC_COMMIT_HASH | a8486b64b0c87dabd045453b6c81500015d122d6 |
VERGEN_RUSTC_HOST_TRIPLE | x86_64-apple-darwin |
VERGEN_RUSTC_LLVM_VERSION | 11.0 |
VERGEN_RUSTC_SEMVER | 1.52.0-nightly |
Example
Emit all of the rustc instructions
EmitBuilder::builder().all_rustc().emit()?;
Emit some of the rustc instructions
EmitBuilder::builder()
.rustc_channel()
.rustc_semver()
.emit()?;
Override output with your own value
env::set_var("VERGEN_RUSTC_CHANNEL", "this is the channel I want output");
EmitBuilder::builder().all_rustc().emit()?;
sourcepub fn all_rustc(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn all_rustc(&mut self) -> &mut Self
rustc
only.Enable all of the VERGEN_RUSTC_*
options
sourcepub fn rustc_channel(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_channel(&mut self) -> &mut Self
rustc
only.Enable the rustc channel
sourcepub fn rustc_commit_date(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_commit_date(&mut self) -> &mut Self
rustc
only.Enable the rustc commit date
sourcepub fn rustc_commit_hash(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_commit_hash(&mut self) -> &mut Self
rustc
only.Enable the rustc SHA
sourcepub fn rustc_host_triple(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_host_triple(&mut self) -> &mut Self
rustc
only.Enable rustc host triple
sourcepub fn rustc_llvm_version(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_llvm_version(&mut self) -> &mut Self
rustc
only.Enable rustc LLVM version
sourcepub fn rustc_semver(&mut self) -> &mut Self
Available on crate feature rustc
only.
pub fn rustc_semver(&mut self) -> &mut Self
rustc
only.Enable the rustc semver
source§impl EmitBuilder
impl EmitBuilder
The VERGEN_SYSINFO_*
configuration features
Variable | Sample |
---|---|
VERGEN_SYSINFO_NAME | Manjaro Linux |
VERGEN_SYSINFO_OS_VERSION | Linux Manjaro Linux |
VERGEN_SYSINFO_USER | Yoda |
VERGEN_SYSINFO_TOTAL_MEMORY | 33 GB |
VERGEN_SYSINFO_CPU_VENDOR | Authentic AMD |
VERGEN_SYSINFO_CPU_CORE_COUNT | 8 |
VERGEN_SYSINFO_CPU_NAME | cpu0,cpu1,cpu2,cpu3,cpu4,cpu5,cpu6,cpu7 |
VERGEN_SYSINFO_CPU_BRAND | AMD Ryzen Threadripper 1900X 8-Core Processor |
VERGEN_SYSINFO_CPU_FREQUENCY | 3792 |
Example
Emit all sysinfo instructions
EmitBuilder::builder().all_sysinfo().emit()?;
Emit some of the sysinfo instructions
EmitBuilder::builder()
.sysinfo_os_version()
.sysinfo_cpu_core_count()
.emit()?;
Override output with your own value
env::set_var("VERGEN_SYSINFO_NAME", "this is the name I want output");
EmitBuilder::builder().all_sysinfo().emit()?;
Example
This feature also recognizes the idempotent flag.
EmitBuilder::builder().idempotent().all_sysinfo().emit()?;
The above will always generate the following output
cargo:rustc-env=VERGEN_SYSINFO_NAME=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_OS_VERSION=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_USER=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_TOTAL_MEMORY=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_VENDOR=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_CORE_COUNT=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_NAME=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_BRAND=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_FREQUENCY=VERGEN_IDEMPOTENT_OUTPUT
cargo:warning=VERGEN_SYSINFO_NAME set to default
cargo:warning=VERGEN_SYSINFO_OS_VERSION set to default
cargo:warning=VERGEN_SYSINFO_USER set to default
cargo:warning=VERGEN_SYSINFO_TOTAL_MEMORY set to default
cargo:warning=VERGEN_SYSINFO_CPU_VENDOR set to default
cargo:warning=VERGEN_SYSINFO_CPU_CORE_COUNT set to default
cargo:warning=VERGEN_SYSINFO_CPU_NAME set to default
cargo:warning=VERGEN_SYSINFO_CPU_BRAND set to default
cargo:warning=VERGEN_SYSINFO_CPU_FREQUENCY set to default
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=VERGEN_IDEMPOTENT
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH
sourcepub fn all_sysinfo(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn all_sysinfo(&mut self) -> &mut Self
si
only.Enable all of the VERGEN_SYSINFO_*
options
sourcepub fn sysinfo_refresh_kind(
&mut self,
refresh_kind: Option<RefreshKind>
) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_refresh_kind( &mut self, refresh_kind: Option<RefreshKind> ) -> &mut Self
si
only.Set the RefreshKind
to use during sysinfo initialization.
This allows the user to control at a more fine level what sysinfo
will refresh on initialization.
Example
let refresh_kind = RefreshKind::new();
let cpu_refresh_kind = CpuRefreshKind::everything()
.without_cpu_usage()
.without_frequency();
let config = EmitBuilder::builder()
.sysinfo_refresh_kind(Some(refresh_kind.with_cpu(cpu_refresh_kind)))
.sysinfo_cpu_brand()
.emit()?;
sourcepub fn sysinfo_name(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_name(&mut self) -> &mut Self
si
only.Enable the sysinfo name
sourcepub fn sysinfo_os_version(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_os_version(&mut self) -> &mut Self
si
only.Enable the sysinfo OS version
sourcepub fn sysinfo_user(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_user(&mut self) -> &mut Self
si
only.Enable sysinfo user
sourcepub fn sysinfo_memory(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_memory(&mut self) -> &mut Self
si
only.Enable sysinfo memory
sourcepub fn sysinfo_cpu_vendor(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_cpu_vendor(&mut self) -> &mut Self
si
only.Enable sysinfo cpu vendor
sourcepub fn sysinfo_cpu_core_count(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_cpu_core_count(&mut self) -> &mut Self
si
only.Enable sysinfo cpu core count
sourcepub fn sysinfo_cpu_name(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_cpu_name(&mut self) -> &mut Self
si
only.Enable sysinfo cpu name
sourcepub fn sysinfo_cpu_brand(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_cpu_brand(&mut self) -> &mut Self
si
only.Enable sysinfo cpu brand
sourcepub fn sysinfo_cpu_frequency(&mut self) -> &mut Self
Available on crate feature si
only.
pub fn sysinfo_cpu_frequency(&mut self) -> &mut Self
si
only.Enable sysinfo cpu frequency
Trait Implementations§
source§impl Clone for EmitBuilder
impl Clone for EmitBuilder
source§fn clone(&self) -> EmitBuilder
fn clone(&self) -> EmitBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more