From 44afbd7697a80a215d8cf597241d5071c01ce785 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 12 Sep 2022 13:12:18 +0800 Subject: [PATCH] fix issue where large lists of apps break signing key specifier mechanism now to specify a signing key you add it after a "--" which delimits the list of apps --- xtask/src/main.rs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 676b45406..1af13c329 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -43,7 +43,15 @@ impl std::error::Error for BuildError {} fn get_packages() -> Vec { let mut args = env::args(); args.nth(1); - args.filter(|x| !x.starts_with("-")).collect() + // skip everything past -- + let mut pkgs = Vec::::new(); + for arg in args { + if arg == "--" { + break; + } + pkgs.push(arg); + } + pkgs.into_iter().filter(|x| !x.starts_with("-")).collect() } fn main() -> Result<(), Box> { @@ -172,8 +180,28 @@ fn main() -> Result<(), Box> { let aestest_pkgs = ["ticktimer-server", "log-server", "aes-test"]; let mut args = env::args(); let task = args.nth(1); - let lkey = args.nth(3); - let kkey = args.nth(4); + // extract lkey/kkey args only after a "--" separator + let mut next_is_lkey = false; + let mut next_is_kkey = false; + let mut lkey: Option = None; + let mut kkey: Option = None; + for arg in args { + if next_is_kkey { + kkey = Some(arg); + next_is_kkey = false; + continue; + } + if next_is_lkey { + lkey = Some(arg); + next_is_lkey = false; + next_is_kkey = true; + continue; + } + if arg == "--" { + next_is_lkey = true; + continue; + } + } match task.as_deref() { Some("install-toolkit") | Some("install-toolchain") => { let arg = env::args().nth(2); @@ -726,7 +754,7 @@ fn print_help() { "Tasks: Hardware images: hw-image [soc.svd] builds an image for real hardware with baseline demo apps - [loader.key] plus signing key options + -- [loader.key] plus signing key options [kernel.key] app-image [app1] [..] builds an image for real hardware of baseline kernel + specified apps perf-image [app1] [..] builds an image for real hardware assuming a performance counter variant of the SOC.