mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
18 lines
524 B
Rust
18 lines
524 B
Rust
use std::process::Command;
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-env-changed=TYPST_VERSION");
|
|
if option_env!("TYPST_VERSION").is_some() {
|
|
return;
|
|
}
|
|
|
|
let version = Command::new("git")
|
|
.args(["rev-parse", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.filter(|output| output.status.success())
|
|
.and_then(|output| String::from_utf8(output.stdout.get(..8)?.into()).ok())
|
|
.unwrap_or_else(|| "(unknown version)".into());
|
|
println!("cargo:rustc-env=TYPST_VERSION={version}");
|
|
}
|