Flat out package names when building

This commit is contained in:
Wildan M 2025-12-29 21:53:57 +07:00
parent a7b7b9e589
commit bd78177329
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
3 changed files with 30 additions and 5 deletions

View File

@ -497,6 +497,7 @@ fn parse_args(args: Vec<String>) -> anyhow::Result<(CliConfig, CliCommand, Vec<C
!command.is_pushing(),
// In CliCommand::Cook, is_deps==true will make it skip checking source
command.is_pushing() || !config.with_package_deps,
true,
)?
} else {
recipe_names

View File

@ -194,7 +194,7 @@ pub fn build(
&recipe.build.dev_dependencies[..],
]
.concat();
let build_deps = CookRecipe::get_build_deps_recursive(&build_deps, false, false)
let build_deps = CookRecipe::get_build_deps_recursive(&build_deps, false, false, false)
.map_err(|e| format!("{:?}", e))?;
for dependency in build_deps.iter() {
let (_, pkgar, _) = dependency.stage_paths();

View File

@ -297,6 +297,7 @@ impl CookRecipe {
}
let mut recipes = Vec::new();
let mut recipes_set = BTreeSet::new();
for name in names {
let recipe = Self::from_name(name.clone())?;
@ -317,7 +318,8 @@ impl CookRecipe {
})?;
for dependency in dependencies {
if !recipes.contains(&dependency) {
if !recipes_set.contains(&dependency.name) {
recipes_set.insert(dependency.name.clone());
recipes.push(dependency);
}
}
@ -340,7 +342,8 @@ impl CookRecipe {
})?;
for dependency in dependencies {
if !recipes.contains(&dependency) {
if !recipes_set.contains(&dependency.name) {
recipes_set.insert(dependency.name.clone());
recipes.push(dependency);
}
}
@ -363,13 +366,15 @@ impl CookRecipe {
})?;
for dependency in dependencies {
if !recipes.contains(&dependency) {
if !recipes_set.contains(&dependency.name) {
recipes_set.insert(dependency.name.clone());
recipes.push(dependency);
}
}
}
if collect_self && !recipes.contains(&recipe) {
if collect_self && !recipes_set.contains(&recipe.name) {
recipes_set.insert(recipe.name.clone());
recipes.push(recipe);
}
}
@ -381,6 +386,7 @@ impl CookRecipe {
names: &[PackageName],
include_dev: bool,
mark_is_deps: bool,
flatten_opt_package: bool,
) -> Result<Vec<Self>, PackageError> {
let mut packages = Self::new_recursive(
names,
@ -399,6 +405,24 @@ impl CookRecipe {
}
}
if flatten_opt_package {
let old_packages = packages;
packages = Vec::new();
let mut packages_set = BTreeSet::new();
for mut package in old_packages {
let is_host = package.name.is_host();
let mut name = package.name.with_suffix(None);
if is_host {
name = name.with_host();
}
if !packages_set.contains(name.as_str()) {
packages_set.insert(name.to_string());
package.name = name;
packages.push(package);
}
}
}
Ok(packages)
}