Skip to content

Commit 2a21a84

Browse files
Fix a few errors introduced during rebase.
1 parent 2a63901 commit 2a21a84

File tree

4 files changed

+122
-63
lines changed

4 files changed

+122
-63
lines changed

src/bootstrap/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ impl<'a> Builder<'a> {
192192
impl<'a> Step<'a> for Libdir<'a> {
193193
type Output = PathBuf;
194194
fn run(self, builder: &Builder) -> PathBuf {
195+
let compiler = self.compiler;
195196
let lib = if compiler.stage >= 2 && builder.build.config.libdir_relative.is_some() {
196-
builder.build.config.libdir_relative.cloned().unwrap()
197+
builder.build.config.libdir_relative.clone().unwrap()
197198
} else {
198199
PathBuf::from("lib")
199200
};

src/bootstrap/check.rs

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -701,40 +701,63 @@ impl<'a> Step<'a> for Compiletest<'a> {
701701
}
702702
}
703703

704+
#[derive(Serialize)]
705+
pub struct Docs<'a> {
706+
compiler: Compiler<'a>,
707+
}
708+
704709
// rules.test("check-docs", "src/doc")
705710
// .dep(|s| s.name("libtest"))
706711
// .default(true)
707712
// .host(true)
708713
// .run(move |s| check::docs(build, &s.compiler()));
709-
/// Run `rustdoc --test` for all documentation in `src/doc`.
710-
///
711-
/// This will run all tests in our markdown documentation (e.g. the book)
712-
/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
713-
/// `compiler`.
714-
pub fn docs(build: &Build, compiler: &Compiler) {
715-
// Do a breadth-first traversal of the `src/doc` directory and just run
716-
// tests for all files that end in `*.md`
717-
let mut stack = vec![build.src.join("src/doc")];
718-
let _time = util::timeit();
719-
let _folder = build.fold_output(|| "test_docs");
720-
721-
while let Some(p) = stack.pop() {
722-
if p.is_dir() {
723-
stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
724-
continue
725-
}
714+
impl<'a> Step<'a> for Docs<'a> {
715+
type Output = ();
716+
const DEFAULT: bool = true;
717+
const ONLY_HOSTS: bool = true;
726718

727-
if p.extension().and_then(|s| s.to_str()) != Some("md") {
728-
continue;
729-
}
719+
fn should_run(_builder: &Builder, path: &Path) -> bool {
720+
path.ends_with("src/doc")
721+
}
730722

731-
// The nostarch directory in the book is for no starch, and so isn't
732-
// guaranteed to build. We don't care if it doesn't build, so skip it.
733-
if p.to_str().map_or(false, |p| p.contains("nostarch")) {
734-
continue;
735-
}
723+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, _target: &str) {
724+
builder.ensure(Docs {
725+
compiler: builder.compiler(builder.top_stage, host),
726+
});
727+
}
728+
729+
/// Run `rustdoc --test` for all documentation in `src/doc`.
730+
///
731+
/// This will run all tests in our markdown documentation (e.g. the book)
732+
/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
733+
/// `compiler`.
734+
fn run(self, builder: &Builder) {
735+
let build = builder.build;
736+
let compiler = self.compiler;
737+
// Do a breadth-first traversal of the `src/doc` directory and just run
738+
// tests for all files that end in `*.md`
739+
let mut stack = vec![build.src.join("src/doc")];
740+
let _time = util::timeit();
741+
let _folder = build.fold_output(|| "test_docs");
736742

737-
markdown_test(build, compiler, &p);
743+
while let Some(p) = stack.pop() {
744+
if p.is_dir() {
745+
stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
746+
continue
747+
}
748+
749+
if p.extension().and_then(|s| s.to_str()) != Some("md") {
750+
continue;
751+
}
752+
753+
// The nostarch directory in the book is for no starch, and so isn't
754+
// guaranteed to build. We don't care if it doesn't build, so skip it.
755+
if p.to_str().map_or(false, |p| p.contains("nostarch")) {
756+
continue;
757+
}
758+
759+
markdown_test(builder, compiler, &p);
760+
}
738761
}
739762
}
740763

src/bootstrap/dist.rs

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -553,29 +553,76 @@ impl<'a> Step<'a> for DebuggerScripts<'a> {
553553
// .dep(move |s| tool_rust_installer(build, s))
554554
// .run(move |s| dist::std(build, &s.compiler(), s.target));
555555

