Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/buildomat/jobs/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ ptime -m ./tools/install_builder_prerequisites.sh -y

banner build

# We collect some build envrionment information with vergen to augment
# development builds, but this would otherwise put extra build-env info into
# the production (and test) binaries built here. While we don't test or rely on
# deterministic rebuilds of propolis-server, set Vergen up to use idempotent
# environment variables so we're not needlessly introducing build-time
# variance.
#
# "idempotent" still lets us collect the current relevant git info, so CI
# builds of propolis-server will still be able to self-report what commit they
# came from. See
# https://docs.rs/vergen/10.0.3/vergen/struct.Emitter.html#method.idempotent
# for more.
export VERGEN_IDEMPOTENT="true"

# Enable the "omicron-build" feature to indicate this is an artifact destined
# for production use on an appropriately configured Oxide machine
#
Expand Down
4 changes: 4 additions & 0 deletions .github/buildomat/jobs/phd-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ ptime -m ./tools/install_builder_prerequisites.sh -y
# should fire during tests.
banner build-propolis

# The same reasoning as in `image.sh` applies here, where we'd prefer more
# deterministic CI builds over less deterministic.
export VERGEN_IDEMPOTENT="true"

# We'll do a few cargo builds, keeping features the same means we reuse build
# artifacts from crates these configure.
TEST_FEATURES="omicron-build,failure-injection"
Expand Down
27 changes: 23 additions & 4 deletions lib/propolis/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,29 @@ fn main() -> anyhow::Result<()> {
.dirty(true)
.sha(true)
.build();
vergen_git2::Emitter::default()
.idempotent()
.add_instructions(&git2)?
.emit()?;
vergen_git2::Emitter::default().add_instructions(&git2)?.emit()?;
// Apologies for the broad rerun-if-changed, but stick with me: build.rs
// *must* rerun when source files are changed so that a version string's
// VERGEN_GIT_DIRTY is accurate. If we only rerun-on-changed for changes in
// the bin crates, that almost works, but means a source-only change in
// a crate in this tree that a bin depends on directly (say,
// propolis-api-types) wouldn't cause this build.rs to re-evaluate and get
// the right dirty bit in the version string.
//
// We could do the VERGEN_GIT_DIRTY work in the binary crates too, and plumb
// that back to propolis-lib version's string, but we'd want that to be
// broad to cover crates too. This takes the other approach: rerun
// propolis-lib build.rs if any files here have changed, which will cause
// propolis dependents to rebuild, and get updated version strings. This
// comes at the cost of recompiling the propolis-lib crate more often than
// strictly necessary during development, but that crate on its own is
// *much* faster to build than any of the bins being linked afterwards!
//
// This also means we can keep all of the versioning fiddliness here instead
// of subjecting every (e.g. both) user to thinking about this stuff.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every (e.g. both)

okay, this bit got me, good show!

println!("cargo:rerun-if-changed=../lib");
println!("cargo:rerun-if-changed=../bin");
println!("cargo:rerun-if-changed=../crates");

Ok(())
}
Loading