File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,6 +177,31 @@ than building it.
177177 continue ;
178178 }
179179
180+ // Check if there exists a built-in target in the list of supported targets.
181+ let mut has_target = false ;
182+ let target_str = target. to_string ( ) ;
183+
184+ let supported_target_list = Command :: new ( "rustc" )
185+ . current_dir ( build. config . src . clone ( ) )
186+ . args ( [ "--print" , "target-list" ] )
187+ . output ( )
188+ . expect ( "Should have been able to fetch the target list." ) ;
189+
190+ if let Some ( stdout) = String :: from_utf8 ( supported_target_list. stdout ) . ok ( ) {
191+ has_target |= stdout. contains ( & target_str) ;
192+ }
193+
194+ // If not, check for a valid file location that may have been specified
195+ // by the user for the custom target.
196+ has_target |= env:: var_os ( "RUST_TARGET_PATH" ) . is_some ( ) ;
197+
198+ if !has_target && !( target_str == "A" || target_str == "B" || target_str == "C" ) {
199+ panic ! (
200+ "No such target exists in the target list,
201+ specify a correct location of the JSON specification file for custom targets!"
202+ ) ;
203+ }
204+
180205 if !build. config . dry_run ( ) {
181206 cmd_finder. must_have ( build. cc ( * target) ) ;
182207 if let Some ( ar) = build. ar ( * target) {
You can’t perform that action at this time.
0 commit comments