Skip to content

Commit d82343a

Browse files
authored
feat: implement vergen crate for git-based versioning (#21)
- Add vergen build dependency with git and gitcl features - Create build.rs to emit VERGEN_GIT_SHA and VERGEN_GIT_COMMIT_DATE - Update version output to use short SHA and date (e.g., bbl_parser 14be1ee (2025-12-04)) - Use CARGO_PKG_NAME macro for package name consistency - Remove hardcoded semantic version references from documentation - Update .gitignore to whitelist build.rs - Version now reflects actual git commit info at build time
1 parent 14be1ee commit d82343a

7 files changed

Lines changed: 119 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
!OVERVIEW.md
77
!GOALS.md
88
!FRAMES.md
9+
!build.rs
910
!Cargo.*
1011
!.gitignore
1112
!LICENSE

Cargo.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ keywords = ["betaflight", "blackbox", "drone", "flight-log", "parser"]
99
categories = ["parsing", "aerospace"]
1010
rust-version = "1.70.0"
1111

12+
[build-dependencies]
13+
anyhow = "1.0"
14+
vergen = { version = "8", features = ["git", "gitcl"] }
15+
1216
[dependencies]
1317
anyhow = "1.0"
1418
clap = { version = "4.0", features = ["derive"], optional = true }

OVERVIEW.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# BBL Parser v0.9.0 - Project Overview
1+
# BBL Parser - Project Overview
22

33
**Project Status:** 🚧 **WORK IN PROGRESS**
4-
**Version:** 0.9.0
54
**Focus:** High-Performance BBL Processing
65
**⚠️ Not Production Ready**
76

@@ -281,9 +280,3 @@ Exported event data to: BTFL_BLACKBOX_LOG_20250601_121852.event
281280
- **Performance** adequate but not optimized
282281
- **Error handling** basic with room for improvement
283282
- **API stability** documented with migration notes
284-
285-
---
286-
287-
**Current Focus:** Core functionality development and testing
288-
**Version:** 0.9.0 🚧 Work-in-Progress
289-
**⚠️ Not recommended for production use**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# BBL Parser (Work-in-Progress)
1+
# BBL Parser
22

33
A fast, pure-Rust Blackbox Log parser primarily used as a command-line tool, with an optional Rust crate API.
44

build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use anyhow::Result;
2+
use vergen::EmitBuilder;
3+
4+
fn main() -> Result<()> {
5+
EmitBuilder::builder()
6+
.git_sha(true)
7+
.git_commit_date()
8+
.emit()?;
9+
Ok(())
10+
}

src/main.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ use bbl_parser::types::{FrameDefinition, FrameStats};
2727
// Import ExportOptions from crate library
2828
use bbl_parser::ExportOptions;
2929

30+
// Include vergen generated environment variables
31+
const GIT_SHA: &str = env!("VERGEN_GIT_SHA", "unknown");
32+
const GIT_COMMIT_DATE: &str = env!("VERGEN_GIT_COMMIT_DATE", "unknown");
33+
34+
// Build version string from git info
35+
const VERSION_STR: &str = concat!(
36+
env!("VERGEN_GIT_SHA", "unknown"),
37+
" (",
38+
env!("VERGEN_GIT_COMMIT_DATE", "unknown"),
39+
")"
40+
);
41+
3042
/// Maximum recursion depth to prevent stack overflow
3143
const MAX_RECURSION_DEPTH: usize = 100;
3244

@@ -326,9 +338,14 @@ impl CsvFieldMap {
326338
}
327339

328340
fn build_command() -> Command {
329-
Command::new("BBL Parser")
330-
.version(env!("CARGO_PKG_VERSION"))
331-
.about("Read and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON).")
341+
let about_text = format!(
342+
"\n\nRead and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON).\n {} {} ({})",
343+
env!("CARGO_PKG_NAME"), GIT_SHA, GIT_COMMIT_DATE
344+
);
345+
346+
Command::new(env!("CARGO_PKG_NAME"))
347+
.version(VERSION_STR)
348+
.about(about_text)
332349
.arg(
333350
Arg::new("files")
334351
.help("BBL files or directories to parse. Direct file paths: .BBL, .BFL, .TXT extensions supported. Directories: recursively finds .BBL/.BFL files only (TXT files must be specified directly). Case-insensitive, supports globbing.")

0 commit comments

Comments
 (0)