@@ -3182,68 +3182,99 @@ impl Step for Distcheck {
3182
3182
/// check steps from those sources.
3183
3183
/// - Check that selected dist components (`rust-src` only at the moment) at least have expected
3184
3184
/// directory shape and crate manifests that cargo can generate a lockfile from.
3185
+ /// - Check that we can run `cargo metadata` on the workspace in the `rustc-dev` component
3185
3186
///
3186
3187
/// FIXME(#136822): dist components are under-tested.
3187
3188
fn run ( self , builder : & Builder < ' _ > ) {
3188
3189
// Use a temporary directory completely outside the current checkout, to avoid reusing any
3189
3190
// local source code, built artifacts or configuration by accident
3190
3191
let root_dir = std:: env:: temp_dir ( ) . join ( "distcheck" ) ;
3191
3192
3192
- // Check that we can build some basic things from the plain source tarball
3193
- builder. info ( "Distcheck plain source tarball" ) ;
3194
- let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3195
- let plain_src_dir = root_dir. join ( "distcheck-plain-src" ) ;
3196
- builder. clear_dir ( & plain_src_dir) ;
3197
-
3198
- let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3199
- . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
3200
- . unwrap_or_default ( ) ;
3201
-
3202
- command ( "tar" )
3203
- . arg ( "-xf" )
3204
- . arg ( plain_src_tarball. tarball ( ) )
3205
- . arg ( "--strip-components=1" )
3206
- . current_dir ( & plain_src_dir)
3207
- . run ( builder) ;
3208
- command ( "./configure" )
3209
- . arg ( "--set" )
3210
- . arg ( "rust.omit-git-hash=false" )
3211
- . args ( & configure_args)
3212
- . arg ( "--enable-vendor" )
3213
- . current_dir ( & plain_src_dir)
3214
- . run ( builder) ;
3215
- command ( helpers:: make ( & builder. config . host_target . triple ) )
3216
- . arg ( "check" )
3217
- // Do not run the build as if we were in CI, otherwise git would be assumed to be
3218
- // present, but we build from a tarball here
3219
- . env ( "GITHUB_ACTIONS" , "0" )
3220
- . current_dir ( & plain_src_dir)
3221
- . run ( builder) ;
3222
-
3223
- // Now make sure that rust-src has all of libstd's dependencies
3224
- builder. info ( "Distcheck rust-src" ) ;
3225
- let src_tarball = builder. ensure ( dist:: Src ) ;
3226
- let src_dir = root_dir. join ( "distcheck-src" ) ;
3227
- builder. clear_dir ( & src_dir) ;
3228
-
3229
- command ( "tar" )
3230
- . arg ( "-xf" )
3231
- . arg ( src_tarball. tarball ( ) )
3232
- . arg ( "--strip-components=1" )
3233
- . current_dir ( & src_dir)
3234
- . run ( builder) ;
3235
-
3236
- let toml = src_dir. join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
3237
- command ( & builder. initial_cargo )
3238
- // Will read the libstd Cargo.toml
3239
- // which uses the unstable `public-dependency` feature.
3240
- . env ( "RUSTC_BOOTSTRAP" , "1" )
3241
- . arg ( "generate-lockfile" )
3242
- . arg ( "--manifest-path" )
3243
- . arg ( & toml)
3244
- . current_dir ( & src_dir)
3245
- . run ( builder) ;
3246
- }
3193
+ distcheck_plain_source_tarball ( builder, & root_dir. join ( "distcheck-plain-src" ) ) ;
3194
+ distcheck_rust_src ( builder, & root_dir. join ( "distcheck-src" ) ) ;
3195
+ distcheck_rustc_dev ( builder, & root_dir. join ( "distcheck-rustc-dev" ) ) ;
3196
+ }
3197
+ }
3198
+
3199
+ /// Check that we can build some basic things from the plain source tarball
3200
+ fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : & Path ) {
3201
+ builder. info ( "Distcheck plain source tarball" ) ;
3202
+ let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3203
+ builder. clear_dir ( plain_src_dir) ;
3204
+
3205
+ let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3206
+ . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
3207
+ . unwrap_or_default ( ) ;
3208
+
3209
+ command ( "tar" )
3210
+ . arg ( "-xf" )
3211
+ . arg ( plain_src_tarball. tarball ( ) )
3212
+ . arg ( "--strip-components=1" )
3213
+ . current_dir ( plain_src_dir)
3214
+ . run ( builder) ;
3215
+ command ( "./configure" )
3216
+ . arg ( "--set" )
3217
+ . arg ( "rust.omit-git-hash=false" )
3218
+ . args ( & configure_args)
3219
+ . arg ( "--enable-vendor" )
3220
+ . current_dir ( plain_src_dir)
3221
+ . run ( builder) ;
3222
+ command ( helpers:: make ( & builder. config . host_target . triple ) )
3223
+ . arg ( "check" )
3224
+ // Do not run the build as if we were in CI, otherwise git would be assumed to be
3225
+ // present, but we build from a tarball here
3226
+ . env ( "GITHUB_ACTIONS" , "0" )
3227
+ . current_dir ( plain_src_dir)
3228
+ . run ( builder) ;
3229
+ }
3230
+
3231
+ /// Check that rust-src has all of libstd's dependencies
3232
+ fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : & Path ) {
3233
+ builder. info ( "Distcheck rust-src" ) ;
3234
+ let src_tarball = builder. ensure ( dist:: Src ) ;
3235
+ builder. clear_dir ( src_dir) ;
3236
+
3237
+ command ( "tar" )
3238
+ . arg ( "-xf" )
3239
+ . arg ( src_tarball. tarball ( ) )
3240
+ . arg ( "--strip-components=1" )
3241
+ . current_dir ( src_dir)
3242
+ . run ( builder) ;
3243
+
3244
+ let toml = src_dir. join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
3245
+ command ( & builder. initial_cargo )
3246
+ // Will read the libstd Cargo.toml
3247
+ // which uses the unstable `public-dependency` feature.
3248
+ . env ( "RUSTC_BOOTSTRAP" , "1" )
3249
+ . arg ( "generate-lockfile" )
3250
+ . arg ( "--manifest-path" )
3251
+ . arg ( & toml)
3252
+ . current_dir ( src_dir)
3253
+ . run ( builder) ;
3254
+ }
3255
+
3256
+ /// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
3257
+ fn distcheck_rustc_dev ( builder : & Builder < ' _ > , dir : & Path ) {
3258
+ builder. info ( "Distcheck rustc-dev" ) ;
3259
+ let tarball = builder. ensure ( dist:: RustcDev :: new ( builder, builder. host_target ) ) . unwrap ( ) ;
3260
+ builder. clear_dir ( dir) ;
3261
+
3262
+ command ( "tar" )
3263
+ . arg ( "-xf" )
3264
+ . arg ( tarball. tarball ( ) )
3265
+ . arg ( "--strip-components=1" )
3266
+ . current_dir ( dir)
3267
+ . run ( builder) ;
3268
+
3269
+ command ( & builder. initial_cargo )
3270
+ . arg ( "metadata" )
3271
+ . arg ( "--manifest-path" )
3272
+ . arg ( "rustc-dev/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" )
3273
+ . env ( "RUSTC_BOOTSTRAP" , "1" )
3274
+ // We might not have a globally available `rustc` binary on CI
3275
+ . env ( "RUSTC" , & builder. initial_rustc )
3276
+ . current_dir ( dir)
3277
+ . run ( builder) ;
3247
3278
}
3248
3279
3249
3280
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
0 commit comments