Skip to content
Open
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
203 changes: 203 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ description = "cargo subcommand to build hyperlight guest binaries"

[dependencies]
anyhow = "1.0"
clap = { version = "4", features = ["derive"] }
console = "0.16"
const_format = "0.2"
glob = "0.3"
libc = "0.2"
object = { version = "0.36", default-features = false, features = ["read", "elf"] }
os_str_bytes = "7.1.1"
regex = "1.12"
rustc-demangle = "0.1"
semver = { version = "1.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tempfile = "3"
which = { version = "8", features = ["regex"] }
40 changes: 24 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@ use std::env;

use cargo_hyperlight::cargo;

mod perf;

const VERSION: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH");
const GIT_DATE: &str = env!("GIT_DATE");

fn main() {
if env::args().any(|arg| arg == "--version" || arg == "-V") {
println!("cargo-hyperlight {} ({} {})", VERSION, GIT_HASH, GIT_DATE);
return;
// Skip binary name; when invoked as `cargo hyperlight`, cargo passes
// "hyperlight" as argv[1] — skip that too.
let mut args = env::args_os().skip(1).peekable();
if args.peek().is_some_and(|a| a == "hyperlight") {
args.next();
}

let args = env::args_os().enumerate().filter_map(|(i, arg)| {
// skip the binary name and the "hyperlight" subcommand if present
if i == 0 || (i == 1 && arg == "hyperlight") {
None
} else {
Some(arg)
match args.peek().map(|a| a.to_os_string()) {
Some(a) if a == "--version" || a == "-V" => {
println!("cargo-hyperlight {} ({} {})", VERSION, GIT_HASH, GIT_DATE);
}
});

cargo()
.expect("Failed to create cargo command")
.args(args)
.status()
.expect("Failed to execute cargo")
Some(a) if a == "perf" => {
if let Err(e) = perf::run(args) {
eprintln!("{e:?}");
std::process::exit(1);
}
}
_ => {
cargo()
.expect("Failed to create cargo command")
.args(args)
.status()
.expect("Failed to execute cargo");
}
}
}
Loading
Loading