Skip to content

Commit 8a195ef

Browse files
committed
Make it possible to attach opaque string metadata to StepMetadata
1 parent c720f49 commit 8a195ef

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/bootstrap/src/core/builder/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ pub struct StepMetadata {
146146
target: TargetSelection,
147147
built_by: Option<Compiler>,
148148
stage: Option<u32>,
149+
/// Additional opaque string printed in the metadata
150+
metadata: Option<String>,
149151
}
150152

151153
impl StepMetadata {
@@ -170,7 +172,7 @@ impl StepMetadata {
170172
}
171173

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

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

188+
pub fn with_metadata(mut self, metadata: String) -> Self {
189+
self.metadata = Some(metadata);
190+
self
191+
}
192+
186193
pub fn get_stage(&self) -> Option<u32> {
187194
self.stage.or(self
188195
.built_by

src/bootstrap/src/core/builder/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ impl ExecutedSteps {
15871587
}
15881588

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

@@ -1648,6 +1648,9 @@ fn render_metadata(metadata: &StepMetadata) -> String {
16481648
}
16491649
let stage = metadata.get_stage().map(|stage| format!("{stage} ")).unwrap_or_default();
16501650
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target));
1651+
if let Some(metadata) = &metadata.metadata {
1652+
write!(record, " {metadata}");
1653+
}
16511654
record
16521655
}
16531656

0 commit comments

Comments
 (0)