Skip to content

Commit

Permalink
Merge #304
Browse files Browse the repository at this point in the history
304: Allow using the crate with custom target JSON specs r=adamgreig a=jonas-schievink

This should fix rust-embedded/cortex-m-rt#145 (cc @thejpster)

Co-authored-by: Jonas Schievink <[email protected]>
  • Loading branch information
bors[bot] and jonas-schievink authored Jan 8, 2021
2 parents 47987f6 + ac4fabb commit 2dfbe11
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cortex-m-rt/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use std::env;
use std::fs::{self, File};
use std::io::Write;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::{env, ffi::OsStr};

fn main() {
let target = env::var("TARGET").unwrap();
let mut target = env::var("TARGET").unwrap();

// When using a custom target JSON, `$TARGET` contains the path to that JSON file. By
// convention, these files are named after the actual target triple, eg.
// `thumbv7m-customos-elf.json`, so we extract the file stem here to allow custom target specs.
let path = Path::new(&target);
if path.extension() == Some(OsStr::new("json")) {
target = path
.file_stem()
.map_or(target.clone(), |stem| stem.to_str().unwrap().to_string());
}

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

has_fpu(&target);
Expand Down

0 comments on commit 2dfbe11

Please sign in to comment.