@@ -63,6 +63,82 @@ mod solaris_base;
6363mod  windows_base; 
6464mod  windows_msvc_base; 
6565
66+ macro_rules!  supported_targets { 
67+     (  $( ( $triple: expr,  $module: ident) ) ,+ )  => ( 
68+         /// List of supported targets 
69+ pub  const  TARGETS :  & ' static  [ & ' static  str ]  = & [ $( $triple) ,* ] ; 
70+ 
71+         // this would use a match if stringify! were allowed in pattern position 
72+         fn  load_specific( target:  & str )  -> Option <Target > { 
73+             $( mod  $module; ) * 
74+             let  target = target. replace( "-" ,  "_" ) ; 
75+             if  false  {  } 
76+             $( 
77+                 else if  target == stringify!( $module)  { 
78+                     let  t = $module:: target( ) ; 
79+                     debug!( "Got builtin target: {:?}" ,  t) ; 
80+                     return  Some ( t) ; 
81+                 } 
82+             ) * 
83+ 
84+             None 
85+         } 
86+     ) 
87+ } 
88+ 
89+ supported_targets !  { 
90+     ( "x86_64-unknown-linux-gnu" ,  x86_64_unknown_linux_gnu) , 
91+     ( "i686-unknown-linux-gnu" ,  i686_unknown_linux_gnu) , 
92+     ( "mips-unknown-linux-gnu" ,  mips_unknown_linux_gnu) , 
93+     ( "mipsel-unknown-linux-gnu" ,  mipsel_unknown_linux_gnu) , 
94+     ( "powerpc-unknown-linux-gnu" ,  powerpc_unknown_linux_gnu) , 
95+     ( "powerpc64-unknown-linux-gnu" ,  powerpc64_unknown_linux_gnu) , 
96+     ( "powerpc64le-unknown-linux-gnu" ,  powerpc64le_unknown_linux_gnu) , 
97+     ( "arm-unknown-linux-gnueabi" ,  arm_unknown_linux_gnueabi) , 
98+     ( "arm-unknown-linux-gnueabihf" ,  arm_unknown_linux_gnueabihf) , 
99+     ( "armv7-unknown-linux-gnueabihf" ,  armv7_unknown_linux_gnueabihf) , 
100+     ( "aarch64-unknown-linux-gnu" ,  aarch64_unknown_linux_gnu) , 
101+     ( "x86_64-unknown-linux-musl" ,  x86_64_unknown_linux_musl) , 
102+     ( "i686-unknown-linux-musl" ,  i686_unknown_linux_musl) , 
103+     ( "mips-unknown-linux-musl" ,  mips_unknown_linux_musl) , 
104+     ( "mipsel-unknown-linux-musl" ,  mipsel_unknown_linux_musl) , 
105+ 
106+     ( "i686-linux-android" ,  i686_linux_android) , 
107+     ( "arm-linux-androideabi" ,  arm_linux_androideabi) , 
108+     ( "aarch64-linux-android" ,  aarch64_linux_android) , 
109+ 
110+     ( "i686-unknown-freebsd" ,  i686_unknown_freebsd) , 
111+     ( "x86_64-unknown-freebsd" ,  x86_64_unknown_freebsd) , 
112+ 
113+     ( "i686-unknown-dragonfly" ,  i686_unknown_dragonfly) , 
114+     ( "x86_64-unknown-dragonfly" ,  x86_64_unknown_dragonfly) , 
115+ 
116+     ( "x86_64-unknown-bitrig" ,  x86_64_unknown_bitrig) , 
117+     ( "x86_64-unknown-openbsd" ,  x86_64_unknown_openbsd) , 
118+     ( "x86_64-unknown-netbsd" ,  x86_64_unknown_netbsd) , 
119+     ( "x86_64-rumprun-netbsd" ,  x86_64_rumprun_netbsd) , 
120+ 
121+     ( "x86_64-apple-darwin" ,  x86_64_apple_darwin) , 
122+     ( "i686-apple-darwin" ,  i686_apple_darwin) , 
123+ 
124+     ( "i386-apple-ios" ,  i386_apple_ios) , 
125+     ( "x86_64-apple-ios" ,  x86_64_apple_ios) , 
126+     ( "aarch64-apple-ios" ,  aarch64_apple_ios) , 
127+     ( "armv7-apple-ios" ,  armv7_apple_ios) , 
128+     ( "armv7s-apple-ios" ,  armv7s_apple_ios) , 
129+ 
130+     ( "x86_64-sun-solaris" ,  x86_64_sun_solaris) , 
131+ 
132+     ( "x86_64-pc-windows-gnu" ,  x86_64_pc_windows_gnu) , 
133+     ( "i686-pc-windows-gnu" ,  i686_pc_windows_gnu) , 
134+ 
135+     ( "x86_64-pc-windows-msvc" ,  x86_64_pc_windows_msvc) , 
136+     ( "i686-pc-windows-msvc" ,  i686_pc_windows_msvc) , 
137+ 
138+     ( "le32-unknown-nacl" ,  le32_unknown_nacl) , 
139+     ( "asmjs-unknown-emscripten" ,  asmjs_unknown_emscripten) 
140+ } 
141+ 
66142/// Everything `rustc` knows about how to compile for a specific target. 
67143/// 
68144/// Every field here must be specified, and has no default value. 
@@ -393,85 +469,10 @@ impl Target {
393469            Ok ( Target :: from_json ( obj) ) 
394470        } 
395471
396-         // this would use a match if stringify! were allowed in pattern position 
397-         macro_rules!  load_specific { 
398-             (  $( $name: ident) ,+ )  => ( 
399-                 { 
400-                     $( mod  $name; ) * 
401-                     let  target = target. replace( "-" ,  "_" ) ; 
402-                     if  false  {  } 
403-                     $( 
404-                         else if  target == stringify!( $name)  { 
405-                             let  t = $name:: target( ) ; 
406-                             debug!( "Got builtin target: {:?}" ,  t) ; 
407-                             return  Ok ( t) ; 
408-                         } 
409-                     ) * 
410-                     else if  target == "x86_64-w64-mingw32"  { 
411-                         let  t = x86_64_pc_windows_gnu:: target( ) ; 
412-                         return  Ok ( t) ; 
413-                     }  else if  target == "i686-w64-mingw32"  { 
414-                         let  t = i686_pc_windows_gnu:: target( ) ; 
415-                         return  Ok ( t) ; 
416-                     } 
417-                 } 
418-             ) 
472+         if  let  Some ( t)  = load_specific ( target)  { 
473+             return  Ok ( t) 
419474        } 
420475
421-         load_specific ! ( 
422-             x86_64_unknown_linux_gnu, 
423-             i686_unknown_linux_gnu, 
424-             mips_unknown_linux_gnu, 
425-             mipsel_unknown_linux_gnu, 
426-             powerpc_unknown_linux_gnu, 
427-             powerpc64_unknown_linux_gnu, 
428-             powerpc64le_unknown_linux_gnu, 
429-             arm_unknown_linux_gnueabi, 
430-             arm_unknown_linux_gnueabihf, 
431-             armv7_unknown_linux_gnueabihf, 
432-             aarch64_unknown_linux_gnu, 
433-             x86_64_unknown_linux_musl, 
434-             i686_unknown_linux_musl, 
435-             mips_unknown_linux_musl, 
436-             mipsel_unknown_linux_musl, 
437- 
438-             i686_linux_android, 
439-             arm_linux_androideabi, 
440-             aarch64_linux_android, 
441- 
442-             i686_unknown_freebsd, 
443-             x86_64_unknown_freebsd, 
444- 
445-             i686_unknown_dragonfly, 
446-             x86_64_unknown_dragonfly, 
447- 
448-             x86_64_unknown_bitrig, 
449-             x86_64_unknown_openbsd, 
450-             x86_64_unknown_netbsd, 
451-             x86_64_rumprun_netbsd, 
452- 
453-             x86_64_apple_darwin, 
454-             i686_apple_darwin, 
455- 
456-             i386_apple_ios, 
457-             x86_64_apple_ios, 
458-             aarch64_apple_ios, 
459-             armv7_apple_ios, 
460-             armv7s_apple_ios, 
461- 
462-             x86_64_sun_solaris, 
463- 
464-             x86_64_pc_windows_gnu, 
465-             i686_pc_windows_gnu, 
466- 
467-             x86_64_pc_windows_msvc, 
468-             i686_pc_windows_msvc, 
469- 
470-             le32_unknown_nacl, 
471-             asmjs_unknown_emscripten
472-         ) ; 
473- 
474- 
475476        let  path = Path :: new ( target) ; 
476477
477478        if  path. is_file ( )  { 
0 commit comments