mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Reimplement git version generation ourselves
This allows us to remove two dependency crates
This commit is contained in:
parent
a1e46a94f6
commit
2a4e776d92
4 changed files with 32 additions and 31 deletions
31
Cargo.lock
generated
31
Cargo.lock
generated
|
@ -102,7 +102,6 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"errno",
|
"errno",
|
||||||
"fast-float",
|
"fast-float",
|
||||||
"git-version",
|
|
||||||
"hexponent",
|
"hexponent",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -137,26 +136,6 @@ dependencies = [
|
||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "git-version"
|
|
||||||
version = "0.3.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
|
|
||||||
dependencies = [
|
|
||||||
"git-version-macro",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "git-version-macro"
|
|
||||||
version = "0.3.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.50",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
|
@ -203,9 +182,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.20"
|
version = "0.4.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lru"
|
name = "lru"
|
||||||
|
@ -496,9 +475,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.50"
|
version = "2.0.52"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb"
|
checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -589,5 +568,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.50",
|
"syn 2.0.52",
|
||||||
]
|
]
|
||||||
|
|
|
@ -34,7 +34,6 @@ num-traits = "0.2.15"
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
rand = { version = "0.8.5", features = ["small_rng"] }
|
rand = { version = "0.8.5", features = ["small_rng"] }
|
||||||
widestring = "1.0.2"
|
widestring = "1.0.2"
|
||||||
git-version = "0.3"
|
|
||||||
terminfo = { git = "https://github.com/meh/rust-terminfo", rev = "870327dd79beaecf50db09a15931d5ee1de2a24d" }
|
terminfo = { git = "https://github.com/meh/rust-terminfo", rev = "870327dd79beaecf50db09a15931d5ee1de2a24d" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
26
build.rs
26
build.rs
|
@ -24,6 +24,8 @@ fn main() {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
rsconf::set_env_value("FISH_BUILD_VERSION", &get_version(build_dir));
|
||||||
|
|
||||||
rsconf::rebuild_if_path_changed("src/libc.c");
|
rsconf::rebuild_if_path_changed("src/libc.c");
|
||||||
cc::Build::new()
|
cc::Build::new()
|
||||||
.file("src/libc.c")
|
.file("src/libc.c")
|
||||||
|
@ -193,3 +195,27 @@ fn setup_paths() {
|
||||||
rsconf::set_env_value("DOCDIR", docdir.to_str().unwrap());
|
rsconf::set_env_value("DOCDIR", docdir.to_str().unwrap());
|
||||||
rsconf::rebuild_if_env_changed("DOCDIR");
|
rsconf::rebuild_if_env_changed("DOCDIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_version(build_dir: &str) -> String {
|
||||||
|
use std::fs::read_to_string;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
if let Ok(var) = std::env::var("FISH_BUILD_VERSION") {
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = PathBuf::from(build_dir).join("version");
|
||||||
|
if let Ok(strver) = read_to_string(path) {
|
||||||
|
return strver.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
let args = &["describe", "--always", "--dirty=-dirty"];
|
||||||
|
if let Ok(output) = Command::new("git").args(args).output() {
|
||||||
|
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||||
|
if !rev.is_empty() {
|
||||||
|
return rev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"unknown".to_string()
|
||||||
|
}
|
||||||
|
|
|
@ -22,10 +22,7 @@
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
#![allow(clippy::uninlined_format_args)]
|
#![allow(clippy::uninlined_format_args)]
|
||||||
|
|
||||||
pub const BUILD_VERSION: &str = match option_env!("FISH_BUILD_VERSION") {
|
pub const BUILD_VERSION: &str = env!("FISH_BUILD_VERSION");
|
||||||
Some(v) => v,
|
|
||||||
None => git_version::git_version!(args = ["--always", "--dirty=-dirty"], fallback = "unknown"),
|
|
||||||
};
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
Loading…
Reference in a new issue