From 57f1aa27852b666e63d71af37893d27bc3c355f3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 17 Mar 2021 21:02:03 -0700 Subject: [PATCH] fixup build to not consider termwiz tags as wezterm tags CI got broken by the termwiz release. This commit teaches the various `git describe --tags` calls to filter to the wezterm tags which all start with the year. We're match `20*` which should be good for the next 79 years. I've removed the vergen dependency as there was no way to teach it to do the equivalent matching, and it wasn't a terrible burden to just inline the git describe call anyway. --- Cargo.lock | 25 ++----------------------- ci/appimage.sh | 2 +- ci/deploy.sh | 2 +- ci/source-archive.sh | 2 +- config/Cargo.toml | 3 --- config/build.rs | 25 ++++++++++++++++++------- config/src/version.rs | 14 ++++---------- 7 files changed, 27 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fadd0499..d9f31b1ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -713,7 +713,6 @@ dependencies = [ "termwiz", "toml", "umask", - "vergen", "wezterm-input-types", "wezterm-term", "winapi 0.3.9", @@ -2565,7 +2564,7 @@ checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" dependencies = [ "lock_api 0.3.4", "parking_lot_core 0.6.2", - "rustc_version 0.2.3", + "rustc_version", ] [[package]] @@ -2588,7 +2587,7 @@ dependencies = [ "cloudabi", "libc", "redox_syscall 0.1.57", - "rustc_version 0.2.3", + "rustc_version", "smallvec 0.6.14", "winapi 0.3.9", ] @@ -3231,15 +3230,6 @@ dependencies = [ "semver 0.9.0", ] -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "rustls" version = "0.19.0" @@ -4066,17 +4056,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[package]] -name = "vergen" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7141e445af09c8919f1d5f8a20dae0b20c3b57a45dee0d5823c6ed5d237f15a" -dependencies = [ - "bitflags", - "chrono", - "rustc_version 0.3.3", -] - [[package]] name = "version_check" version = "0.9.2" diff --git a/ci/appimage.sh b/ci/appimage.sh index b2049d8d7..107734882 100755 --- a/ci/appimage.sh +++ b/ci/appimage.sh @@ -13,7 +13,7 @@ install -Dm644 assets/wezterm.appdata.xml AppDir/usr/share/metainfo/org.wezfurlo [ -x /tmp/linuxdeploy ] || ( curl -L 'https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage' -o /tmp/linuxdeploy && chmod +x /tmp/linuxdeploy ) -TAG_NAME=${TAG_NAME:-$(git describe --tags)} +TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} distro=$(lsb_release -is) distver=$(lsb_release -rs) diff --git a/ci/deploy.sh b/ci/deploy.sh index f47aba355..2500c019d 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -4,7 +4,7 @@ set -e TARGET_DIR=${1:-target} -TAG_NAME=${TAG_NAME:-$(git describe --tags)} +TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} HERE=$(pwd) diff --git a/ci/source-archive.sh b/ci/source-archive.sh index aa16372cb..b1c48441d 100755 --- a/ci/source-archive.sh +++ b/ci/source-archive.sh @@ -3,7 +3,7 @@ set -x -TAG_NAME=${TAG_NAME:-$(git describe --tags)} +TAG_NAME=${TAG_NAME:-$(git describe --tags --match '20*')} TAG_NAME=${TAG_NAME:-$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)} if [[ "$BUILD_REASON" == "Schedule" ]] ; then diff --git a/config/Cargo.toml b/config/Cargo.toml index 7f4110528..05e07bd16 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -7,9 +7,6 @@ build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[build-dependencies] -vergen = "3" - [dev-dependencies] pretty_env_logger = "0.4" diff --git a/config/build.rs b/config/build.rs index eb657347b..fe968b67a 100644 --- a/config/build.rs +++ b/config/build.rs @@ -1,5 +1,4 @@ use std::path::Path; -use vergen::{generate_cargo_keys, ConstantsFlags}; fn bake_color_schemes() { let dir = std::fs::read_dir("../assets/colors").unwrap(); @@ -45,12 +44,6 @@ fn bake_color_schemes() { fn main() { println!("cargo:rerun-if-changed=build.rs"); - let mut flags = ConstantsFlags::all(); - flags.remove(ConstantsFlags::SEMVER_FROM_CARGO_PKG); - - // Generate the 'cargo:' key output - generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!"); - bake_color_schemes(); // If a file named `.tag` is present, we'll take its contents for the @@ -61,7 +54,25 @@ fn main() { ci_tag = s.trim().to_string(); println!("cargo:rerun-if-changed=../.tag"); } + } else { + // Otherwise we'll derive it from the git information + let head = Path::new("../.git/HEAD"); + if head.exists() { + let head = head.canonicalize().unwrap(); + println!("cargo:rerun-if-changed={}", head.display()); + if let Ok(output) = std::process::Command::new("git") + .args(&["describe", "--tags", "--match", "20*"]) + .output() + { + let info = String::from_utf8_lossy(&output.stdout); + ci_tag = info.trim().to_string(); + } + } } + + let target = std::env::var("TARGET").unwrap_or("unknown".to_string()); + + println!("cargo:rustc-env=WEZTERM_TARGET_TRIPLE={}", target); println!("cargo:rustc-env=WEZTERM_CI_TAG={}", ci_tag); println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.9"); } diff --git a/config/src/version.rs b/config/src/version.rs index a756e1e98..aa672f229 100644 --- a/config/src/version.rs +++ b/config/src/version.rs @@ -1,17 +1,11 @@ pub fn wezterm_version() -> &'static str { - // Prefer our version override, if present (see build.rs) - let tag = env!("WEZTERM_CI_TAG"); - if tag.is_empty() { - // Otherwise, fallback to the vergen-generated information, - // which is basically `git describe --tags` computed in build.rs - env!("VERGEN_SEMVER_LIGHTWEIGHT") - } else { - tag - } + // See build.rs + env!("WEZTERM_CI_TAG") } pub fn wezterm_target_triple() -> &'static str { - env!("VERGEN_TARGET_TRIPLE") + // See build.rs + env!("WEZTERM_TARGET_TRIPLE") } pub fn running_under_wsl() -> bool {