summaryrefslogtreecommitdiffstats
path: root/crates/driver/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/driver/src/context.rs')
-rw-r--r--crates/driver/src/context.rs99
1 files changed, 67 insertions, 32 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs
index 25b8e38..3e1a5eb 100644
--- a/crates/driver/src/context.rs
+++ b/crates/driver/src/context.rs
@@ -136,6 +136,7 @@ pub struct Context {
platforms: HashMap<String, Arg>,
globals: TaskArgs,
tasks: HashMap<TaskID, TaskDef>,
+ rootfs_tasks: HashMap<TaskID, TaskDef>,
}
impl Context {
@@ -170,15 +171,80 @@ impl Context {
arg("destdir", paths::TASK_DESTDIR.to_string()),
arg("sysroot", paths::TASK_SYSROOT.to_string()),
]);
+ let rootfs_tasks = Context::rootfs_tasks();
Context {
platforms,
globals,
tasks,
+ rootfs_tasks,
}
}
- fn get_with_args<'ctx>(&'ctx self, id: &'ctx TaskID, _args: &TaskArgs) -> Result<&TaskDef> {
+ fn rootfs_tasks() -> HashMap<TaskID, TaskDef> {
+ // TODO: Do not hardcode this
+ const ROOTFS_TASKS: &[((&str, &str), bool, &[&str])] = &[
+ (("gmp", "install"), false, &["default"]),
+ (("mpfr", "install"), false, &["default"]),
+ (("mpc", "install"), false, &["default"]),
+ (("zlib", "install"), false, &["default"]),
+ (("binutils", "install"), true, &["default"]),
+ (("gcc", "install"), true, &["default"]),
+ (("libgcc", "install"), true, &["default"]),
+ (("gcc-libs", "install"), false, &["default"]),
+ (("linux-uapi-headers", "install"), false, &["default"]),
+ (("glibc", "install"), false, &["default"]),
+ ];
+
+ let mut ret = HashMap::new();
+
+ for ((recipe, task), has_target, outputs) in ROOTFS_TASKS {
+ let mut task_def = TaskDef::default();
+
+ task_def.args.insert("host".to_string(), ArgType::Platform);
+ if *has_target {
+ task_def
+ .args
+ .insert("target".to_string(), ArgType::Platform);
+ }
+
+ for output in *outputs {
+ task_def
+ .output
+ .insert(output.to_string(), Output::default());
+ }
+
+ ret.insert(
+ TaskID {
+ recipe: recipe.to_string(),
+ task: task.to_string(),
+ },
+ task_def,
+ );
+ }
+
+ ret
+ }
+
+ 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 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).ok_or(Error {
task: id,
kind: ErrorKind::TaskNotFound,
@@ -403,37 +469,6 @@ impl Context {
Ok(ret)
}
-
- pub fn in_rootfs<'ctx>(&'ctx self, output: &OutputRef<'ctx>) -> bool {
- let build = self.globals.get("build").unwrap();
- if output.task.args.get("host") != Some(build) {
- return false;
- }
- if let Some(target) = output.task.args.get("target") {
- if target != build {
- return false;
- }
- }
-
- // TODO: Do not hardcode this
- match (
- output.task.id.recipe.as_str(),
- output.task.id.task.as_str(),
- output.output,
- ) {
- ("gmp", "install", "default") => true,
- ("mpfr", "install", "default") => true,
- ("mpc", "install", "default") => true,
- ("zlib", "install", "default") => true,
- ("binutils", "install", "default") => true,
- ("gcc", "install", "default") => true,
- ("libgcc", "install", "default") => true,
- ("gcc-libs", "install", "default") => true,
- ("linux-uapi-headers", "install", "default") => true,
- ("glibc", "install", "default") => true,
- _ => false,
- }
- }
}
impl<'ctx> Index<&TaskRef<'ctx>> for &'ctx Context {