summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crates/driver/src/context.rs84
1 files changed, 49 insertions, 35 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs
index 3953f54..b89b23c 100644
--- a/crates/driver/src/context.rs
+++ b/crates/driver/src/context.rs
@@ -15,7 +15,12 @@ use common::{
types::TaskID,
};
-use crate::{args::*, parse, paths, pin::Pins, task::*};
+use crate::{
+ args::*,
+ parse, paths,
+ pin::{self, Pins},
+ task::*,
+};
#[derive(Debug, Clone, Copy)]
pub enum ErrorKind<'ctx> {
@@ -174,9 +179,11 @@ impl Context {
arg("destdir", paths::TASK_DESTDIR.to_string()),
arg("sysroot", paths::TASK_SYSROOT.to_string()),
]);
- let rootfs = Context::handle_pins(pins)?;
+ let (rootfs, rootfs_provides) =
+ Context::handle_pins(pins).context("Failed to process pin list")?;
- Context::add_rootfs_tasks(&mut tasks, &globals);
+ Context::add_rootfs_tasks(&mut tasks, rootfs_provides, &globals)
+ .context("Failed to determine rootfs-provided tasks from pin list")?;
Ok(Context {
platforms,
@@ -186,57 +193,62 @@ impl Context {
})
}
- fn handle_pins(pins: Pins) -> error::Result<(ArchiveHash, String)> {
- let mut rootfs = None;
+ fn handle_pins(pins: Pins) -> error::Result<((ArchiveHash, String), Vec<pin::Provides>)> {
+ let mut ret = None;
for (name, pin) in pins {
if pin.is_rootfs {
- if rootfs.is_some() {
+ if ret.is_some() {
return Err(error::Error::new("Multiple is-rootfs pins"));
}
let hash = pin.hash.context("is-rootfs pin without hash")?;
- rootfs = Some((hash, name));
+ ret = Some(((hash, name), pin.provides));
}
}
- rootfs.context("No is-rootfs pins")
+ ret.context("No is-rootfs pins")
}
- 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"]),
- (("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"]),
- (("e2fsprogs", "install"), false, &["default"]),
- ];
- let build = globals.get("build");
-
- for ((recipe, task), has_target, outputs) in ROOTFS_TASKS {
+ fn add_rootfs_tasks(
+ tasks: &mut HashMap<TaskID, Vec<TaskDef>>,
+ provides: Vec<pin::Provides>,
+ globals: &TaskArgs,
+ ) -> error::Result<()> {
+ let build = globals.get("build").unwrap();
+
+ for pin::Provides {
+ recipe,
+ task,
+ output,
+ args,
+ } in provides
+ {
let mut task_def = TaskDef::default();
- task_def.args.insert("host".to_string(), ArgType::Platform);
- task_def.arg_match.set("host", build);
+ if let Some(host) = args.host {
+ if host != "build" {
+ return Err(error::Error::new(format!("Invalid host value '{}'", host)));
+ }
+ task_def.args.insert("host".to_string(), build.into());
+ task_def.arg_match.set("host", Some(build));
+ }
- if *has_target {
- task_def
- .args
- .insert("target".to_string(), ArgType::Platform);
- task_def.arg_match.set("target", build);
+ if let Some(target) = args.target {
+ if target != "build" {
+ return Err(error::Error::new(format!(
+ "Invalid target value '{}'",
+ target
+ )));
+ }
+ task_def.args.insert("target".to_string(), build.into());
+ task_def.arg_match.set("target", Some(build));
}
- for output in *outputs {
+ for output_entry in output {
task_def
.output
- .insert(output.to_string(), Output::default());
+ .insert(output_entry.to_string(), Output::default());
}
task_def.priority = i32::MAX;
@@ -249,6 +261,8 @@ impl Context {
.or_default()
.push(task_def);
}
+
+ Ok(())
}
pub fn get_rootfs(&self) -> &(ArchiveHash, String) {