build: revise dep graph for version changes

Previously, the config crate would get rebuilt each time the
git state changed, which has a lot of fan out and makes the build
take longer than it really needs to.

This commit breaks out the version changing stuff to its own crate
and then provides a runtime mechanism for assigning the version
information back into the config crate.

The env-bootstrap crate is responsible for setting that up.
This commit is contained in:
Wez Furlong committed 2023-04-08 17:03:03 -07:00
1 parent 4667a4b4be
commit 5e5989f3e2
8 files changed
+52 -17

No files matched your search

Generated
+9 -1
View File
@@ -846,7 +846,6 @@ dependencies = [
"dirs-next",
"enum-display-derive",
"env_logger",
"git2",
"hostname",
"lazy_static",
"libc",
@@ -855,6 +854,7 @@ dependencies = [
"mlua",
"nix 0.26.2",
"notify",
"once_cell",
"ordered-float",
"portable-pty",
"promise",
@@ -1482,6 +1482,7 @@ dependencies = [
"termwiz",
"termwiz-funcs",
"time-funcs",
"wezterm-version",
"winapi",
]
@@ -6256,6 +6257,13 @@ dependencies = [
"zvariant",
]
[[package]]
name = "wezterm-version"
version = "0.1.0"
dependencies = [
"git2",
]
[[package]]
name = "wgpu"
version = "0.15.1"
+1 -4
View File
@@ -3,16 +3,12 @@ name = "config"
version = "0.1.0"
authors = ["Wez Furlong <wez@wezfurlong.org>"]
edition = "2018"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dev-dependencies]
env_logger = "0.10"
[build-dependencies]
git2 = { version = "0.16", default-features = false }
[features]
distro-defaults = []
@@ -30,6 +26,7 @@ luahelper = { path = "../luahelper" }
mlua = {version="0.8.3", features=["vendored", "lua54", "async", "send"]}
# file change notification
notify = "5.0.0"
once_cell = "1.8"
ordered-float = { version = "3.0", features = ["serde"] }
portable-pty = { path = "../pty", features = ["serde_support"]}
promise = { path = "../promise" }
+16 -4
View File
@@ -1,11 +1,23 @@
use once_cell::sync::OnceCell;
static VERSION: OnceCell<&'static str> = OnceCell::new();
static TRIPLE: OnceCell<&'static str> = OnceCell::new();
pub fn assign_version_info(version: &'static str, triple: &'static str) {
VERSION.set(version).unwrap();
TRIPLE.set(triple).unwrap();
}
pub fn wezterm_version() -> &'static str {
// See build.rs
env!("WEZTERM_CI_TAG")
VERSION
.get()
.unwrap_or(&"someone forgot to call assign_version_info")
}
pub fn wezterm_target_triple() -> &'static str {
// See build.rs
env!("WEZTERM_TARGET_TRIPLE")
TRIPLE
.get()
.unwrap_or(&"someone forgot to call assign_version_info")
}
pub fn running_under_wsl() -> bool {
+1
View File
@@ -29,6 +29,7 @@ share-data = { path = "../lua-api-crates/share-data" }
ssh-funcs = { path = "../lua-api-crates/ssh-funcs" }
spawn-funcs = { path = "../lua-api-crates/spawn-funcs" }
time-funcs = { path = "../lua-api-crates/time-funcs" }
wezterm-version = { path = "../wezterm-version" }
[target."cfg(windows)".dependencies]
winapi = "0.3"
+4
View File
@@ -184,6 +184,10 @@ fn register_lua_modules() {
}
pub fn bootstrap() {
config::assign_version_info(
wezterm_version::wezterm_version(),
wezterm_version::wezterm_target_triple(),
);
setup_logger();
register_panic_hook();
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "wezterm-version"
version = "0.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
git2 = { version = "0.16", default-features = false }
[dependencies]
@@ -1,5 +1,3 @@
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
@@ -30,12 +28,7 @@ fn main() {
}
}
}
}
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(&[
"-c",
@@ -57,5 +50,4 @@ fn main() {
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");
}
+9
View File
@@ -0,0 +1,9 @@
pub fn wezterm_version() -> &'static str {
// See build.rs
env!("WEZTERM_CI_TAG")
}
pub fn wezterm_target_triple() -> &'static str {
// See build.rs
env!("WEZTERM_TARGET_TRIPLE")
}