Skip to content

Commit

Permalink
use the shared vendor impl for plan source tarballs
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Feb 17, 2025
1 parent 33e7f9b commit 92f31b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
28 changes: 9 additions & 19 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use object::read::archive::ArchiveFile;

use crate::core::build_steps::doc::DocumentationFormat;
use crate::core::build_steps::tool::{self, Tool};
use crate::core::build_steps::vendor::default_paths_to_vendor;
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
use crate::core::build_steps::{compile, llvm};
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::core::config::TargetSelection;
Expand Down Expand Up @@ -1050,19 +1050,6 @@ impl Step for PlainSourceTarball {
if builder.config.dist_vendor {
builder.require_and_update_all_submodules();

// Vendor all Cargo dependencies
let mut cmd = command(&builder.initial_cargo);
cmd.arg("vendor").arg("--versioned-dirs");

for (p, _) in default_paths_to_vendor(builder) {
cmd.arg("--sync").arg(p);
}

cmd
// Will read the libstd Cargo.toml which uses the unstable `public-dependency` feature.
.env("RUSTC_BOOTSTRAP", "1")
.current_dir(plain_dst_src);

// Vendor packages that are required by opt-dist to collect PGO profiles.
let pkgs_for_pgo_training = build_helper::LLVM_PGO_CRATES
.iter()
Expand All @@ -1074,15 +1061,18 @@ impl Step for PlainSourceTarball {
manifest_path.push("Cargo.toml");
manifest_path
});
for manifest_path in pkgs_for_pgo_training {
cmd.arg("--sync").arg(manifest_path);
}

let config = cmd.run_capture(builder).stdout();
// Vendor all Cargo dependencies
let vendor = builder.ensure(Vendor {
sync_args: pkgs_for_pgo_training.collect(),
versioned_dirs: true,
root_dir: plain_dst_src.into(),
output_dir: VENDOR_DIR.into(),
});

let cargo_config_dir = plain_dst_src.join(".cargo");
builder.create_dir(&cargo_config_dir);
builder.create(&cargo_config_dir.join("config.toml"), &config);
builder.create(&cargo_config_dir.join("config.toml"), &vendor.config);
}

// Delete extraneous directories
Expand Down
10 changes: 8 additions & 2 deletions src/bootstrap/src/core/build_steps/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) struct Vendor {
}

impl Step for Vendor {
type Output = ();
type Output = VendorOutput;
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

Expand Down Expand Up @@ -89,6 +89,12 @@ impl Step for Vendor {

cmd.current_dir(self.root_dir).arg(&self.output_dir);

cmd.run(builder);
let config = cmd.run_capture_stdout(builder);
VendorOutput { config: config.stdout() }
}
}

#[derive(Debug, Clone)]
pub(crate) struct VendorOutput {
pub(crate) config: String,
}

0 comments on commit 92f31b9

Please sign in to comment.