Skip to content

Commit d45edbc

Browse files
committed
add perf kvm support
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 8f21b64 commit d45edbc

File tree

4 files changed

+859
-16
lines changed

4 files changed

+859
-16
lines changed

Cargo.lock

Lines changed: 203 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
@@ -10,13 +10,17 @@ description = "cargo subcommand to build hyperlight guest binaries"
1010

1111
[dependencies]
1212
anyhow = "1.0"
13+
clap = { version = "4", features = ["derive"] }
1314
console = "0.16"
1415
const_format = "0.2"
1516
glob = "0.3"
1617
libc = "0.2"
18+
object = { version = "0.36", default-features = false, features = ["read", "elf"] }
1719
os_str_bytes = "7.1.1"
1820
regex = "1.12"
21+
rustc-demangle = "0.1"
1922
semver = { version = "1.0", features = ["serde"] }
2023
serde = { version = "1.0", features = ["derive"] }
2124
serde_json = "1.0"
25+
tempfile = "3"
2226
which = { version = "8", features = ["regex"] }

src/main.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@ use std::env;
22

33
use cargo_hyperlight::cargo;
44

5+
mod perf;
6+
57
const VERSION: &str = env!("CARGO_PKG_VERSION");
68
const GIT_HASH: &str = env!("GIT_HASH");
79
const GIT_DATE: &str = env!("GIT_DATE");
810

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

15-
let args = env::args_os().enumerate().filter_map(|(i, arg)| {
16-
// skip the binary name and the "hyperlight" subcommand if present
17-
if i == 0 || (i == 1 && arg == "hyperlight") {
18-
None
19-
} else {
20-
Some(arg)
19+
match args.peek().map(|a| a.to_os_string()) {
20+
Some(a) if a == "--version" || a == "-V" => {
21+
println!("cargo-hyperlight {} ({} {})", VERSION, GIT_HASH, GIT_DATE);
2122
}
22-
});
23-
24-
cargo()
25-
.expect("Failed to create cargo command")
26-
.args(args)
27-
.status()
28-
.expect("Failed to execute cargo")
23+
Some(a) if a == "perf" => {
24+
if let Err(e) = perf::run(args) {
25+
eprintln!("{e:?}");
26+
std::process::exit(1);
27+
}
28+
}
29+
_ => {
30+
cargo()
31+
.expect("Failed to create cargo command")
32+
.args(args)
33+
.status()
34+
.expect("Failed to execute cargo");
35+
}
36+
}
2937
}

0 commit comments

Comments
 (0)