未验证 提交 c768ce13 编写于 作者: P Pietro Albini

bootstrap: convert rust-docs to use Tarball

上级 7be85701
......@@ -55,7 +55,7 @@ pub struct Docs {
}
impl Step for Docs {
type Output = PathBuf;
type Output = Option<PathBuf>;
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
......@@ -67,13 +67,10 @@ fn make_run(run: RunConfig<'_>) {
}
/// Builds the `rust-docs` installer component.
fn run(self, builder: &Builder<'_>) -> PathBuf {
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
let host = self.host;
let name = pkgname(builder, "rust-docs");
if !builder.config.docs {
return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple));
return None;
}
builder.default_doc(None);
......@@ -81,34 +78,14 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
builder.info(&format!("Dist docs ({})", host));
let _time = timeit(builder);
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
let _ = fs::remove_dir_all(&image);
let dest = "share/doc/rust/html";
let dst = image.join("share/doc/rust/html");
t!(fs::create_dir_all(&dst));
let src = builder.doc_out(host);
builder.cp_r(&src, &dst);
builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644);
let mut cmd = rust_installer(builder);
cmd.arg("generate")
.arg("--product-name=Rust-Documentation")
.arg("--rel-manifest-dir=rustlib")
.arg("--success-message=Rust-documentation-is-installed.")
.arg("--image-dir")
.arg(&image)
.arg("--work-dir")
.arg(&tmpdir(builder))
.arg("--output-dir")
.arg(&distdir(builder))
.arg(format!("--package-name={}-{}", name, host.triple))
.arg("--component-name=rust-docs")
.arg("--legacy-manifest-dirs=rustlib,cargo")
.arg("--bulk-dirs=share/doc/rust/html");
builder.run(&mut cmd);
builder.remove_dir(&image);
let mut tarball = Tarball::new(builder, "rust-docs", &host.triple);
tarball.set_product_name("Rust Documentation");
tarball.add_dir(&builder.doc_out(host), dest);
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple))
Some(tarball.generate())
}
}
......@@ -1826,7 +1803,7 @@ fn run(self, builder: &Builder<'_>) {
tarballs.extend(llvm_tools_installer);
tarballs.push(analysis_installer);
tarballs.push(std_installer);
if builder.config.docs {
if let Some(docs_installer) = docs_installer {
tarballs.push(docs_installer);
}
if target.contains("pc-windows-gnu") {
......@@ -2509,7 +2486,7 @@ fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
// Copy the include directory as well; needed mostly to build
// librustc_llvm properly (e.g., llvm-config.h is in here). But also
// just broadly useful to be able to link against the bundled LLVM.
tarball.add_dir(&builder.llvm_out(target).join("include"), ".");
tarball.add_dir(&builder.llvm_out(target).join("include"), "include");
// Copy libLLVM.so to the target lib dir as well, so the RPATH like
// `$ORIGIN/../lib` can find it. It may also be used as a dependency
......
......@@ -27,6 +27,7 @@ pub(crate) struct Tarball<'a> {
pkgname: String,
component: String,
target: String,
product_name: String,
overlay: OverlayKind,
temp_dir: PathBuf,
......@@ -54,6 +55,7 @@ pub(crate) fn new(builder: &'a Builder<'a>, component: &str, target: &str) -> Se
pkgname,
component: component.into(),
target: target.into(),
product_name: "Rust".into(),
overlay: OverlayKind::Rust,
temp_dir,
......@@ -69,6 +71,10 @@ pub(crate) fn set_overlay(&mut self, overlay: OverlayKind) {
self.overlay = overlay;
}
pub(crate) fn set_product_name(&mut self, name: &str) {
self.product_name = name.into();
}
pub(crate) fn is_preview(&mut self, is: bool) {
self.is_preview = is;
}
......@@ -91,12 +97,11 @@ pub(crate) fn add_file(&self, src: impl AsRef<Path>, destdir: impl AsRef<Path>,
self.builder.install(src.as_ref(), &destdir, perms);
}
pub(crate) fn add_dir(&self, src: impl AsRef<Path>, destdir: impl AsRef<Path>) {
t!(std::fs::create_dir_all(destdir.as_ref()));
self.builder.cp_r(
src.as_ref(),
&self.image_dir.join(destdir.as_ref()).join(src.as_ref().file_name().unwrap()),
);
pub(crate) fn add_dir(&self, src: impl AsRef<Path>, dest: impl AsRef<Path>) {
let dest = self.image_dir.join(dest.as_ref());
t!(std::fs::create_dir_all(&dest));
self.builder.cp_r(src.as_ref(), &dest);
}
pub(crate) fn generate(self) -> PathBuf {
......@@ -114,7 +119,7 @@ pub(crate) fn generate(self) -> PathBuf {
let distdir = crate::dist::distdir(self.builder);
let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller);
cmd.arg("generate")
.arg("--product-name=Rust")
.arg(format!("--product-name={}", self.product_name))
.arg("--rel-manifest-dir=rustlib")
.arg(format!("--success-message={} installed.", self.component))
.arg("--image-dir")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册