Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5bcb66c

Browse files
committedMar 10, 2024
Add metadata to targets
This adds four pieces of metadata to every target: - description - tier - host tools - std This information is currently scattered across target docs and both - not machine readable, making validation harder - sometimes subtly encoding by the table it's in, causing mistakes and making it harder to review changes to the properties By putting it in the compiler, we improve this. Later, we will use this canonical information to generate target documentation from it.
1 parent af69f4c commit 5bcb66c

File tree

232 files changed

+1422
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+1422
-238
lines changed
 

‎compiler/rustc_target/src/json.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use std::borrow::Cow;
22
use std::collections::BTreeMap;
33

44
pub use serde_json::Value as Json;
5-
use serde_json::{Map, Number};
5+
use serde_json::{json, Map, Number};
6+
7+
use crate::spec::TargetMetadata;
68

79
pub trait ToJson {
810
fn to_json(&self) -> Json;
@@ -120,3 +122,14 @@ impl ToJson for crate::abi::call::Conv {
120122
Json::String(s.to_owned())
121123
}
122124
}
125+
126+
impl ToJson for TargetMetadata {
127+
fn to_json(&self) -> Json {
128+
json!({
129+
"description": self.description,
130+
"tier": self.tier,
131+
"host_tools": self.host_tools,
132+
"std": self.std,
133+
})
134+
}
135+
}

‎compiler/rustc_target/src/spec/base/avr_gnu.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ use object::elf;
88
pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
99
Target {
1010
arch: "avr".into(),
11-
description: None,
11+
metadata: crate::spec::TargetMetadata {
12+
description: None,
13+
tier: None,
14+
host_tools: None,
15+
std: None,
16+
},
1217
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(),
1318
llvm_target: "avr-unknown-unknown".into(),
1419
pointer_width: 16,

0 commit comments

Comments
 (0)
Please sign in to comment.