@@ -637,6 +637,28 @@ impl Step for DebuggerScripts {
637
637
}
638
638
}
639
639
640
+ fn skip_host_target_lib ( builder : & Builder < ' _ > , compiler : Compiler ) -> bool {
641
+ // The only true set of target libraries came from the build triple, so
642
+ // let's reduce redundant work by only producing archives from that host.
643
+ if compiler. host != builder. config . build {
644
+ builder. info ( "\t skipping, not a build host" ) ;
645
+ true
646
+ } else {
647
+ false
648
+ }
649
+ }
650
+
651
+ /// Copy stamped files into an image's `target/lib` directory.
652
+ fn copy_target_libs ( builder : & Builder < ' _ > , target : & str , image : & Path , stamp : & Path ) {
653
+ let dst = image. join ( "lib/rustlib" ) . join ( target) . join ( "lib" ) ;
654
+ t ! ( fs:: create_dir_all( & dst) ) ;
655
+ for ( path, host) in builder. read_stamp_file ( stamp) {
656
+ if !host || builder. config . build == target {
657
+ builder. copy ( & path, & dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
658
+ }
659
+ }
660
+ }
661
+
640
662
#[ derive( Debug , PartialOrd , Ord , Copy , Clone , Hash , PartialEq , Eq ) ]
641
663
pub struct Std {
642
664
pub compiler : Compiler ,
@@ -667,29 +689,19 @@ impl Step for Std {
667
689
let target = self . target ;
668
690
669
691
let name = pkgname ( builder, "rust-std" ) ;
670
-
671
- // The only true set of target libraries came from the build triple, so
672
- // let's reduce redundant work by only producing archives from that host.
673
- if compiler. host != builder. config . build {
674
- builder. info ( "\t skipping, not a build host" ) ;
675
- return distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
692
+ let archive = distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
693
+ if skip_host_target_lib ( builder, compiler) {
694
+ return archive;
676
695
}
677
696
678
697
builder. ensure ( compile:: Std { compiler, target } ) ;
679
698
680
699
let image = tmpdir ( builder) . join ( format ! ( "{}-{}-image" , name, target) ) ;
681
700
let _ = fs:: remove_dir_all ( & image) ;
682
701
683
- let dst = image. join ( "lib/rustlib" ) . join ( target) . join ( "lib" ) ;
684
- t ! ( fs:: create_dir_all( & dst) ) ;
685
-
686
702
let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
687
- let stamp = dbg ! ( compile:: libstd_stamp( builder, compiler_to_use, target) ) ;
688
- for ( path, host) in builder. read_stamp_file ( & stamp) {
689
- if !host {
690
- builder. copy ( & path, & dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
691
- }
692
- }
703
+ let stamp = compile:: libstd_stamp ( builder, compiler_to_use, target) ;
704
+ copy_target_libs ( builder, & target, & image, & stamp) ;
693
705
694
706
let mut cmd = rust_installer ( builder) ;
695
707
cmd. arg ( "generate" )
@@ -708,26 +720,27 @@ impl Step for Std {
708
720
let _time = timeit ( builder) ;
709
721
builder. run ( & mut cmd) ;
710
722
builder. remove_dir ( & image) ;
711
- distdir ( builder ) . join ( format ! ( "{}-{}.tar.gz" , name , target ) )
723
+ archive
712
724
}
713
725
}
714
726
715
727
#[ derive( Debug , PartialOrd , Ord , Copy , Clone , Hash , PartialEq , Eq ) ]
716
- pub struct StdZ {
728
+ pub struct RustcDev {
717
729
pub compiler : Compiler ,
718
730
pub target : Interned < String > ,
719
731
}
720
732
721
- impl Step for StdZ {
733
+ impl Step for RustcDev {
722
734
type Output = PathBuf ;
723
735
const DEFAULT : bool = true ;
736
+ const ONLY_HOSTS : bool = true ;
724
737
725
738
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
726
- run. path ( "src/libstdZ " )
739
+ run. path ( "rustc-dev " )
727
740
}
728
741
729
742
fn make_run ( run : RunConfig < ' _ > ) {
730
- run. builder . ensure ( StdZ {
743
+ run. builder . ensure ( RustcDev {
731
744
compiler : run. builder . compiler_for (
732
745
run. builder . top_stage ,
733
746
run. builder . config . build ,
@@ -741,64 +754,39 @@ impl Step for StdZ {
741
754
let compiler = self . compiler ;
742
755
let target = self . target ;
743
756
744
- let name = pkgname ( builder, "rust-stdZ" ) ;
745
-
746
- // The only true set of target libraries came from the build triple, so
747
- // let's reduce redundant work by only producing archives from that host.
748
- if compiler. host != builder. config . build {
749
- builder. info ( "\t skipping, not a build host" ) ;
750
- return distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
757
+ let name = pkgname ( builder, "rustc-dev" ) ;
758
+ let archive = distdir ( builder) . join ( format ! ( "{}-{}.tar.gz" , name, target) ) ;
759
+ if skip_host_target_lib ( builder, compiler) {
760
+ return archive;
751
761
}
752
762
753
- // We want to package up as many target libraries as possible
754
- // for the `rust-std` package, so if this is a host target we
755
- // depend on librustc and otherwise we just depend on libtest.
756
- if builder. hosts . iter ( ) . any ( |t| t == target) {
757
- builder. ensure ( compile:: Rustc { compiler, target } ) ;
758
- } else {
759
- builder. ensure ( compile:: Std { compiler, target } ) ;
760
- }
763
+ builder. ensure ( compile:: Rustc { compiler, target } ) ;
761
764
762
765
let image = tmpdir ( builder) . join ( format ! ( "{}-{}-image" , name, target) ) ;
763
766
let _ = fs:: remove_dir_all ( & image) ;
764
767
765
- let dst = image. join ( "lib/rustlib" ) . join ( target) ;
766
- t ! ( fs:: create_dir_all( & dst) ) ;
767
- let mut src = builder. sysroot_libdir ( compiler, target) . to_path_buf ( ) ;
768
- src. pop ( ) ; // Remove the trailing /lib folder from the sysroot_libdir
769
- builder. cp_filtered ( & src, & dst, & |path| {
770
- if let Some ( name) = path. file_name ( ) . and_then ( |s| s. to_str ( ) ) {
771
- if name == builder. config . rust_codegen_backends_dir . as_str ( ) {
772
- return false
773
- }
774
- if name == "bin" {
775
- return false
776
- }
777
- if name. contains ( "LLVM" ) {
778
- return false
779
- }
780
- }
781
- true
782
- } ) ;
768
+ let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
769
+ let stamp = compile:: librustc_stamp ( builder, compiler_to_use, target) ;
770
+ copy_target_libs ( builder, & target, & image, & stamp) ;
783
771
784
772
let mut cmd = rust_installer ( builder) ;
785
773
cmd. arg ( "generate" )
786
774
. arg ( "--product-name=Rust" )
787
775
. arg ( "--rel-manifest-dir=rustlib" )
788
- . arg ( "--success-message=stdZ -is-standing-at-the-ready ." )
776
+ . arg ( "--success-message=Rust -is-ready-to-develop ." )
789
777
. arg ( "--image-dir" ) . arg ( & image)
790
778
. arg ( "--work-dir" ) . arg ( & tmpdir ( builder) )
791
779
. arg ( "--output-dir" ) . arg ( & distdir ( builder) )
792
780
. arg ( format ! ( "--package-name={}-{}" , name, target) )
793
- . arg ( format ! ( "--component-name=rust-stdZ -{}" , target) )
781
+ . arg ( format ! ( "--component-name=rustc-dev -{}" , target) )
794
782
. arg ( "--legacy-manifest-dirs=rustlib,cargo" ) ;
795
783
796
- builder. info ( & format ! ( "Dist std stage{} ({} -> {})" ,
784
+ builder. info ( & format ! ( "Dist rustc-dev stage{} ({} -> {})" ,
797
785
compiler. stage, & compiler. host, target) ) ;
798
786
let _time = timeit ( builder) ;
799
787
builder. run ( & mut cmd) ;
800
788
builder. remove_dir ( & image) ;
801
- distdir ( builder ) . join ( format ! ( "{}-{}.tar.gz" , name , target ) )
789
+ archive
802
790
}
803
791
}
804
792
0 commit comments