xtask: simplify lists

This commit is contained in:
eupn 2024-03-31 21:31:02 +04:00
parent 698cc497c9
commit 12ef383353
No known key found for this signature in database
GPG key ID: 6A550BE33BE768A9
3 changed files with 41 additions and 41 deletions

View file

@ -350,9 +350,9 @@ impl Builder {
}
/// Add a list of services
pub fn add_services<'a>(&'a mut self, service_list: &Vec<String>) -> &'a mut Builder {
pub fn add_services<S: AsRef<str>>(&mut self, service_list: impl IntoIterator<Item = S>) -> &mut Builder {
for service in service_list {
self.services.push(service.as_str().into());
self.services.push(service.as_ref().into());
}
self
}
@ -367,9 +367,9 @@ impl Builder {
}
/// Add a list of apps. Apps can be remote or downloaded externally.
pub fn add_apps<'a>(&'a mut self, app_list: &Vec<String>) -> &'a mut Builder {
pub fn add_apps<S: AsRef<str>>(&mut self, app_list: impl IntoIterator<Item = S>) -> &mut Builder {
for app in app_list {
self.apps.push(app.as_str().into());
self.apps.push(app.as_ref().into());
}
self
}
@ -415,11 +415,11 @@ impl Builder {
fn builder(
&self,
packages: &Vec<CrateSpec>,
features: &Vec<String>,
features: &[String],
target: &Option<&str>,
// the stream is specified separately here because the loader is special-case always release
stream: BuildStream,
extra_args: &Vec<String>,
extra_args: &[String],
no_default_features: bool,
) -> Result<Vec<String>, DynError> {
// list of build artifacts, as full paths specific to the host OS
@ -795,7 +795,7 @@ impl Builder {
if self.run_svd2repl {
Command::new(cargo())
.current_dir(project_root())
.args(&[
.args([
"run",
"-p",
"svd2repl",
@ -836,7 +836,7 @@ impl Builder {
loader_presign.push("loader_presign.bin");
let status = Command::new(cargo())
.current_dir(project_root())
.args(&[
.args([
"run",
"--package",
"tools",
@ -853,7 +853,7 @@ impl Builder {
let status = Command::new(cargo())
.current_dir(project_root())
.args(&[
.args([
"run",
"--package",
"tools",
@ -879,7 +879,7 @@ impl Builder {
let status = Command::new(cargo())
.current_dir(project_root())
.args(&[
.args([
"run",
"--package",
"tools",

View file

@ -177,33 +177,33 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("renode-image") => {
builder
.target_renode()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_apps(&get_cratespecs());
}
Some("renode-image-debug") => {
builder
.target_renode()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.stream(BuildStream::Debug)
.add_apps(&get_cratespecs());
}
Some("renode-test") => {
builder
.target_renode()
.add_services(&base_pkgs.into_iter().map(String::from).collect())
.add_services(&base_pkgs)
.add_services(&get_cratespecs());
}
Some("libstd-test") => {
builder
.target_renode()
.add_services(&base_pkgs.into_iter().map(String::from).collect())
.add_services(&base_pkgs)
.add_services(&get_cratespecs());
builder.add_loader_feature("renode-bypass");
}
Some("libstd-net") => {
builder
.target_renode()
.add_services(&base_pkgs.into_iter().map(String::from).collect())
.add_services(&base_pkgs)
.add_services(&get_cratespecs());
builder.add_loader_feature("renode-bypass").add_loader_feature("renode-minimal");
builder
@ -215,13 +215,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("renode-aes-test") => {
builder
.target_renode()
.add_services(&aes_test_pkgs.into_iter().map(String::from).collect())
.add_services(&aes_test_pkgs)
.add_services(&get_cratespecs());
}
Some("ffi-test") => {
builder
.target_renode()
.add_services(&gfx_base_pkgs.into_iter().map(String::from).collect())
.add_services(&gfx_base_pkgs)
.add_services(&get_cratespecs());
builder.add_service("ffi-test", false);
builder.add_loader_feature("renode-bypass");
@ -231,7 +231,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("run") => {
builder
.target_hosted()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("pddbtest")
.add_feature("ditherpunk")
.add_feature("tracking-alloc")
@ -242,14 +242,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("pddb-ci") => {
builder
.target_hosted()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("pddb/ci")
.add_feature("pddb/deterministic");
}
Some("pddb-btest") => {
builder
.target_hosted()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("pddbtest")
.add_feature("autobasis") // this will make secret basis tracking synthetic and automated for stress testing
.add_feature("autobasis-ci")
@ -258,7 +258,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("hosted-debug") => {
builder
.target_hosted()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("pddbtest")
.add_feature("ditherpunk")
.add_feature("tracking-alloc")
@ -269,14 +269,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("gfx-dev") => {
builder
.target_hosted()
.add_services(&gfx_base_pkgs.into_iter().map(String::from).collect())
.add_services(&gfx_base_pkgs)
.add_services(&get_cratespecs())
.add_feature("graphics-server/gfx-testing");
}
Some("hosted-ci") => {
builder
.target_hosted()
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.hosted_build_only()
.add_apps(&get_cratespecs());
}
@ -285,14 +285,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("app-image") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("mass-storage") // add this in by default to help with testing
.add_apps(&get_cratespecs());
}
Some("app-image-xip") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
//.add_services(&user_pkgs.into_iter().map(String::from).collect())
//.add_services(&user_pkgs)
.add_feature("mass-storage"); // add this in by default to help with testing
for service in user_pkgs {
if (service != "shellchat") && (service != "ime-plugin-shell" && (service != "net")) {
@ -322,7 +322,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// by the usb_update script.
builder
.target_precursor("c809403-perflib")
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_apps(&get_cratespecs())
.add_feature("perfcounter")
.add_kernel_feature("v2p");
@ -350,7 +350,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
pkgs.push("ime-plugin-tts");
pkgs.retain(|&pkg| pkg != "ime-plugin-shell");
builder.add_services(&pkgs.into_iter().map(String::from).collect())
builder.add_services(&pkgs)
.add_apps(&get_cratespecs())
.add_service("espeak-embedded#https://ci.betrusted.io/job/espeak-embedded/lastSuccessfulBuild/artifact/target/riscv32imac-unknown-xous-elf/release/espeak-embedded", false)
.override_locale("en-tts")
@ -360,13 +360,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("tiny") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&base_pkgs.into_iter().map(String::from).collect())
.add_services(&base_pkgs)
.add_services(&get_cratespecs());
}
Some("usbdev") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&base_pkgs.into_iter().map(String::from).collect())
.add_services(&base_pkgs)
.add_services(&get_cratespecs());
//builder.add_service("usb-test");
builder.add_service("usb-device-xous", false);
@ -374,31 +374,31 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("pddb-dev") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&pddb_dev_pkgs.into_iter().map(String::from).collect())
.add_services(&pddb_dev_pkgs)
.add_services(&get_cratespecs());
}
Some("trng-test") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("urandomtest");
}
Some("ro-test") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("ringosctest");
}
Some("av-test") => {
builder
.target_precursor(PRECURSOR_SOC_VERSION)
.add_services(&user_pkgs.into_iter().map(String::from).collect())
.add_services(&user_pkgs)
.add_feature("avalanchetest");
}
Some("compile-apps") => {
builder
.target_precursor_no_image(PRECURSOR_SOC_VERSION)
.add_services(&gfx_base_pkgs.into_iter().map(String::from).collect());
.add_services(&gfx_base_pkgs);
}
// ------ Cramium hardware image configs ------
@ -423,11 +423,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some("arm-tiny") => {
builder
.target_arm()
.add_services(&vec![
"xous-log".to_string(),
"xous-ticktimer".to_string(),
"xous-names".to_string(),
"ticktimer-test-client".to_string(),
.add_services([
"xous-log",
"xous-ticktimer",
"xous-names",
"ticktimer-test-client",
])
.add_kernel_feature("v2p") // required to use LCD DMA with lcd-console
.add_feature("atsama5d27")

View file

@ -145,7 +145,7 @@ pub(crate) fn ensure_kernel_compiler(target: &Option<&str>, force_install: bool)
let rustup_command = Command::new("rustup")
.stderr(Stdio::null())
.stdout(Stdio::piped())
.args(&["target", "add", target])
.args(["target", "add", target])
.spawn()
.map_err(|e| format!("could not run rustup: {}", e))?;
@ -377,7 +377,7 @@ pub(crate) fn wycheproof_import() -> Result<(), crate::DynError> {
let output_file = "services/shellchat/src/cmds/x25519_test.bin";
let status = Command::new(cargo())
.current_dir(project_root())
.args(&["run", "--package", "wycheproof-import", "--", input_file, output_file])
.args(["run", "--package", "wycheproof-import", "--", input_file, output_file])
.status()?;
if !status.success() {
return Err("wycheproof-import failed. If any, the output will not be usable.".into());