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
13 // If we're building this for nightly, we want to set the ZED_COMMIT_SHA
14 if let Some(release_channel) = std::env::var("ZED_RELEASE_CHANNEL").ok() {
15 if release_channel.as_str() == "nightly" {
16 // Populate git sha environment variable if git is available
17 println!("cargo:rerun-if-changed=../../.git/logs/HEAD");
18 if let Some(output) = Command::new("git")
19 .args(["rev-parse", "HEAD"])
20 .output()
21 .ok()
22 .filter(|output| output.status.success())
23 {
24 let git_sha = String::from_utf8_lossy(&output.stdout);
25 let git_sha = git_sha.trim();
26
27 println!("cargo:rustc-env=ZED_COMMIT_SHA={git_sha}");
28 }
29 }
30 }
31}