@@ -8,8 +8,8 @@ use crate::error::Result;
88use crate :: repositories:: RepositoryStatsUpdater ;
99use crate :: storage:: { rustdoc_archive_path, source_archive_path} ;
1010use crate :: utils:: {
11- copy_dir_all, parse_rustc_version, queue_builder, report_error, set_config, CargoMetadata ,
12- ConfigName ,
11+ copy_dir_all, get_config , parse_rustc_version, queue_builder, report_error, set_config,
12+ CargoMetadata , ConfigName ,
1313} ;
1414use crate :: RUSTDOC_STATIC_STORAGE_PREFIX ;
1515use crate :: { db:: blacklist:: is_blacklisted, utils:: MetadataPackage } ;
@@ -33,6 +33,21 @@ const COMPONENTS: &[&str] = &["llvm-tools-preview", "rustc-dev", "rustfmt"];
3333const DUMMY_CRATE_NAME : & str = "empty-library" ;
3434const DUMMY_CRATE_VERSION : & str = "1.0.0" ;
3535
36+ fn get_configured_toolchain ( conn : & mut Client ) -> Result < Toolchain > {
37+ let name: String = get_config ( conn, ConfigName :: Toolchain ) ?. unwrap_or_else ( || "nightly" . into ( ) ) ;
38+
39+ // If the toolchain is all hex, assume it references an artifact from
40+ // CI, for instance an `@bors try` build.
41+ let re = Regex :: new ( r"^[a-fA-F0-9]+$" ) . unwrap ( ) ;
42+ if re. is_match ( & name) {
43+ debug ! ( "using CI build {}" , & name) ;
44+ Ok ( Toolchain :: ci ( & name, false ) )
45+ } else {
46+ debug ! ( "using toolchain {}" , & name) ;
47+ Ok ( Toolchain :: dist ( & name) )
48+ }
49+ }
50+
3651pub enum PackageKind < ' a > {
3752 Local ( & ' a Path ) ,
3853 CratesIo ,
@@ -75,22 +90,13 @@ impl RustwideBuilder {
7590 . purge_all_build_dirs ( )
7691 . map_err ( FailureError :: compat) ?;
7792
78- // If the toolchain is all hex, assume it references an artifact from
79- // CI, for instance an `@bors try` build.
80- let re = Regex :: new ( r"^[a-fA-F0-9]+$" ) . unwrap ( ) ;
81- let toolchain = if re. is_match ( & config. toolchain ) {
82- debug ! ( "using CI build {}" , & config. toolchain) ;
83- Toolchain :: ci ( & config. toolchain , false )
84- } else {
85- debug ! ( "using toolchain {}" , & config. toolchain) ;
86- Toolchain :: dist ( & config. toolchain )
87- } ;
93+ let pool = context. pool ( ) ?;
8894
8995 Ok ( RustwideBuilder {
9096 workspace,
91- toolchain,
97+ toolchain : get_configured_toolchain ( & mut * pool . get ( ) ? ) ? ,
9298 config,
93- db : context . pool ( ) ? ,
99+ db : pool,
94100 storage : context. storage ( ) ?,
95101 metrics : context. instance_metrics ( ) ?,
96102 index : context. index ( ) ?,
@@ -119,6 +125,8 @@ impl RustwideBuilder {
119125 }
120126
121127 pub fn update_toolchain ( & mut self ) -> Result < bool > {
128+ self . toolchain = get_configured_toolchain ( & mut * self . db . get ( ) ?) ?;
129+
122130 // For CI builds, a lot of the normal update_toolchain things don't apply.
123131 // CI builds are only for one platform (https://forge.rust-lang.org/infra/docs/rustc-ci.html#try-builds)
124132 // so we only try installing for the current platform. If that's not a match,
0 commit comments