From 6f11f3f247d8949401cd0afb676198b439053740 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 12 Apr 2024 19:34:13 +0200 Subject: Replace 'inherit' recipe field with 'parent' All occurrences of 'inherit' in the code are replaced with 'parent' or 'ancestors'. --- crates/common/src/types.rs | 2 +- crates/driver/src/context.rs | 19 +++++++++---------- crates/driver/src/driver.rs | 23 +++++++++++------------ crates/driver/src/resolve.rs | 8 ++++---- crates/driver/src/task.rs | 4 ++-- crates/runner/src/task.rs | 8 ++++---- examples/recipes/binutils/build.yml | 6 +++--- examples/recipes/busybox/build.yml | 6 +++--- examples/recipes/e2fsprogs/build.yml | 6 +++--- examples/recipes/gcc/build.libgcc-initial.yml | 6 +++--- examples/recipes/gcc/build.libgcc.yml | 4 ++-- examples/recipes/gcc/build.libs.yml | 4 ++-- examples/recipes/gcc/build.yml | 6 +++--- examples/recipes/glibc/build.yml | 6 +++--- examples/recipes/gmp/build.yml | 6 +++--- examples/recipes/linux/build.uapi-headers.yml | 2 +- examples/recipes/linux/build.yml | 6 +++--- examples/recipes/make_ext4fs/build.yml | 4 ++-- examples/recipes/mpc/build.yml | 6 +++--- examples/recipes/mpfr/build.yml | 6 +++--- examples/recipes/zlib/build.yml | 6 +++--- 21 files changed, 71 insertions(+), 73 deletions(-) diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 32b9182..a5d6678 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -39,7 +39,7 @@ pub struct Task { pub command: String, pub workdir: String, pub rootfs: ArchiveHash, - pub inherit: Vec, + pub ancestors: Vec, pub depends: HashSet, pub outputs: HashMap, pub pins: HashMap, diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs index e6e60b1..3bf4bf5 100644 --- a/crates/driver/src/context.rs +++ b/crates/driver/src/context.rs @@ -424,7 +424,7 @@ impl Context { Ok(Cow::Owned(ret)) } - fn inherit_ref<'ctx>(&'ctx self, dep: &'ctx InheritDep, args: &TaskArgs) -> Result { + fn parent_ref<'ctx>(&'ctx self, dep: &'ctx ParentDep, args: &TaskArgs) -> Result { let mapped_args = Context::map_args(&dep.dep.id, &dep.dep.args, args, false)?; self.task_ref(&dep.dep.id, mapped_args.as_ref()) } @@ -442,19 +442,18 @@ impl Context { }) } - pub fn get_inherit_depend<'ctx>( + pub fn get_parent_depend<'ctx>( &'ctx self, task_ref: &TaskRef<'ctx>, ) -> Result> { let task = self.get(task_ref)?; - let inherit = match &task.inherit { - Some(inherit) => inherit, - None => return Ok(None), + let Some(parent) = &task.parent else { + return Ok(None); }; - Some(self.inherit_ref(inherit, &task_ref.args)).transpose() + Some(self.parent_ref(parent, &task_ref.args)).transpose() } - fn inherit_iter<'ctx>( + fn ancestor_iter<'ctx>( &'ctx self, task_ref: &TaskRef<'ctx>, ) -> impl Iterator> { @@ -468,7 +467,7 @@ impl Context { Ok(task_ref) => task_ref, Err(err) => return Some(Err(err)), }; - self.1 = self.0.get_inherit_depend(&task_ref).transpose(); + self.1 = self.0.get_parent_depend(&task_ref).transpose(); Some(Ok(task_ref)) } } @@ -483,7 +482,7 @@ impl Context { let mut ret = HashSet::new(); let mut allow_noinherit = true; - for current in self.inherit_iter(task_ref) { + for current in self.ancestor_iter(task_ref) { let current_ref = current?; let task = self.get(¤t_ref)?; let entries = task @@ -507,7 +506,7 @@ impl Context { let mut ret = HashSet::new(); let mut allow_noinherit = true; - for current in self.inherit_iter(task_ref) { + for current in self.ancestor_iter(task_ref) { let current_ref = current?; let task = self.get(¤t_ref)?; let entries = task diff --git a/crates/driver/src/driver.rs b/crates/driver/src/driver.rs index 28c8578..212f4cf 100644 --- a/crates/driver/src/driver.rs +++ b/crates/driver/src/driver.rs @@ -37,7 +37,7 @@ impl<'ctx> CompletionState<'ctx> { } } - // Treats both "depends" and "inherit" as dependencies + // Treats both "depends" and "parent" as dependencies fn deps_satisfied(&self, task_ref: &TaskRef) -> bool { resolve::get_dependent_tasks(self.ctx, task_ref) .map_err(|_| Error::new(format!("invalid dependency for {}", task_ref))) @@ -103,18 +103,17 @@ impl<'ctx> CompletionState<'ctx> { Ok(fetch_deps.chain(build_deps).chain(host_deps).collect()) } - fn task_inherit_chain(&self, task_ref: &TaskRef<'ctx>) -> Vec { - let inherit = match self + fn task_ancestors(&self, task_ref: &TaskRef<'ctx>) -> Vec { + let Some(parent) = self .ctx - .get_inherit_depend(task_ref) - .expect("invalid inherit depends") - { - Some(inherit) => inherit, - None => return vec![], + .get_parent_depend(task_ref) + .expect("invalid parent depends") + else { + return vec![]; }; - let mut chain = self.task_inherit_chain(&inherit); - if let Some(layer) = self.tasks_done[&inherit].layer { + let mut chain = self.task_ancestors(&parent); + if let Some(layer) = self.tasks_done[&parent].layer { chain.push(layer); } chain @@ -314,7 +313,7 @@ impl<'ctx> Driver<'ctx> { }) .collect(); - let inherit_chain = self.state.task_inherit_chain(task_ref); + let ancestors = self.state.task_ancestors(task_ref); let mut run = Self::task_setup(task_ref); run.push(&task_def.action.run); @@ -331,7 +330,7 @@ impl<'ctx> Driver<'ctx> { command, workdir: paths::TASK_WORKDIR.to_string(), rootfs: rootfs.0, - inherit: inherit_chain, + ancestors, depends: task_deps, outputs: task_output, pins: HashMap::from([rootfs.clone()]), diff --git a/crates/driver/src/resolve.rs b/crates/driver/src/resolve.rs index c13fcd2..102c483 100644 --- a/crates/driver/src/resolve.rs +++ b/crates/driver/src/resolve.rs @@ -214,7 +214,7 @@ pub fn get_dependent_tasks<'ctx>( task_ref: &TaskRef<'ctx>, ) -> Result>, Vec>> { Ok(ctx - .get_inherit_depend(task_ref) + .get_parent_depend(task_ref) .map_err(|err| vec![err.into()])? .into_iter() .chain( @@ -281,9 +281,9 @@ impl<'ctx> Resolver<'ctx> { }; let _ = (|| -> Result<(), ()> { - match self.ctx.get_inherit_depend(task) { - Ok(Some(inherit)) => { - handle_errors(self.add_task(&inherit, None))?; + match self.ctx.get_parent_depend(task) { + Ok(Some(parent)) => { + handle_errors(self.add_task(&parent, None))?; } Ok(None) => {} Err(err) => { diff --git a/crates/driver/src/task.rs b/crates/driver/src/task.rs index e30f214..e84766e 100644 --- a/crates/driver/src/task.rs +++ b/crates/driver/src/task.rs @@ -28,7 +28,7 @@ fn default_output_name() -> String { } #[derive(Clone, Debug, Deserialize)] -pub struct InheritDep { +pub struct ParentDep { #[serde(flatten)] pub dep: TaskDep, } @@ -78,7 +78,7 @@ pub struct TaskDef { #[serde(default)] pub args: HashMap, #[serde(default)] - pub inherit: Option, + pub parent: Option, #[serde(default)] pub fetch: HashSet, #[serde(default)] diff --git a/crates/runner/src/task.rs b/crates/runner/src/task.rs index 5c27e78..19b74f4 100644 --- a/crates/runner/src/task.rs +++ b/crates/runner/src/task.rs @@ -52,7 +52,7 @@ fn input_hash(task: &Task) -> InputHash { pub command: &'a str, pub workdir: &'a str, pub rootfs: &'a ArchiveHash, - pub inherit: &'a [LayerHash], + pub ancestors: &'a [LayerHash], pub depends: HashMap, pub outputs: &'a HashMap, } @@ -60,7 +60,7 @@ fn input_hash(task: &Task) -> InputHash { command: &task.command, workdir: &task.workdir, rootfs: &task.rootfs, - inherit: &task.inherit, + ancestors: &task.ancestors, depends: task .depends .iter() @@ -94,7 +94,7 @@ fn init_task(input_hash: &InputHash, task: &Task) -> Result { .with_context(|| format!("Failed to write {}", runfile))?; let mount_target = paths::join(&[&task_tmp_dir, &task.workdir]); - let mount = if task.inherit.is_empty() { + let mount = if task.ancestors.is_empty() { fs::mount(task_layer_dir, &mount_target, None, MsFlags::MS_BIND, None) .with_context(|| format!("Failed to bind mount to {:?}", mount_target))? } else { @@ -104,7 +104,7 @@ fn init_task(input_hash: &InputHash, task: &Task) -> Result { fs::fixup_permissions(&task_work_dir)?; let lower = task - .inherit + .ancestors .iter() .rev() .map(paths::layer_dir) diff --git a/examples/recipes/binutils/build.yml b/examples/recipes/binutils/build.yml index a82723f..dd82d2e 100644 --- a/examples/recipes/binutils/build.yml +++ b/examples/recipes/binutils/build.yml @@ -12,7 +12,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -44,7 +44,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -55,7 +55,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/busybox/build.yml b/examples/recipes/busybox/build.yml index e8019bb..fa87bc3 100644 --- a/examples/recipes/busybox/build.yml +++ b/examples/recipes/busybox/build.yml @@ -10,7 +10,7 @@ tasks: configure: - inherit: + parent: task: 'unpack' run: | mkdir {{name}}-build @@ -23,7 +23,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' build_depends: - recipe: 'toolchain' @@ -46,7 +46,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/e2fsprogs/build.yml b/examples/recipes/e2fsprogs/build.yml index e1fc0e0..508d1d4 100644 --- a/examples/recipes/e2fsprogs/build.yml +++ b/examples/recipes/e2fsprogs/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -31,7 +31,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -41,7 +41,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/gcc/build.libgcc-initial.yml b/examples/recipes/gcc/build.libgcc-initial.yml index 38414aa..ed230ba 100644 --- a/examples/recipes/gcc/build.libgcc-initial.yml +++ b/examples/recipes/gcc/build.libgcc-initial.yml @@ -3,7 +3,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: recipe: 'gcc' task: 'compile' depends: @@ -28,7 +28,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -38,7 +38,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'compile' output: default: {} diff --git a/examples/recipes/gcc/build.libgcc.yml b/examples/recipes/gcc/build.libgcc.yml index ed7fa66..67e21f7 100644 --- a/examples/recipes/gcc/build.libgcc.yml +++ b/examples/recipes/gcc/build.libgcc.yml @@ -3,7 +3,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: recipe: 'gcc' task: 'compile' depends: @@ -19,7 +19,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'compile' output: default: {} diff --git a/examples/recipes/gcc/build.libs.yml b/examples/recipes/gcc/build.libs.yml index 4a20ad1..856fd1c 100644 --- a/examples/recipes/gcc/build.libs.yml +++ b/examples/recipes/gcc/build.libs.yml @@ -2,7 +2,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: recipe: 'gcc/libgcc' task: 'compile' args: @@ -15,7 +15,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/gcc/build.yml b/examples/recipes/gcc/build.yml index cd4166e..3352b2d 100644 --- a/examples/recipes/gcc/build.yml +++ b/examples/recipes/gcc/build.yml @@ -26,7 +26,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -95,7 +95,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'configure' depends: - task: 'header-stubs' @@ -109,7 +109,7 @@ tasks: args: host: 'platform' target: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/glibc/build.yml b/examples/recipes/glibc/build.yml index 3538d90..f1bf890 100644 --- a/examples/recipes/glibc/build.yml +++ b/examples/recipes/glibc/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'gcc' @@ -47,7 +47,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -56,7 +56,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/gmp/build.yml b/examples/recipes/gmp/build.yml index 3a07f44..322f0f0 100644 --- a/examples/recipes/gmp/build.yml +++ b/examples/recipes/gmp/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -31,7 +31,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -40,7 +40,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/linux/build.uapi-headers.yml b/examples/recipes/linux/build.uapi-headers.yml index ea398d3..a302aa9 100644 --- a/examples/recipes/linux/build.uapi-headers.yml +++ b/examples/recipes/linux/build.uapi-headers.yml @@ -9,7 +9,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'unpack' output: default: {} diff --git a/examples/recipes/linux/build.yml b/examples/recipes/linux/build.yml index ad32813..3f84291 100644 --- a/examples/recipes/linux/build.yml +++ b/examples/recipes/linux/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'gcc' @@ -28,7 +28,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | export KBUILD_BUILD_TIMESTAMP="@${SOURCE_DATE_EPOCH}" @@ -42,7 +42,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: boot: diff --git a/examples/recipes/make_ext4fs/build.yml b/examples/recipes/make_ext4fs/build.yml index f50fa85..183389a 100644 --- a/examples/recipes/make_ext4fs/build.yml +++ b/examples/recipes/make_ext4fs/build.yml @@ -19,7 +19,7 @@ tasks: task: 'depends' - recipe: 'zlib' task: 'install' - inherit: + parent: task: 'unpack' run: | cd {{name}}-{{version}} @@ -28,7 +28,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/mpc/build.yml b/examples/recipes/mpc/build.yml index 816bed0..e415c60 100644 --- a/examples/recipes/mpc/build.yml +++ b/examples/recipes/mpc/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -33,7 +33,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -42,7 +42,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/mpfr/build.yml b/examples/recipes/mpfr/build.yml index b77cf81..619bec7 100644 --- a/examples/recipes/mpfr/build.yml +++ b/examples/recipes/mpfr/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -33,7 +33,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -42,7 +42,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: diff --git a/examples/recipes/zlib/build.yml b/examples/recipes/zlib/build.yml index a9f09d7..3e72844 100644 --- a/examples/recipes/zlib/build.yml +++ b/examples/recipes/zlib/build.yml @@ -11,7 +11,7 @@ tasks: configure: args: host: 'platform' - inherit: + parent: task: 'unpack' build_depends: - recipe: 'toolchain' @@ -29,7 +29,7 @@ tasks: compile: args: host: 'platform' - inherit: + parent: task: 'configure' run: | cd {{name}}-build @@ -38,7 +38,7 @@ tasks: install: args: host: 'platform' - inherit: + parent: task: 'compile' output: default: -- cgit v1.2.3