@@ -748,6 +748,7 @@ macro_rules! tool_extended {
748
748
stable = $stable: expr
749
749
$( , tool_std = $tool_std: literal) ?
750
750
$( , allow_features = $allow_features: expr) ?
751
+ $( , add_bins_to_sysroot = $add_bins_to_sysroot: expr) ?
751
752
; ) +) => {
752
753
$(
753
754
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
@@ -790,7 +791,7 @@ macro_rules! tool_extended {
790
791
791
792
#[ allow( unused_mut) ]
792
793
fn run( mut $sel, $builder: & Builder <' _>) -> Option <PathBuf > {
793
- $builder. ensure( ToolBuild {
794
+ let tool = $builder. ensure( ToolBuild {
794
795
compiler: $sel. compiler,
795
796
target: $sel. target,
796
797
tool: $tool_name,
@@ -800,7 +801,27 @@ macro_rules! tool_extended {
800
801
is_optional_tool: true ,
801
802
source_type: SourceType :: InTree ,
802
803
allow_features: concat!( $( $allow_features) * ) ,
803
- } )
804
+ } ) ?;
805
+
806
+ if ( false $( || !$add_bins_to_sysroot. is_empty( ) ) ?) && $sel. compiler. stage > 0 {
807
+ let bindir = $builder. sysroot( $sel. compiler) . join( "bin" ) ;
808
+ t!( fs:: create_dir_all( & bindir) ) ;
809
+
810
+ #[ allow( unused_variables) ]
811
+ let tools_out = $builder
812
+ . cargo_out( $sel. compiler, Mode :: ToolRustc , $sel. target) ;
813
+
814
+ $( for add_bin in $add_bins_to_sysroot {
815
+ let bin_source = tools_out. join( exe( add_bin, $sel. target) ) ;
816
+ let bin_destination = bindir. join( exe( add_bin, $sel. compiler. host) ) ;
817
+ $builder. copy( & bin_source, & bin_destination) ;
818
+ } ) ?
819
+
820
+ let tool = bindir. join( exe( $tool_name, $sel. compiler. host) ) ;
821
+ Some ( tool)
822
+ } else {
823
+ Some ( tool)
824
+ }
804
825
}
805
826
}
806
827
) +
@@ -814,15 +835,15 @@ macro_rules! tool_extended {
814
835
tool_extended ! ( ( self , builder) ,
815
836
Cargofmt , "src/tools/rustfmt" , "cargo-fmt" , stable=true ;
816
837
CargoClippy , "src/tools/clippy" , "cargo-clippy" , stable=true ;
817
- Clippy , "src/tools/clippy" , "clippy-driver" , stable=true ;
818
- Miri , "src/tools/miri" , "miri" , stable=false ;
819
- CargoMiri , "src/tools/miri/cargo-miri" , "cargo-miri" , stable=true ;
838
+ Clippy , "src/tools/clippy" , "clippy-driver" , stable=true , add_bins_to_sysroot = [ "clippy-driver" , "cargo-clippy" ] ;
839
+ Miri , "src/tools/miri" , "miri" , stable=false , add_bins_to_sysroot = [ "miri" ] ;
840
+ CargoMiri , "src/tools/miri/cargo-miri" , "cargo-miri" , stable=true , add_bins_to_sysroot = [ "cargo-miri" ] ;
820
841
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
821
842
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
822
843
// and this is close enough for now.
823
844
Rls , "src/tools/rls" , "rls" , stable=true , tool_std=true ;
824
845
RustDemangler , "src/tools/rust-demangler" , "rust-demangler" , stable=false , tool_std=true ;
825
- Rustfmt , "src/tools/rustfmt" , "rustfmt" , stable=true ;
846
+ Rustfmt , "src/tools/rustfmt" , "rustfmt" , stable=true , add_bins_to_sysroot = [ "rustfmt" , "cargo-fmt" ] ;
826
847
) ;
827
848
828
849
impl < ' a > Builder < ' a > {
0 commit comments