Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gather more build information and improve version string #126

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading