feat: add build sha to parser.c header comment

This commit is contained in:
dundargoc 2024-10-24 12:44:37 +02:00 committed by dundargoc
parent 74481399df
commit dc4e232e6e
3 changed files with 41 additions and 2 deletions

View file

@ -19,8 +19,9 @@ use super::{
const SMALL_STATE_THRESHOLD: usize = 64;
const ABI_VERSION_MIN: usize = 14;
const ABI_VERSION_MAX: usize = tree_sitter::LANGUAGE_VERSION;
const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION");
const ABI_VERSION_WITH_METADATA: 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)*) => {{
@ -280,9 +281,13 @@ 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{BUILD_VERSION}"
"/* Automatically generated by tree-sitter v{version} */",
);
add_line!(self, "");
}