556-
let name = pkgname(build, "rust-std");
557-
let image = tmpdir(build).join(format!("{}-{}-image", name, target));
558-
let _ = fs::remove_dir_all(&image);
559-
560-
let dst = image.join("lib/rustlib").join(target);
561-
t!(fs::create_dir_all(&dst));
562-
let mut src = build.sysroot_libdir(compiler, target);
563-
src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
564-
cp_r(&src, &dst);
565-
566-
let mut cmd = rust_installer(build);
567-
cmd.arg("generate")
568-
.arg("--product-name=Rust")
569-
.arg("--rel-manifest-dir=rustlib")
570-
.arg("--success-message=std-is-standing-at-the-ready.")
571-
.arg("--image-dir").arg(&image)
572-
.arg("--work-dir").arg(&tmpdir(build))
573-
.arg("--output-dir").arg(&distdir(build))
574-
.arg(format!("--package-name={}-{}", name, target))
575-
.arg(format!("--component-name=rust-std-{}", target))
576-
.arg("--legacy-manifest-dirs=rustlib,cargo");
577-
build.run(&mut cmd);
578-
t!(fs::remove_dir_all(&image));
556+
#[derive(Serialize)]
557+
pub struct Std<'a> {
558+
pub compiler: Compiler<'a>,
559+
pub target: &'a str,
560+
}
561+
562+
impl<'a> Step<'a> for Std<'a> {
563+
type Output = ();
564+
const DEFAULT: bool = true;
565+
const ONLY_BUILD_TARGETS: bool = true;
566+
567+
fn should_run(_builder: &Builder, path: &Path) -> bool {
568+
path.ends_with("src/libstd")
569+
}
570+
571+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, target: &str) {
572+
builder.ensure(Std {
573+
compiler: builder.compiler(builder.top_stage, host),
574+
target: target,
575+
});
576+
}
577+
578+
fn run(self, builder: &Builder) {
579+
let build = builder.build;
580+
let compiler = self.compiler;
581+
let target = self.target;
582+
583+
println!("Dist std stage{} ({} -> {})", compiler.stage, compiler.host,
584+
target);
585+
586+
// The only true set of target libraries came from the build triple, so
587+
// let's reduce redundant work by only producing archives from that host.
588+
if compiler.host != build.build {
589+
println!("\tskipping, not a build host");
590+
return
591+
}
592+
593+
// We want to package up as many target libraries as possible
594+
// for the `rust-std` package, so if this is a host target we
595+
// depend on librustc and otherwise we just depend on libtest.
596+
if build.config.host.iter().any(|t| t == target) {
597+
builder.ensure(compile::Rustc { compiler, target });
598+
} else {
599+
builder.ensure(compile::Test { compiler, target });
600+
}
601+
602+
let name = pkgname(build, "rust-std");
603+
let image = tmpdir(build).join(format!("{}-{}-image", name, target));
604+
let _ = fs::remove_dir_all(&image);
605+
606+
let dst = image.join("lib/rustlib").join(target);
607+
t!(fs::create_dir_all(&dst));
608+
let mut src = builder.sysroot_libdir(compiler, target);
609+
src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
610+
cp_r(&src, &dst);
611+
612+
let mut cmd = rust_installer(builder);
613+
cmd.arg("generate")
614+
.arg("--product-name=Rust")
615+
.arg("--rel-manifest-dir=rustlib")
616+
.arg("--success-message=std-is-standing-at-the-ready.")
617+
.arg("--image-dir").arg(&image)
618+
.arg("--work-dir").arg(&tmpdir(build))
619+
.arg("--output-dir").arg(&distdir(build))
620+
.arg(format!("--package-name={}-{}", name, target))
621+
.arg(format!("--component-name=rust-std-{}", target))
622+
.arg("--legacy-manifest-dirs=rustlib,cargo");
623+
build.run(&mut cmd);
624+
t!(fs::remove_dir_all(&image));
625+
}
579626
}
580627

581628
/// The path to the complete rustc-src tarball

src/bootstrap/lib.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
//! also check out the `src/bootstrap/README.md` file for more information.
115115
116116
#![deny(warnings)]
117+
#![allow(stable_features)]
117118
#![feature(associated_consts)]
118119
#![feature(core_intrinsics)]
119120

@@ -441,19 +442,6 @@ impl Build {
441442
self.out.join(compiler.host).join(format!("stage{}-incremental", compiler.stage))
442443
}
443444

444-
/// Returns the libdir where the standard library and other artifacts are
445-
/// found for a compiler's sysroot.
446-
fn sysroot_libdir(&self, compiler: &Compiler, target: &str) -> PathBuf {
447-
if compiler.stage >= 2 {
448-
if let Some(ref libdir_relative) = self.config.libdir_relative {
449-
return self.sysroot(compiler).join(libdir_relative)
450-
.join("rustlib").join(target).join("lib")
451-
}
452-
}
453-
self.sysroot(compiler).join("lib").join("rustlib")
454-
.join(target).join("lib")
455-
}
456-
457445
/// Returns the root directory for all output generated in a particular
458446
/// stage when running with a particular host compiler.
459447
///

0 commit comments

Comments
 (0)