Revert "feat: add build sha to parser.c header comment" (#4475)
This reverts commitdc4e232e6e. Reason: The sha in the generated output (which most distro builds of tree-sitter, including `cargo install`, strip) produces too many conflicts when verifying via CI that parsers are regenerated on every grammar change. (cherry picked from commite7f9160867)
This commit is contained in:
parent
4cac30b54a
commit
baf222f772
3 changed files with 1 additions and 40 deletions
|
|
@ -60,8 +60,6 @@ fn web_playground_files_present() -> bool {
|
|||
paths.iter().all(|p| Path::new(p).exists())
|
||||
}
|
||||
|
||||
// When updating this function, don't forget to also update generate/build.rs which has a
|
||||
// near-identical function.
|
||||
fn read_git_sha() -> Option<String> {
|
||||
let crate_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
use std::{env, path::PathBuf, process::Command};
|
||||
|
||||
fn main() {
|
||||
if let Some(git_sha) = read_git_sha() {
|
||||
println!("cargo:rustc-env=BUILD_SHA={git_sha}");
|
||||
}
|
||||
}
|
||||
|
||||
// This is copied from the build.rs in parent directory. This should be updated if the
|
||||
// parent build.rs gets fixes.
|
||||
fn read_git_sha() -> Option<String> {
|
||||
let crate_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
|
||||
if !crate_path
|
||||
.parent()?
|
||||
.parent()
|
||||
.is_some_and(|p| p.join(".git").exists())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.current_dir(crate_path)
|
||||
.output()
|
||||
.map_or(None, |output| {
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
Some(String::from_utf8_lossy(&output.stdout).to_string())
|
||||
})
|
||||
}
|
||||
|
|
@ -24,7 +24,6 @@ pub const ABI_VERSION_MIN: usize = 14;
|
|||
pub const ABI_VERSION_MAX: usize = tree_sitter::LANGUAGE_VERSION;
|
||||
const ABI_VERSION_WITH_RESERVED_WORDS: usize = 15;
|
||||
const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const BUILD_SHA: Option<&'static str> = option_env!("BUILD_SHA");
|
||||
|
||||
macro_rules! add {
|
||||
($this: tt, $($arg: tt)*) => {{
|
||||
|
|
@ -322,13 +321,9 @@ impl Generator {
|
|||
}
|
||||
|
||||
fn add_header(&mut self) {
|
||||
let version = BUILD_SHA.map_or_else(
|
||||
|| BUILD_VERSION.to_string(),
|
||||
|build_sha| format!("{BUILD_VERSION} ({build_sha})"),
|
||||
);
|
||||
add_line!(
|
||||
self,
|
||||
"/* Automatically @generated by tree-sitter v{version} */",
|
||||
"/* Automatically @generated by tree-sitter v{BUILD_VERSION} */",
|
||||
);
|
||||
add_line!(self, "");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue