Skip to content

Commit 0cf581e

Browse files
committed
inline build_artifact_requirements_to_units()
1 parent b478370 commit 0cf581e

File tree

1 file changed

+14
-35
lines changed

1 file changed

+14
-35
lines changed

src/cargo/core/compiler/unit_dependencies.rs

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -526,47 +526,25 @@ fn compute_deps_custom_build(
526526
dep.kind() == DepKind::Build && dep.artifact().is_some()
527527
});
528528

529-
build_artifact_requirements_to_units(
530-
unit,
531-
unit_for.root_compile_kind(),
532-
artifact_build_deps,
533-
state,
534-
&mut result,
535-
)?;
536-
537-
Ok(result)
538-
}
539-
540-
/// Given a `parent` unit which is a build script with artifact dependencies `artifact_deps`,
541-
/// produce units that build all required artifact kinds (like binaries,
542-
/// static libraries, etc) with the correct compile target.
543-
///
544-
/// Computing the compile target for artifact units is more involved as it has to handle
545-
/// various target configurations specific to artifacts, like `target = "target"` and
546-
/// `target = "<triple>"`, which makes knowing the root units compile target
547-
/// `root_unit_compile_target` necessary.
548-
fn build_artifact_requirements_to_units(
549-
parent: &Unit,
550-
root_unit_compile_target: CompileKind,
551-
artifact_deps: Vec<(PackageId, &HashSet<Dependency>)>,
552-
state: &State<'_, '_>,
553-
ret: &mut Vec<UnitDep>,
554-
) -> CargoResult<()> {
555-
// This really wants to be true for build dependencies, otherwise resolver = "2"
556-
// will fail. // It means that the host features will be separated from normal
557-
// features, thus won't be unified with them.
558-
let host_features = true;
559-
let unit_for = UnitFor::new_host(host_features, root_unit_compile_target);
560-
for (dep_pkg_id, deps) in artifact_deps {
529+
// Produce units that build all required artifact kinds (like binaries,
530+
// static libraries, etc) with the correct compile target.
531+
//
532+
// Computing the compile target for artifact units is more involved as it has to handle
533+
// various target configurations specific to artifacts, like `target = "target"` and
534+
// `target = "<triple>"`, which makes knowing the root units compile target
535+
// `root_unit_compile_target` necessary.
536+
let root_unit_compile_target = unit_for.root_compile_kind();
537+
let unit_for = UnitFor::new_host(/*host_features*/ true, root_unit_compile_target);
538+
for (dep_pkg_id, deps) in artifact_build_deps {
561539
let artifact_pkg = state.get(dep_pkg_id);
562540
for build_dep in deps.iter().filter(|d| d.is_build()) {
563541
let artifact = build_dep.artifact().expect("artifact dep");
564542
let resolved_artifact_compile_kind = artifact
565543
.target()
566544
.map(|target| target.to_resolved_compile_kind(root_unit_compile_target));
567545

568-
ret.extend(artifact_targets_to_unit_deps(
569-
parent,
546+
result.extend(artifact_targets_to_unit_deps(
547+
unit,
570548
unit_for.with_artifact_features_from_resolved_compile_kind(
571549
resolved_artifact_compile_kind,
572550
),
@@ -577,7 +555,8 @@ fn build_artifact_requirements_to_units(
577555
)?);
578556
}
579557
}
580-
Ok(())
558+
559+
Ok(result)
581560
}
582561

583562
/// Given a `parent` unit containing a dependency `dep` whose package is `artifact_pkg`,

0 commit comments

Comments
 (0)