diff --git a/Cargo.toml b/Cargo.toml index 4195127..bc3352b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ edition = "2024" rust-version = "1.99" # What `cargo install` needs to build; tests, fixtures, benches and docs stay # in the repository. -include = ["/src", "/build.rs", "/README.md", "/LICENSE-MIT", "/LICENSE-APACHE"] +include = ["/src", "/README.md", "/LICENSE-MIT", "/LICENSE-APACHE"] [lints.rust] unsafe_code = "forbid" diff --git a/build.rs b/build.rs deleted file mode 100644 index 532c6eb..0000000 --- a/build.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![expect(missing_docs, reason = "build scripts are not a public API")] - -use std::path::Path; -use std::process::Command; - -// A crates.io build has no `.git`, and a rerun-if-changed path that does not -// exist reruns the script on every build. A worktree's `.git` is a file, so -// git names the real HEAD and refs. -fn main() { - let sha = if Path::new(".git").exists() { - for name in ["HEAD", "refs"] { - if let Some(path) = git(&["rev-parse", "--git-path", name]) { - println!("cargo::rerun-if-changed={path}"); - } - } - built_from() - } else { - println!("cargo::rerun-if-changed=build.rs"); - "unknown".to_owned() - }; - println!("cargo::rustc-env=DATASEEK_GIT_SHA={sha}"); -} - -fn built_from() -> String { - let Some(sha) = git(&["rev-parse", "--short", "HEAD"]) else { - return "unknown".to_owned(); - }; - match git(&["status", "--porcelain"]) { - Some(changes) if !changes.is_empty() => format!("{sha}-dirty"), - _ => sha, - } -} - -fn git(args: &[&str]) -> Option { - let out = Command::new("git").args(args).output().ok()?; - out.status - .success() - .then(|| String::from_utf8(out.stdout).ok()) - .flatten() - .map(|s| s.trim().to_owned()) -}