Skip to content

rustbuild: Support cross rust-docs packages #32751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/bootstrap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions src/bootstrap/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::process::Command;

use build_helper::output;

use build::util::{exe, staticlib, libdir, mtime, is_dylib};
use build::util::{exe, staticlib, libdir, mtime, is_dylib, copy};
use build::{Build, Compiler, Mode};

/// Build the standard library.
Expand All @@ -32,8 +32,8 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
let libdir = build.sysroot_libdir(compiler, target);
let _ = fs::remove_dir_all(&libdir);
t!(fs::create_dir_all(&libdir));
t!(fs::hard_link(&build.compiler_rt_built.borrow()[target],
libdir.join(staticlib("compiler-rt", target))));
copy(&build.compiler_rt_built.borrow()[target],
&libdir.join(staticlib("compiler-rt", target)));

build_startup_objects(build, target, &libdir);

Expand Down Expand Up @@ -77,8 +77,8 @@ pub fn std_link(build: &Build,
if host != compiler.host {
let _ = fs::remove_dir_all(&libdir);
t!(fs::create_dir_all(&libdir));
t!(fs::hard_link(&build.compiler_rt_built.borrow()[target],
libdir.join(staticlib("compiler-rt", target))));
copy(&build.compiler_rt_built.borrow()[target],
&libdir.join(staticlib("compiler-rt", target)));
}
add_to_sysroot(&out_dir, &libdir);

Expand All @@ -93,7 +93,7 @@ pub fn std_link(build: &Build,
/// Only required for musl targets that statically link to libc
fn copy_third_party_objects(build: &Build, target: &str, into: &Path) {
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
t!(fs::copy(compiler_file(build.cc(target), obj), into.join(obj)));
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
}
}

Expand All @@ -119,7 +119,7 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
}

for obj in ["crt2.o", "dllcrt2.o"].iter() {
t!(fs::copy(compiler_file(build.cc(target), obj), into.join(obj)));
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
}
}

Expand Down Expand Up @@ -240,9 +240,10 @@ fn libtest_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
build.cargo_out(compiler, Mode::Libtest, target).join("libtest_shim.rlib")
}

fn compiler_file(compiler: &Path, file: &str) -> String {
output(Command::new(compiler)
.arg(format!("-print-file-name={}", file))).trim().to_string()
fn compiler_file(compiler: &Path, file: &str) -> PathBuf {
let out = output(Command::new(compiler)
.arg(format!("-print-file-name={}", file)));
PathBuf::from(out.trim())
}

/// Prepare a new compiler from the artifacts in `stage`
Expand Down Expand Up @@ -270,7 +271,7 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
for f in t!(fs::read_dir(&src_libdir)).map(|f| t!(f)) {
let filename = f.file_name().into_string().unwrap();
if is_dylib(&filename) {
t!(fs::hard_link(&f.path(), sysroot_libdir.join(&filename)));
copy(&f.path(), &sysroot_libdir.join(&filename));
}
}

Expand All @@ -282,15 +283,15 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
t!(fs::create_dir_all(&bindir));
let compiler = build.compiler_path(&Compiler::new(stage, host));
let _ = fs::remove_file(&compiler);
t!(fs::hard_link(rustc, compiler));
copy(&rustc, &compiler);

// See if rustdoc exists to link it into place
let rustdoc = exe("rustdoc", host);
let rustdoc_src = out_dir.join(&rustdoc);
let rustdoc_dst = bindir.join(&rustdoc);
if fs::metadata(&rustdoc_src).is_ok() {
let _ = fs::remove_file(&rustdoc_dst);
t!(fs::hard_link(&rustdoc_src, &rustdoc_dst));
copy(&rustdoc_src, &rustdoc_dst);
}
}

