From dd68d0b28d4265fba1b7692f3f4357821e4e8de2 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Thu, 5 Nov 2020 17:18:14 -0500 Subject: [PATCH] Vendor libtest's dependencies in the rust-src component This is the Rust side of https://github.com/rust-lang/wg-cargo-std-aware/issues/23 --- src/bootstrap/dist.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index bdab12db43502..4534c69d40de9 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1040,6 +1040,25 @@ impl Step for Src { builder.copy(&builder.src.join(file), &dst_src.join(file)); } + // libtest includes std and everything else, so vendoring it + // creates exactly what's needed for `cargo -Zbuild-std` or any + // other analysis of the stdlib's source. Cargo also needs help + // finding the lock, so we copy it to libtest temporarily. + // + // Note that this requires std to only have one version of each + // crate. e.g. two versions of getopts won't be patchable. + let dst_libtest = dst_src.join("library/test"); + let dst_vendor = dst_src.join("vendor"); + let root_lock = dst_src.join("Cargo.lock"); + let temp_lock = dst_libtest.join("Cargo.lock"); + builder.copy(&root_lock, &temp_lock); + + let mut cmd = Command::new(&builder.initial_cargo); + cmd.arg("vendor").arg(dst_vendor).current_dir(&dst_libtest); + builder.run(&mut cmd); + + builder.remove(&temp_lock); + // Create source tarball in rust-installer format let mut cmd = rust_installer(builder); cmd.arg("generate")