Make it possible to attach opaque string metadata to StepMetadata
This commit is contained in:
parent
c720f49c46
commit
8a195efa1e
2 changed files with 12 additions and 2 deletions
|
|
@ -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>,
|
||||
}
|
||||
|
||||
impl StepMetadata {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue