File tree 1 file changed +14
-3
lines changed 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
- use std:: env;
2
1
use std:: fs:: { self , File } ;
3
2
use std:: io:: Write ;
4
- use std:: path:: PathBuf ;
3
+ use std:: path:: { Path , PathBuf } ;
4
+ use std:: { env, ffi:: OsStr } ;
5
5
6
6
fn 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
+
8
19
let out_dir = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
9
20
10
21
has_fpu ( & target) ;
You can’t perform that action at this time.
0 commit comments