File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1- use std:: env;
21use std:: fs:: { self , File } ;
32use std:: io:: Write ;
4- use std:: path:: PathBuf ;
3+ use std:: path:: { Path , PathBuf } ;
4+ use std:: { env, ffi:: OsStr } ;
55
66fn main ( ) {
7- let target = env:: var ( "TARGET" ) . unwrap ( ) ;
7+ let mut target = env:: var ( "TARGET" ) . unwrap ( ) ;
8+
9+ // When using a custom target JSON, `$TARGET` contains the path to that JSON file. By
10+ // convention, these files are named after the actual target triple, eg.
11+ // `thumbv7m-customos-elf.json`, so we extract the file stem here to allow custom target specs.
12+ let path = Path :: new ( & target) ;
13+ if path. extension ( ) == Some ( OsStr :: new ( "json" ) ) {
14+ target = path
15+ . file_stem ( )
16+ . map_or ( target. clone ( ) , |stem| stem. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
17+ }
18+
819 let out_dir = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
920
1021 has_fpu ( & target) ;
You can’t perform that action at this time.
0 commit comments