Skip to content

Commit 7248f67

Browse files
committed
Build the rustc-src tarball before the rust-src component
1 parent 2b4c911 commit 7248f67

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

src/bootstrap/dist.rs

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,11 @@ pub fn rust_src(build: &Build) {
369369

370370
println!("Dist src");
371371

372-
let name = pkgname(build, "rust-src");
373-
let image = tmpdir(build).join(format!("{}-image", name));
374-
let _ = fs::remove_dir_all(&image);
375-
376-
let dst = image.join("lib/rustlib/src");
377-
let dst_src = dst.join("rust");
378-
t!(fs::create_dir_all(&dst_src));
372+
// Make sure that the root folder of tarball has the correct name
373+
let plain_name = format!("rustc-{}-src", build.rust_package_vers());
374+
let plain_dst_src = tmpdir(build).join(&plain_name);
375+
let _ = fs::remove_dir_all(&plain_dst_src);
376+
t!(fs::create_dir_all(&plain_dst_src));
379377

380378
// This is the set of root paths which will become part of the source package
381379
let src_files = [
@@ -424,13 +422,13 @@ pub fn rust_src(build: &Build) {
424422

425423
// Copy the directories using our filter
426424
for item in &src_dirs {
427-
let dst = &dst_src.join(item);
425+
let dst = &plain_dst_src.join(item);
428426
t!(fs::create_dir(dst));
429427
cp_filtered(&build.src.join(item), dst, &filter_fn);
430428
}
431429
// Copy the files normally
432430
for item in &src_files {
433-
copy(&build.src.join(item), &dst_src.join(item));
431+
copy(&build.src.join(item), &plain_dst_src.join(item));
434432
}
435433

436434
// If we're building from git sources, we need to vendor a complete distribution.
@@ -455,10 +453,35 @@ pub fn rust_src(build: &Build) {
455453
// Vendor all Cargo dependencies
456454
let mut cmd = Command::new(&build.cargo);
457455
cmd.arg("vendor")
458-
.current_dir(&dst_src.join("src"));
456+
.current_dir(&plain_dst_src.join("src"));
459457
build.run(&mut cmd);
460458
}
461459

460+
// Create the version file
461+
write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes());
462+
463+
// Create plain source tarball
464+
let tarball = rust_src_location(build);
465+
if let Some(dir) = tarball.parent() {
466+
t!(fs::create_dir_all(dir));
467+
}
468+
let mut cmd = Command::new("tar");
469+
cmd.arg("-czf").arg(sanitize_sh(&tarball))
470+
.arg(&plain_name)
471+
.current_dir(tmpdir(build));
472+
build.run(&mut cmd);
473+
474+
475+
let name = pkgname(build, "rust-src");
476+
let image = tmpdir(build).join(format!("{}-image", name));
477+
let _ = fs::remove_dir_all(&image);
478+
479+
let dst = image.join("lib/rustlib/src");
480+
let dst_src = dst.join("rust");
481+
t!(fs::create_dir_all(&dst_src));
482+
483+
cp_r(&plain_dst_src, &dst_src);
484+
462485
// Create source tarball in rust-installer format
463486
let mut cmd = Command::new(SH_CMD);
464487
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
@@ -473,23 +496,6 @@ pub fn rust_src(build: &Build) {
473496
.arg("--legacy-manifest-dirs=rustlib,cargo");
474497
build.run(&mut cmd);
475498

476-
// Rename directory, so that root folder of tarball has the correct name
477-
let plain_name = format!("rustc-{}-src", build.rust_package_vers());
478-
let plain_dst_src = tmpdir(build).join(&plain_name);
479-
let _ = fs::remove_dir_all(&plain_dst_src);
480-
t!(fs::create_dir_all(&plain_dst_src));
481-
cp_r(&dst_src, &plain_dst_src);
482-
483-
// Create the version file
484-
write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes());
485-
486-
// Create plain source tarball
487-
let mut cmd = Command::new("tar");
488-
cmd.arg("-czf").arg(sanitize_sh(&rust_src_location(build)))
489-
.arg(&plain_name)
490-
.current_dir(tmpdir(build));
491-
build.run(&mut cmd);
492-
493499
t!(fs::remove_dir_all(&image));
494500
t!(fs::remove_dir_all(&plain_dst_src));
495501
}

0 commit comments

Comments
 (0)