Expand Down Expand Up @@ -329,8 +330,7 @@ fn add_to_sysroot(out_dir: &Path, sysroot_dst: &Path) {
let (_, path) = paths.iter().map(|path| {
(mtime(&path).seconds(), path)
}).max().unwrap();
t!(fs::hard_link(&path,
sysroot_dst.join(path.file_name().unwrap())));
copy(&path, &sysroot_dst.join(path.file_name().unwrap()));
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/bootstrap/build/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
.arg(format!("--image-dir={}", sanitize_sh(&image)))
.arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
.arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
.arg(format!("--package-name={}", name))
.arg(format!("--package-name={}-{}", name, host))
.arg("--component-name=rust-docs")
.arg("--legacy-manifest-dirs=rustlib,cargo")
.arg("--bulk-dirs=share/doc/rust/html");
Expand All @@ -61,9 +61,11 @@ pub fn docs(build: &Build, stage: u32, host: &str) {

// As part of this step, *also* copy the docs directory to a directory which
// buildbot typically uploads.
let dst = distdir(build).join("doc").join(&build.package_vers);
t!(fs::create_dir_all(&dst));
cp_r(&src, &dst);
if host == build.config.build {
let dst = distdir(build).join("doc").join(&build.package_vers);
t!(fs::create_dir_all(&dst));
cp_r(&src, &dst);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this directory build/doc? If this is being done for all targets then won't they overwrite each other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is build/doc, which I think is just what we upload to the S3 bucket, which in turn buildbot filters to just upload one of these? I was hoping the host == build.config.build would filter this build at least and we'd only copy one into place.

}

pub fn mingw(build: &Build, host: &str) {
Expand Down
50 changes: 26 additions & 24 deletions src/bootstrap/build/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ use std::process::Command;
use build::{Build, Compiler, Mode};
use build::util::{up_to_date, cp_r};

pub fn rustbook(build: &Build, stage: u32, host: &str, name: &str, out: &Path) {
pub fn rustbook(build: &Build, stage: u32, target: &str, name: &str, out: &Path) {
t!(fs::create_dir_all(out));

let out = out.join(name);
let compiler = Compiler::new(stage, host);
let compiler = Compiler::new(stage, &build.config.build);
let src = build.src.join("src/doc").join(name);
let index = out.join("index.html");
let rustbook = build.tool(&compiler, "rustbook");
if up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
return
}
println!("Rustbook stage{} ({}) - {}", stage, host, name);
println!("Rustbook stage{} ({}) - {}", stage, target, name);
let _ = fs::remove_dir_all(&out);
build.run(build.tool_cmd(&compiler, "rustbook")
.arg("build")
.arg(&src)
.arg(out));
}

pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} standalone ({})", stage, host);
pub fn standalone(build: &Build, stage: u32, target: &str, out: &Path) {
println!("Documenting stage{} standalone ({})", stage, target);
t!(fs::create_dir_all(out));

let compiler = Compiler::new(stage, host);
let compiler = Compiler::new(stage, &build.config.build);

let favicon = build.src.join("src/doc/favicon.inc");
let footer = build.src.join("src/doc/footer.inc");
Expand Down Expand Up @@ -105,59 +105,61 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
}
}

pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} std ({})", stage, host);
let compiler = Compiler::new(stage, host);
pub fn std(build: &Build, stage: u32, target: &str, out: &Path) {
println!("Documenting stage{} std ({})", stage, target);
t!(fs::create_dir_all(out));
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Libstd)
.join(host).join("doc");
.join(target).join("doc");
let rustdoc = build.rustdoc(&compiler);

build.clear_if_dirty(&out_dir, &rustdoc);

let mut cargo = build.cargo(&compiler, Mode::Libstd, host, "doc");
let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
.arg("--features").arg(build.std_features());
build.run(&mut cargo);
cp_r(&out_dir, out)
}

pub fn test(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} test ({})", stage, host);
let compiler = Compiler::new(stage, host);
pub fn test(build: &Build, stage: u32, target: &str, out: &Path) {
println!("Documenting stage{} test ({})", stage, target);
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Libtest)
.join(host).join("doc");
.join(target).join("doc");
let rustdoc = build.rustdoc(&compiler);

build.clear_if_dirty(&out_dir, &rustdoc);

let mut cargo = build.cargo(&compiler, Mode::Libtest, host, "doc");
let mut cargo = build.cargo(&compiler, Mode::Libtest, target, "doc");
cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
build.run(&mut cargo);
cp_r(&out_dir, out)
}

pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} compiler ({})", stage, host);
let compiler = Compiler::new(stage, host);
pub fn rustc(build: &Build, stage: u32, target: &str, out: &Path) {
println!("Documenting stage{} compiler ({})", stage, target);
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Librustc)
.join(host).join("doc");
.join(target).join("doc");
let rustdoc = build.rustdoc(&compiler);
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
t!(fs::remove_dir_all(&out_dir));
}
let mut cargo = build.cargo(&compiler, Mode::Librustc, host, "doc");
let mut cargo = build.cargo(&compiler, Mode::Librustc, target, "doc");
cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/Cargo.toml"))
.arg("--features").arg(build.rustc_features());
build.run(&mut cargo);
cp_r(&out_dir, out)
}

pub fn error_index(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} error index ({})", stage, host);
let compiler = Compiler::new(stage, host);
pub fn error_index(build: &Build, stage: u32, target: &str, out: &Path) {
println!("Documenting stage{} error index ({})", stage, target);
t!(fs::create_dir_all(out));
let compiler = Compiler::new(stage, &build.config.build);
let mut index = build.tool_cmd(&compiler, "error_index_generator");
index.arg("html");
index.arg(out.join("error-index.html"));
Expand Down
12 changes: 12 additions & 0 deletions src/bootstrap/build/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,16 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
}
}
}

for host in build.flags.host.iter() {
if !build.config.host.contains(host) {
panic!("specified host `{}` is not in the ./configure list", host);
}
}
for target in build.flags.target.iter() {
if !build.config.target.contains(target) {
panic!("specified target `{}` is not in the ./configure list",
target);
}
}
}
Loading