1use std::process::Command;
2
3const ZED_MANIFEST: &str = include_str!("../zed/Cargo.toml");
4
5fn main() {
6 let zed_cargo_toml: cargo_toml::Manifest =
7 toml::from_str(ZED_MANIFEST).expect("failed to parse zed Cargo.toml");
8 println!(
9 "cargo:rustc-env=ZED_PKG_VERSION={}",
10 zed_cargo_toml.package.unwrap().version.unwrap()
11 );
12 println!(
13 "cargo:rustc-env=TARGET={}",
14 std::env::var("TARGET").unwrap()
15 );
16
17 // Populate git sha environment variable if git is available
18 println!("cargo:rerun-if-changed=../../.git/logs/HEAD");
19 if let Some(output) = Command::new("git")
20 .args(["rev-parse", "HEAD"])
21 .output()
22 .ok()
23 .filter(|output| output.status.success())
24 {
25 let git_sha = String::from_utf8_lossy(&output.stdout);
26 let git_sha = git_sha.trim();
27
28 println!("cargo:rustc-env=ZED_COMMIT_SHA={git_sha}");
29 }
30}