summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-11-05 22:05:02 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-11-05 22:05:02 +0100
commit55449131fe9f0de0786d8c743ee0a353b7a12122 (patch)
tree95a024a99089195618d6727214c2d4a9cc95771a
parentbfaaa8b0fac53430af28956c231985c181ef302f (diff)
downloadrebel-55449131fe9f0de0786d8c743ee0a353b7a12122.tar
rebel-55449131fe9f0de0786d8c743ee0a353b7a12122.zip
driver: context: remove separate rootfs_tasks
The rootfs tasks can now just be added to the regular task map.
-rw-r--r--crates/driver/src/context.rs47
1 files changed, 15 insertions, 32 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs
index 5564c86..3953f54 100644
--- a/crates/driver/src/context.rs
+++ b/crates/driver/src/context.rs
@@ -140,11 +140,10 @@ pub struct Context {
globals: TaskArgs,
tasks: HashMap<TaskID, Vec<TaskDef>>,
rootfs: (ArchiveHash, String),
- rootfs_tasks: HashMap<TaskID, TaskDef>,
}
impl Context {
- pub fn new(tasks: HashMap<TaskID, Vec<TaskDef>>, pins: Pins) -> error::Result<Self> {
+ pub fn new(mut tasks: HashMap<TaskID, Vec<TaskDef>>, pins: Pins) -> error::Result<Self> {
let platforms: HashMap<_, _> = [
arg(
"build",
@@ -176,14 +175,14 @@ impl Context {
arg("sysroot", paths::TASK_SYSROOT.to_string()),
]);
let rootfs = Context::handle_pins(pins)?;
- let rootfs_tasks = Context::rootfs_tasks();
+
+ Context::add_rootfs_tasks(&mut tasks, &globals);
Ok(Context {
platforms,
globals,
tasks,
rootfs,
- rootfs_tasks,
})
}
@@ -204,7 +203,7 @@ impl Context {
rootfs.context("No is-rootfs pins")
}
- fn rootfs_tasks() -> HashMap<TaskID, TaskDef> {
+ fn add_rootfs_tasks(tasks: &mut HashMap<TaskID, Vec<TaskDef>>, globals: &TaskArgs) {
// TODO: Do not hardcode this
const ROOTFS_TASKS: &[((&str, &str), bool, &[&str])] = &[
(("gmp", "install"), false, &["default"]),
@@ -219,17 +218,19 @@ impl Context {
(("glibc", "install"), false, &["default"]),
(("e2fsprogs", "install"), false, &["default"]),
];
-
- let mut ret = HashMap::new();
+ let build = globals.get("build");
for ((recipe, task), has_target, outputs) in ROOTFS_TASKS {
let mut task_def = TaskDef::default();
task_def.args.insert("host".to_string(), ArgType::Platform);
+ task_def.arg_match.set("host", build);
+
if *has_target {
task_def
.args
.insert("target".to_string(), ArgType::Platform);
+ task_def.arg_match.set("target", build);
}
for output in *outputs {
@@ -238,36 +239,22 @@ impl Context {
.insert(output.to_string(), Output::default());
}
- ret.insert(
- TaskID {
+ task_def.priority = i32::MAX;
+
+ tasks
+ .entry(TaskID {
recipe: recipe.to_string(),
task: task.to_string(),
- },
- task_def,
- );
+ })
+ .or_default()
+ .push(task_def);
}
-
- ret
}
pub fn get_rootfs(&self) -> &(ArchiveHash, String) {
&self.rootfs
}
- fn rootfs_task<'ctx>(&'ctx self, id: &'ctx TaskID, args: &TaskArgs) -> Option<&TaskDef> {
- let build = self.globals.get("build").unwrap();
- if args.get("host") != Some(build) {
- return None;
- }
-
- let task_def = self.rootfs_tasks.get(id)?;
- if task_def.args.get("target").is_some() && args.get("target") != Some(build) {
- return None;
- }
-
- Some(task_def)
- }
-
fn match_task(task: &TaskDef, args: &TaskArgs) -> bool {
task.arg_match
.iter()
@@ -292,10 +279,6 @@ impl Context {
}
fn get_with_args<'ctx>(&'ctx self, id: &'ctx TaskID, args: &TaskArgs) -> Result<&TaskDef> {
- if let Some(rootfs_task) = self.rootfs_task(id, args) {
- return Ok(rootfs_task);
- }
-
self.tasks
.get(id)
.and_then(|tasks| Self::select_task(tasks, args))