File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,12 +151,7 @@ fn run() -> Result<ExitStatus> {
151151 } ;
152152
153153 let cmode = if let Some ( triple) = args. target ( ) {
154- if Path :: new ( triple) . is_file ( ) {
155- bail ! (
156- "Xargo doesn't support files as an argument to --target. \
157- Use `--target foo` instead of `--target foo.json`."
158- )
159- } else if triple == meta. host {
154+ if triple == meta. host {
160155 Some ( CompilationMode :: Native ( meta. host . clone ( ) ) )
161156 } else {
162157 Target :: new ( triple, & cd, verbose) ?. map ( CompilationMode :: Cross )
Original file line number Diff line number Diff line change @@ -121,6 +121,19 @@ impl Target {
121121 if rustc:: targets ( verbose) ?. iter ( ) . any ( |t| t == & triple) {
122122 Ok ( Some ( Target :: Builtin { triple : triple } ) )
123123 } else {
124+ if Path :: new ( & triple) . exists ( ) {
125+ let path = match Path :: new ( & triple) . canonicalize ( ) {
126+ Ok ( path) => path,
127+ Err ( _) => bail ! ( "target path {:?} is invalid" , triple) ,
128+ } ;
129+ let file_stem = match path. file_stem ( ) . and_then ( |stem| stem. to_str ( ) ) {
130+ Some ( stem) => stem. into ( ) ,
131+ None => {
132+ bail ! ( "target file name {:?} is empty or contains invalid unicode" , path)
133+ }
134+ } ;
135+ return Ok ( Some ( Target :: Custom { json : path, triple : file_stem } ) )
136+ }
124137 let mut json = cd. path ( ) . join ( & triple) ;
125138 json. set_extension ( "json" ) ;
126139
You can’t perform that action at this time.
0 commit comments