Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ pub struct StepMetadata {
target: TargetSelection,
built_by: Option<Compiler>,
stage: Option<u32>,
/// Additional opaque string printed in the metadata
metadata: Option<String>,
Comment on lines +149 to +150
Copy link
Member

Choose a reason for hiding this comment

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

Remark: I'm not so fussed about this, but maybe crates more specifically? Though of course I suppose for many Steps crates doesn't make sense anyway. We'll see if more specific use cases warrant changing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Metadata is a bit silly name here, but I just wanted this to be an opaque string that steps could just use as additional snapshot data.

}

impl StepMetadata {
Expand All @@ -170,7 +172,7 @@ impl StepMetadata {
}

fn new(name: &'static str, target: TargetSelection, kind: Kind) -> Self {
Self { name, kind, target, built_by: None, stage: None }
Self { name, kind, target, built_by: None, stage: None, metadata: None }
}

pub fn built_by(mut self, compiler: Compiler) -> Self {
Expand All @@ -183,6 +185,11 @@ impl StepMetadata {
self
}

pub fn with_metadata(mut self, metadata: String) -> Self {
self.metadata = Some(metadata);
self
}

pub fn get_stage(&self) -> Option<u32> {
self.stage.or(self
.built_by
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ impl ExecutedSteps {
}

fn fuzzy_metadata_eq(executed: &StepMetadata, to_match: &StepMetadata) -> bool {
let StepMetadata { name, kind, target, built_by: _, stage: _ } = executed;
let StepMetadata { name, kind, target, built_by: _, stage: _, metadata } = executed;
*name == to_match.name && *kind == to_match.kind && *target == to_match.target
}

Expand Down Expand Up @@ -1648,6 +1648,9 @@ fn render_metadata(metadata: &StepMetadata) -> String {
}
let stage = metadata.get_stage().map(|stage| format!("{stage} ")).unwrap_or_default();
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target));
if let Some(metadata) = &metadata.metadata {
write!(record, " {metadata}");
}
record
}

Expand Down