From 1d672b4ff80c78ed5a1c394c1bbaa6d389b2790e Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Fri, 12 Apr 2024 22:40:10 +0800 Subject: [PATCH] feat: support features selection in xtask --- kernel/Cargo.toml | 6 +++--- xtask/src/artifact.rs | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index d37112d..9ac2d44 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["riscv.board.virt"] +default = ["riscv.board.virt", "riscv.riscv64"] legacy = ["utils/legacy", "vspace/legacy"] @@ -20,8 +20,8 @@ riscv = [] "riscv.riscv64" = ["riscv", "riscv.pagetable.sv39"] "riscv.riscv32" = ["riscv", "riscv.pagetable.sv32", "legacy"] -"riscv.board.default" = ["riscv.riscv64"] -"riscv.board.virt" = ["riscv.riscv64"] +"riscv.board.default" = [] +"riscv.board.virt" = [] [dependencies] allocator = { path = "../lib/allocator" } diff --git a/xtask/src/artifact.rs b/xtask/src/artifact.rs index 1dad957..8ab2e12 100644 --- a/xtask/src/artifact.rs +++ b/xtask/src/artifact.rs @@ -88,22 +88,28 @@ pub struct Artifact { impl Artifact { pub fn cargo_args(&self) -> Result> { let mut args: Vec = Vec::new(); + let mut features: Vec = Vec::new(); // profile if let Some(Profile::Release) = self.profile { args.push("--release".to_string()); } - // board - if let Some(board) = self.board { - args.push("--no-default-features".to_string()); - args.push("--features".to_string()); - args.push(board.cargo_args(&self.arch)?); - } - // arch args.extend(self.arch.cargo_args().iter().map(|s| s.to_string())); + // board + if let Some(board) = self.board { + features.push(board.cargo_args(&self.arch)?); + } + + // features + features.extend(self.features.iter().map(|s| s.to_string())); + if !features.is_empty() { + args.push("--no-default-features".to_string()); + args.push(format!("--features={}", features.join(","))); + } + Ok(args) }