Skip to content

Commit

Permalink
Merge pull request #126 from martinling/build-info
Browse files Browse the repository at this point in the history
Gather more build information and improve version string
  • Loading branch information
martinling committed Jul 13, 2024
2 parents 1c4d9c2 + c5a8d7c commit ae82994
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 32 deletions.
187 changes: 170 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository = "https://github.com/greatscottgadgets/packetry"
documentation = "https://packetry.readthedocs.io"
edition = "2021"
rust-version = "1.74"
build = "src/build.rs"

include = [
"CHANGELOG.md",
Expand All @@ -21,7 +22,8 @@ include = [
"tests/**/*",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
built = { version = "0.7.4", features = ["cargo-lock", "git2"] }

[dependencies]
bytemuck = "1.14.1"
Expand All @@ -47,7 +49,6 @@ lrumap = "0.1.0"
memmap2 = "0.9.4"
page_size = "0.6.0"
anyhow = { version = "1.0.79", features = ["backtrace"] }
git-version = "0.3.9"

[dev-dependencies]
serde = { version = "1.0.196", features = ["derive"] }
Expand Down
3 changes: 3 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ extern crate bitfield;
#[macro_use]
extern crate ctor;

// Include build-time info.
pub mod built {
// The file has been placed there by the build script.
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

// Declare all modules used.
mod backend;
mod capture;
Expand All @@ -31,6 +37,7 @@ mod ui;
mod usb;
mod util;
mod vec_map;
mod version;

// Declare optional modules.
#[cfg(any(test, feature="record-ui-test"))]
Expand All @@ -46,14 +53,17 @@ use ui::{
display_error,
stop_cynthion
};
use version::{version, version_info};

fn have_argument(name: &str) -> bool {
std::env::args().any(|arg| arg == name)
}

fn main() {
if have_argument("--version") {
println!("Packetry version {}", git_version::git_version!())
println!("Packetry version {}\n\n{}",
version(),
version_info(have_argument("--dependencies")));
} else if have_argument("--test-cynthion") {
let save_captures = have_argument("--save-captures");
test_cynthion::run_test(save_captures);
Expand All @@ -67,4 +77,3 @@ fn main() {
display_error(stop_cynthion());
}
}

Loading

0 comments on commit ae82994

Please sign in to comment.