From 80ecb671fd22a2d6c6fa33f731283d5f5e529801 Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Fri, 26 Jun 2026 19:38:13 -0700 Subject: [PATCH] mux: allow build-time version label override (FREEMKV_BUILD_LABEL) build.rs emits FREEMKV_VERSION = FREEMKV_BUILD_LABEL when that env is set (non-empty), else the Cargo package version. The muxing/writing-application field and the FVI generator tag use it, so a pre-release/test build can be stamped without bumping Cargo.toml and disturbing the tag-pinned [patch] version matching. The git short hash is still appended either way. --- build.rs | 12 ++++++++++++ src/mux/mkv.rs | 2 +- src/mux/videomap.rs | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 39f99d6..6398ddc 100644 --- a/build.rs +++ b/build.rs @@ -57,6 +57,18 @@ fn main() { /// leaving just the package version. Always emitted so `env!("GIT_SUFFIX")` /// resolves on every target. fn emit_git_suffix() { + // Version label for the muxing-app / FVI generator tag. `FREEMKV_BUILD_LABEL` + // overrides the Cargo package version when set (non-empty) — used to stamp a + // pre-release/test build without bumping Cargo.toml and disturbing the + // tag-pinned [patch] version matching. Unset → the package version. + let version = std::env::var("FREEMKV_BUILD_LABEL") + .ok() + .filter(|s| !s.trim().is_empty()) + .or_else(|| std::env::var("CARGO_PKG_VERSION").ok()) + .unwrap_or_default(); + println!("cargo:rustc-env=FREEMKV_VERSION={version}"); + println!("cargo:rerun-if-env-changed=FREEMKV_BUILD_LABEL"); + let suffix = git_short_hash() .map(|h| format!(" (g{h})")) .unwrap_or_default(); diff --git a/src/mux/mkv.rs b/src/mux/mkv.rs index ab94811..e1e355a 100644 --- a/src/mux/mkv.rs +++ b/src/mux/mkv.rs @@ -774,7 +774,7 @@ impl MkvMuxer { // Stamp the freemkv version so any muxed file is traceable to the build // that produced it (MediaInfo "Writing application"/"library"). const FREEMKV_MUX_APP: &str = - concat!("freemkv ", env!("CARGO_PKG_VERSION"), env!("GIT_SUFFIX")); + concat!("freemkv ", env!("FREEMKV_VERSION"), env!("GIT_SUFFIX")); ebml::write_string(&mut writer, ebml::MUXING_APP, FREEMKV_MUX_APP)?; ebml::write_string(&mut writer, ebml::WRITING_APP, FREEMKV_MUX_APP)?; if let Some(t) = title { diff --git a/src/mux/videomap.rs b/src/mux/videomap.rs index 8808fbd..5c8de52 100644 --- a/src/mux/videomap.rs +++ b/src/mux/videomap.rs @@ -37,7 +37,7 @@ pub const FVI_VERSION: u32 = 1; /// Producing tool tag for the header `"generator"` member /// (`docs/FVI_FORMAT.md` §6). -pub const FVI_GENERATOR: &str = concat!("freemkv/", env!("CARGO_PKG_VERSION"), env!("GIT_SUFFIX")); +pub const FVI_GENERATOR: &str = concat!("freemkv/", env!("FREEMKV_VERSION"), env!("GIT_SUFFIX")); /// Header `"timescale"` for all `pts`/`dts` ticks (`docs/FVI_FORMAT.md` §10). /// The highway carries presentation timestamps in nanoseconds, so the timescale