mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 13:10:54 +00:00
dd730549df
Currently when one runs `cargo build` twice without changing anything, zed lib and binary are gonna get rebuilt every time. I checked out cargo logs and it turns out we were querying wrong path to `.git/logs/HEAD` in our build.rs, causing it to rerun on every build and thus marking zed lib as dirty. See logs (`CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo build`): ``` 0.501173792s INFO cargo::core::compiler::fingerprint: fingerprint dirty for zed v0.120.0 (/Users/hiro/Projects/zed/crates/zed)/RunCustomBuild/TargetInner { ..: custom_build_target("build-script-build", "/Users/hiro/Projects/zed/crates/zed/build.rs", Edition2021) } 0.501180417s INFO cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(MissingFile("/Users/hiro/Projects/zed/crates/zed/.git/logs/HEAD"))) ``` The path to .git directory is relative to crates/zed and not to the workspace's root. /cc @maxbrunsfeld Release Notes: - N/A
44 lines
1.9 KiB
Rust
44 lines
1.9 KiB
Rust
use std::process::Command;
|
|
|
|
fn main() {
|
|
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
|
|
|
|
println!("cargo:rerun-if-env-changed=ZED_BUNDLE");
|
|
if std::env::var("ZED_BUNDLE").ok().as_deref() == Some("true") {
|
|
// Find WebRTC.framework in the Frameworks folder when running as part of an application bundle.
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../Frameworks");
|
|
} else {
|
|
// Find WebRTC.framework as a sibling of the executable when running outside of an application bundle.
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
|
|
}
|
|
|
|
// Weakly link ReplayKit to ensure Zed can be used on macOS 10.15+.
|
|
println!("cargo:rustc-link-arg=-Wl,-weak_framework,ReplayKit");
|
|
|
|
// Seems to be required to enable Swift concurrency
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
|
|
|
|
// Register exported Objective-C selectors, protocols, etc
|
|
println!("cargo:rustc-link-arg=-Wl,-ObjC");
|
|
|
|
// Populate git sha environment variable if git is available
|
|
println!("cargo:rerun-if-changed=../../.git/logs/HEAD");
|
|
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
|
if output.status.success() {
|
|
let git_sha = String::from_utf8_lossy(&output.stdout);
|
|
let git_sha = git_sha.trim();
|
|
|
|
println!("cargo:rustc-env=ZED_COMMIT_SHA={git_sha}");
|
|
|
|
if let Ok(build_profile) = std::env::var("PROFILE") {
|
|
if build_profile == "release" {
|
|
// This is currently the best way to make `cargo build ...`'s build script
|
|
// to print something to stdout without extra verbosity.
|
|
println!(
|
|
"cargo:warning=Info: using '{git_sha}' hash for ZED_COMMIT_SHA env var"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|