diff --git a/src/bin/repo.rs b/src/bin/repo.rs index 378ff9ee..7d283398 100644 --- a/src/bin/repo.rs +++ b/src/bin/repo.rs @@ -452,7 +452,8 @@ fn parse_args(args: Vec) -> anyhow::Result<(CliConfig, CliCommand, Vec, PackageError>>()? } else { if recipe_names.is_empty() { diff --git a/src/bin/repo_builder.rs b/src/bin/repo_builder.rs index 51736771..d7ae75bc 100644 --- a/src/bin/repo_builder.rs +++ b/src/bin/repo_builder.rs @@ -89,7 +89,7 @@ fn publish_packages(config: &CliConfig) -> anyhow::Result<()> { eprintln!("recipe {} not found", recipe); continue; }; - let Ok(cookbook_recipe) = CookRecipe::from_path(recipe_path, true) else { + let Ok(cookbook_recipe) = CookRecipe::from_path(recipe_path, true, false) else { eprintln!("recipe {} unable to read", recipe); continue; }; diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index 8c5d0a49..385dc3ec 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -208,7 +208,12 @@ pub fn build( return Ok((stage_dirs, auto_deps)); } - let source_modified = modified_dir_ignore_git(source_dir).unwrap_or(SystemTime::UNIX_EPOCH); + let mut source_modified = modified_dir_ignore_git(source_dir).unwrap_or(SystemTime::UNIX_EPOCH); + if let Ok(recipe_modified) = modified(&recipe_dir.join("recipe.toml")) { + if recipe_modified > source_modified { + source_modified = recipe_modified + } + } let deps_modified = dep_pkgars .iter() .map(|(_dep, pkgar)| modified(pkgar)) @@ -221,7 +226,6 @@ pub fn build( .unwrap_or(Ok(SystemTime::UNIX_EPOCH))?; // Rebuild sysroot if source is newer - //TODO: rebuild on recipe changes if recipe.build.kind != BuildKind::Remote { build_deps_dir( logger, @@ -248,7 +252,6 @@ pub fn build( } // Rebuild stage if source is newer - //TODO: rebuild on recipe changes if stage_dirs.iter().any(|dir| dir.is_dir()) { let stage_modified = modified_all(&stage_dirs, modified_dir).unwrap_or(SystemTime::UNIX_EPOCH); diff --git a/src/recipe.rs b/src/recipe.rs index 67947a33..5e0b4ce6 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -265,9 +265,12 @@ impl CookRecipe { Self::new(name, dir.to_path_buf(), recipe) } - pub fn from_path(dir: &Path, read_recipe: bool) -> Result { + pub fn from_path(dir: &Path, read_recipe: bool, is_host: bool) -> Result { let file = dir.join("recipe.toml"); - let name: PackageName = dir.file_name().unwrap().try_into()?; + let mut name: PackageName = dir.file_name().unwrap().try_into()?; + if is_host { + name = name.with_host(); + } let recipe = if read_recipe { Recipe::new(&file)? } else { @@ -417,7 +420,7 @@ impl CookRecipe { } pub fn reload_recipe(&mut self) -> Result<(), PackageError> { - let r = Self::from_path(&self.dir, true)?; + let r = Self::from_path(&self.dir, true, self.name.is_host())?; self.recipe = r.recipe; Ok(()) }