Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,18 +1206,14 @@ impl Step for Src {
);

// Vendor all Cargo dependencies
let vendor = builder.ensure(Vendor {
builder.ensure(Vendor {
sync_args: vec![],
versioned_dirs: true,
root_dir: dst_src.clone(),
output_dir: None,
only_library_workspace: true,
});

let library_cargo_config_dir = dst_src.join("library").join(".cargo");
builder.create_dir(&library_cargo_config_dir);
builder.create(&library_cargo_config_dir.join("config.toml"), &vendor.config_library);

tarball.generate()
}

Expand Down Expand Up @@ -1379,21 +1375,13 @@ fn prepare_source_tarball<'a>(
});

// Vendor all Cargo dependencies
let vendor = builder.ensure(Vendor {
builder.ensure(Vendor {
sync_args: pkgs_for_pgo_training.collect(),
versioned_dirs: true,
root_dir: plain_dst_src.into(),
output_dir: None,
only_library_workspace: false,
});

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

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

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

impl Step for Vendor {
type Output = VendorOutput;
type Output = ();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? GenerateCopyright can still make use of the final path, instead of having to know about VENDOR_DIR, which is an implementation detail of the vendor step.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VendorOutput only ever contained the data that should be written to .cargo/config.toml.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like overwriting the config.toml file on disk (as per my other comment), but if we did that, we can at least return the path to the vendor directory from the step, to avoid other steps reaching for VENDOR_DIR.

const IS_HOST: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand All @@ -84,7 +84,7 @@ impl Step for Vendor {
///
/// This function runs `cargo vendor` and ensures all required submodules
/// are initialized before vendoring begins.
fn run(self, builder: &Builder<'_>) -> Self::Output {
fn run(self, builder: &Builder<'_>) {
let _guard = builder.group(&format!("Vendoring sources to {:?}", self.root_dir));

let config = if self.only_library_workspace {
Expand Down Expand Up @@ -163,13 +163,15 @@ impl Step for Vendor {

let config_library = cmd.run_capture_stdout(builder).stdout();

VendorOutput { config, config_library }
}
}
// Write .cargo/config.toml
let cargo_config_dir = self.output_dir.as_ref().unwrap_or(&self.root_dir).join(".cargo");
builder.create_dir(&cargo_config_dir);
builder.create(&cargo_config_dir.join("config.toml"), &config);

/// Stores the result of the vendoring step.
#[derive(Debug, Clone)]
pub(crate) struct VendorOutput {
pub(crate) config: String,
pub(crate) config_library: String,
// Write library/.cargo/config.toml
let library_cargo_config_dir =
self.output_dir.unwrap_or(self.root_dir).join("library").join(".cargo");
builder.create_dir(&library_cargo_config_dir);
builder.create(&library_cargo_config_dir.join("config.toml"), &config_library);
}
}
Loading