Skip to content
Merged
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
23 changes: 15 additions & 8 deletions dev-tools/gen-target-info/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,22 @@ fn generate_target_mapping(f: &mut File, target_specs: &RustcTargetSpecs) -> std

fn main() {
// Primarily use information from nightly.
let mut target_specs = get_target_specs_from_json();
let mut target_specs = get_target_specs_from_json(std::env::var("RUSTC").ok());
// Next, read from MSRV to support old, removed targets.
for target_triple in get_targets_msrv().lines() {
let target_triple = target_triple.unwrap();
let target_triple = target_triple.trim();
target_specs
.0
.entry(target_triple.to_string())
.or_insert_with(|| get_target_spec_from_msrv(target_triple));
if std::env::var("CC_RS_MSRV")
.unwrap_or("1".to_string())
.parse::<u32>()
.unwrap()
!= 0
{
for target_triple in get_targets_msrv().lines() {
let target_triple = target_triple.unwrap();
let target_triple = target_triple.trim();
target_specs
.0
.entry(target_triple.to_string())
.or_insert_with(|| get_target_spec_from_msrv(target_triple));
}
}

// Open file to write to
Expand Down
16 changes: 8 additions & 8 deletions dev-tools/gen-target-info/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ pub fn get_target_spec_from_msrv(target: &str) -> TargetSpec {
serde_json::from_slice(&stdout).unwrap()
}

pub fn get_target_specs_from_json() -> RustcTargetSpecs {
let mut cmd = process::Command::new("rustc");
cmd.args([
"+nightly",
"-Zunstable-options",
"--print",
"all-target-specs-json",
]);
pub fn get_target_specs_from_json(rustc: Option<String>) -> RustcTargetSpecs {
let mut cmd = process::Command::new(rustc.clone().unwrap_or("rustc".into()));

if rustc.is_none() {
cmd.arg("+nightly");
}

cmd.args(["-Zunstable-options", "--print", "all-target-specs-json"]);
cmd.stdout(process::Stdio::piped());
cmd.stderr(process::Stdio::inherit());

Expand Down