Skip to content

Commit

Permalink
skip tar generation and compression for x install
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Dec 7, 2023
1 parent 8abfe2b commit ead999c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 64 deletions.
77 changes: 59 additions & 18 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool {
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Docs {
pub host: TargetSelection,
pub prepare_only: bool,
}

impl Step for Docs {
Expand All @@ -65,7 +66,7 @@ impl Step for Docs {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Docs { host: run.target });
run.builder.ensure(Docs { host: run.target, prepare_only: false });
}

/// Builds the `rust-docs` installer component.
Expand All @@ -77,6 +78,7 @@ impl Step for Docs {

let mut tarball = Tarball::new(builder, "rust-docs", &host.triple);
tarball.set_product_name("Rust Documentation");
tarball.is_prepare_only(self.prepare_only);
tarball.add_bulk_dir(&builder.doc_out(host), dest);
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
Some(tarball.generate())
Expand Down Expand Up @@ -351,6 +353,7 @@ impl Step for Mingw {
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustc {
pub compiler: Compiler,
pub prepare_only: bool,
}

impl Step for Rustc {
Expand All @@ -363,16 +366,19 @@ impl Step for Rustc {
}

fn make_run(run: RunConfig<'_>) {
run.builder
.ensure(Rustc { compiler: run.builder.compiler(run.builder.top_stage, run.target) });
run.builder.ensure(Rustc {
compiler: run.builder.compiler(run.builder.top_stage, run.target),
prepare_only: false,
});
}

/// Creates the `rustc` installer component.
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
let compiler = self.compiler;
let host = self.compiler.host;

let tarball = Tarball::new(builder, "rustc", &host.triple);
let mut tarball = Tarball::new(builder, "rustc", &host.triple);
tarball.is_prepare_only(self.prepare_only);

// Prepare the rustc "image", what will actually end up getting installed
prepare_image(builder, compiler, tarball.image_dir());
Expand Down Expand Up @@ -620,6 +626,7 @@ fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path
pub struct Std {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for Std {
Expand All @@ -638,6 +645,7 @@ impl Step for Std {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -652,6 +660,7 @@ impl Step for Std {
builder.ensure(compile::Std::new(compiler, target));

let mut tarball = Tarball::new(builder, "rust-std", &target.triple);
tarball.is_prepare_only(self.prepare_only);
tarball.include_target_in_component_name(true);

let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
Expand Down Expand Up @@ -870,7 +879,9 @@ fn copy_src_dirs(
}

#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Src;
pub struct Src {
pub prepare_only: bool,
}

impl Step for Src {
/// The output path of the src installer tarball
Expand All @@ -883,7 +894,7 @@ impl Step for Src {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Src);
run.builder.ensure(Src { prepare_only: false });
}

/// Creates the `rust-src` installer component
Expand All @@ -892,7 +903,8 @@ impl Step for Src {
builder.update_submodule(&Path::new("src/llvm-project"));
}

let tarball = Tarball::new_targetless(builder, "rust-src");
let mut tarball = Tarball::new_targetless(builder, "rust-src");
tarball.is_prepare_only(self.prepare_only);

// A lot of tools expect the rust-src component to be entirely in this directory, so if you
// change that (e.g. by adding another directory `lib/rustlib/src/foo` or
Expand Down Expand Up @@ -1034,6 +1046,7 @@ impl Step for PlainSourceTarball {
pub struct Cargo {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for Cargo {
Expand All @@ -1054,6 +1067,7 @@ impl Step for Cargo {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1068,6 +1082,7 @@ impl Step for Cargo {
// Prepare the image directory
let mut tarball = Tarball::new(builder, "cargo", &target.triple);
tarball.set_overlay(OverlayKind::Cargo);
tarball.is_prepare_only(self.prepare_only);

tarball.add_file(&cargo, "bin", 0o755);
tarball.add_file(etc.join("_cargo"), "share/zsh/site-functions", 0o644);
Expand Down Expand Up @@ -1127,6 +1142,7 @@ impl Step for Rls {
pub struct RustAnalyzer {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for RustAnalyzer {
Expand All @@ -1147,6 +1163,7 @@ impl Step for RustAnalyzer {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1160,6 +1177,7 @@ impl Step for RustAnalyzer {

let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);
tarball.set_overlay(OverlayKind::RustAnalyzer);
tarball.is_prepare_only(self.prepare_only);
tarball.is_preview(true);
tarball.add_file(rust_analyzer, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/rust-analyzer");
Expand All @@ -1171,6 +1189,7 @@ impl Step for RustAnalyzer {
pub struct Clippy {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for Clippy {
Expand All @@ -1191,6 +1210,7 @@ impl Step for Clippy {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1210,6 +1230,7 @@ impl Step for Clippy {

let mut tarball = Tarball::new(builder, "clippy", &target.triple);
tarball.set_overlay(OverlayKind::Clippy);
tarball.is_prepare_only(self.prepare_only);
tarball.is_preview(true);
tarball.add_file(clippy, "bin", 0o755);
tarball.add_file(cargoclippy, "bin", 0o755);
Expand All @@ -1222,6 +1243,7 @@ impl Step for Clippy {
pub struct Miri {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for Miri {
Expand All @@ -1242,6 +1264,7 @@ impl Step for Miri {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1262,6 +1285,7 @@ impl Step for Miri {
let mut tarball = Tarball::new(builder, "miri", &target.triple);
tarball.set_overlay(OverlayKind::Miri);
tarball.is_preview(true);
tarball.is_prepare_only(self.prepare_only);
tarball.add_file(miri, "bin", 0o755);
tarball.add_file(cargomiri, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/miri");
Expand All @@ -1273,6 +1297,7 @@ impl Step for Miri {
pub struct CodegenBackend {
pub compiler: Compiler,
pub backend: Interned<String>,
pub prepare_only: bool,
}

impl Step for CodegenBackend {
Expand All @@ -1293,6 +1318,7 @@ impl Step for CodegenBackend {
run.builder.ensure(CodegenBackend {
compiler: run.builder.compiler(run.builder.top_stage, run.target),
backend,
prepare_only: false,
});
}
}
Expand Down Expand Up @@ -1338,6 +1364,7 @@ impl Step for CodegenBackend {
panic!("Unknown backend rustc_codegen_{}", backend);
}
tarball.is_preview(true);
tarball.is_prepare_only(self.prepare_only);
tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{}", backend));

let src = builder.sysroot(compiler);
Expand Down Expand Up @@ -1369,6 +1396,7 @@ impl Step for CodegenBackend {
pub struct Rustfmt {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for Rustfmt {
Expand All @@ -1389,6 +1417,7 @@ impl Step for Rustfmt {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1405,6 +1434,7 @@ impl Step for Rustfmt {
let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
tarball.set_overlay(OverlayKind::Rustfmt);
tarball.is_preview(true);
tarball.is_prepare_only(self.prepare_only);
tarball.add_file(rustfmt, "bin", 0o755);
tarball.add_file(cargofmt, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/rustfmt");
Expand All @@ -1416,6 +1446,7 @@ impl Step for Rustfmt {
pub struct RustDemangler {
pub compiler: Compiler,
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for RustDemangler {
Expand All @@ -1441,6 +1472,7 @@ impl Step for RustDemangler {
run.target,
),
target: run.target,
prepare_only: false,
});
}

Expand All @@ -1463,6 +1495,7 @@ impl Step for RustDemangler {
let mut tarball = Tarball::new(builder, "rust-demangler", &target.triple);
tarball.set_overlay(OverlayKind::RustDemangler);
tarball.is_preview(true);
tarball.is_prepare_only(self.prepare_only);
tarball.add_file(&rust_demangler, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/rust-demangler");
Some(tarball.generate())
Expand Down Expand Up @@ -1517,27 +1550,33 @@ impl Step for Extended {
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
// the std files during uninstall. To do this ensure that rustc comes
// before rust-std in the list below.
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
tarballs.push(
builder
.ensure(Rustc { compiler: builder.compiler(stage, target), prepare_only: false }),
);
tarballs.push(
builder.ensure(Std { compiler, target, prepare_only: false }).expect("missing std"),
);

if target.ends_with("windows-gnu") {
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
}

add_component!("rust-docs" => Docs { host: target });
add_component!("rust-docs" => Docs { host: target, prepare_only: false });
add_component!("rust-json-docs" => JsonDocs { host: target });
add_component!("rust-demangler"=> RustDemangler { compiler, target });
add_component!("cargo" => Cargo { compiler, target });
add_component!("rustfmt" => Rustfmt { compiler, target });
add_component!("rust-demangler"=> RustDemangler { compiler, target, prepare_only: false });
add_component!("cargo" => Cargo { compiler, target, prepare_only: false });
add_component!("rustfmt" => Rustfmt { compiler, target, prepare_only: false });
add_component!("rls" => Rls { compiler, target });
add_component!("rust-analyzer" => RustAnalyzer { compiler, target });
add_component!("llvm-components" => LlvmTools { target });
add_component!("clippy" => Clippy { compiler, target });
add_component!("miri" => Miri { compiler, target });
add_component!("rust-analyzer" => RustAnalyzer { compiler, target, prepare_only: false });
add_component!("llvm-components" => LlvmTools { target, prepare_only: false });
add_component!("clippy" => Clippy { compiler, target, prepare_only: false });
add_component!("miri" => Miri { compiler, target, prepare_only: false });
add_component!("analysis" => Analysis { compiler, target });
add_component!("rustc-codegen-cranelift" => CodegenBackend {
compiler: builder.compiler(stage, target),
backend: INTERNER.intern_str("cranelift"),
prepare_only: false
});

let etc = builder.src.join("src/etc/installer");
Expand Down Expand Up @@ -2123,6 +2162,7 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct LlvmTools {
pub target: TargetSelection,
pub prepare_only: bool,
}

impl Step for LlvmTools {
Expand All @@ -2137,7 +2177,7 @@ impl Step for LlvmTools {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(LlvmTools { target: run.target });
run.builder.ensure(LlvmTools { target: run.target, prepare_only: false });
}

fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
Expand All @@ -2156,6 +2196,7 @@ impl Step for LlvmTools {
let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
tarball.set_overlay(OverlayKind::LLVM);
tarball.is_preview(true);
tarball.is_prepare_only(self.prepare_only);

// Prepare the image directory
let src_bindir = builder.llvm_out(target).join("bin");
Expand Down
Loading

0 comments on commit ead999c

Please sign in to comment.