Rollup merge of #92800 - ehuss:docs-fallback, r=Mark-Simulacrum

Add manifest docs fallback.

This adds a fallback so that the rustup manifest will contain the rust-docs component for all hosts. There is a mapping so that the docs that get downloaded are roughly close to the actual host. There inevitably will be things that don't match. Ideally the standard library docs would be the same for every platform (`cfg(doc)` goes a long way towards this), but there are still lots of minor differences.

Closes #69525
This commit is contained in:
Matthias Krüger 2022-01-19 19:19:48 +01:00 committed by GitHub
commit bcb093efcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 46 deletions

View File

@ -320,7 +320,7 @@ jobs:
- name: dist-aarch64-apple - name: dist-aarch64-apple
env: env:
SCRIPT: "./x.py dist --stage 2" SCRIPT: "./x.py dist --stage 2"
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-full-tools --enable-sanitizers --enable-profiler --disable-docs --set rust.jemalloc --set llvm.ninja=false"
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
USE_XCODE_CLANG: 1 USE_XCODE_CLANG: 1
MACOSX_DEPLOYMENT_TARGET: 11.0 MACOSX_DEPLOYMENT_TARGET: 11.0

View File

@ -1483,11 +1483,10 @@ impl Step for Extended {
}; };
prepare("rustc"); prepare("rustc");
prepare("cargo"); prepare("cargo");
prepare("rust-docs");
prepare("rust-std"); prepare("rust-std");
prepare("rust-analysis"); prepare("rust-analysis");
prepare("clippy"); prepare("clippy");
for tool in &["rust-demangler", "rls", "rust-analyzer", "miri"] { for tool in &["rust-docs", "rust-demangler", "rls", "rust-analyzer", "miri"] {
if built_tools.contains(tool) { if built_tools.contains(tool) {
prepare(tool); prepare(tool);
} }

View File

@ -496,6 +496,7 @@ jobs:
--enable-full-tools --enable-full-tools
--enable-sanitizers --enable-sanitizers
--enable-profiler --enable-profiler
--disable-docs
--set rust.jemalloc --set rust.jemalloc
--set llvm.ninja=false --set llvm.ninja=false
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 RUSTC_RETRY_LINKER_ON_SEGFAULT: 1

View File

@ -20,8 +20,7 @@ Then, you can generate the manifest and all the packages from `path/to/dist` to
`path/to/output` with: `path/to/output` with:
``` ```
$ cargo +nightly run path/to/dist path/to/output 1970-01-01 http://example.com \ $ cargo +nightly run path/to/dist path/to/output 1970-01-01 http://example.com CHANNEL
CHANNEL VERSION
``` ```
Remember to replace `CHANNEL` with the channel you produced dist artifacts of Remember to replace `CHANNEL` with the channel you produced dist artifacts of

View File

@ -155,17 +155,19 @@ static TARGETS: &[&str] = &[
"x86_64-unknown-hermit", "x86_64-unknown-hermit",
]; ];
static DOCS_TARGETS: &[&str] = &[ /// This allows the manifest to contain rust-docs for hosts that don't build
"aarch64-unknown-linux-gnu", /// docs.
"i686-apple-darwin", ///
"i686-pc-windows-gnu", /// Tuples of `(host_partial, host_instead)`. If the host does not have the
"i686-pc-windows-msvc", /// rust-docs component available, then if the host name contains
"i686-unknown-linux-gnu", /// `host_partial`, it will use the docs from `host_instead` instead.
"x86_64-apple-darwin", ///
"x86_64-pc-windows-gnu", /// The order here matters, more specific entries should be first.
"x86_64-pc-windows-msvc", static DOCS_FALLBACK: &[(&str, &str)] = &[
"x86_64-unknown-linux-gnu", ("-apple-", "x86_64-apple-darwin"),
"x86_64-unknown-linux-musl", ("aarch64", "aarch64-unknown-linux-gnu"),
("arm-", "aarch64-unknown-linux-gnu"),
("", "x86_64-unknown-linux-gnu"),
]; ];
static MSI_INSTALLERS: &[&str] = &[ static MSI_INSTALLERS: &[&str] = &[
@ -301,23 +303,27 @@ impl Builder {
} }
fn add_packages_to(&mut self, manifest: &mut Manifest) { fn add_packages_to(&mut self, manifest: &mut Manifest) {
let mut package = |name, targets| self.package(name, &mut manifest.pkg, targets); macro_rules! package {
package("rustc", HOSTS); ($name:expr, $targets:expr) => {
package("rustc-dev", HOSTS); self.package($name, &mut manifest.pkg, $targets, &[])
package("reproducible-artifacts", HOSTS); };
package("rustc-docs", HOSTS); }
package("cargo", HOSTS); package!("rustc", HOSTS);
package("rust-mingw", MINGW); package!("rustc-dev", HOSTS);
package("rust-std", TARGETS); package!("reproducible-artifacts", HOSTS);
package("rust-docs", DOCS_TARGETS); package!("rustc-docs", HOSTS);
package("rust-src", &["*"]); package!("cargo", HOSTS);
package("rls-preview", HOSTS); package!("rust-mingw", MINGW);
package("rust-analyzer-preview", HOSTS); package!("rust-std", TARGETS);
package("clippy-preview", HOSTS); self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK);
package("miri-preview", HOSTS); package!("rust-src", &["*"]);
package("rustfmt-preview", HOSTS); package!("rls-preview", HOSTS);
package("rust-analysis", TARGETS); package!("rust-analyzer-preview", HOSTS);
package("llvm-tools-preview", TARGETS); package!("clippy-preview", HOSTS);
package!("miri-preview", HOSTS);
package!("rustfmt-preview", HOSTS);
package!("rust-analysis", TARGETS);
package!("llvm-tools-preview", TARGETS);
} }
fn add_artifacts_to(&mut self, manifest: &mut Manifest) { fn add_artifacts_to(&mut self, manifest: &mut Manifest) {
@ -500,7 +506,13 @@ impl Builder {
.extend(pkgs.iter().map(|s| (*s).to_owned())); .extend(pkgs.iter().map(|s| (*s).to_owned()));
} }
fn package(&mut self, pkgname: &str, dst: &mut BTreeMap<String, Package>, targets: &[&str]) { fn package(
&mut self,
pkgname: &str,
dst: &mut BTreeMap<String, Package>,
targets: &[&str],
fallback: &[(&str, &str)],
) {
let version_info = self let version_info = self
.versions .versions
.version(&PkgType::from_component(pkgname)) .version(&PkgType::from_component(pkgname))
@ -512,16 +524,32 @@ impl Builder {
is_present = false; // Pretend the component is entirely missing. is_present = false; // Pretend the component is entirely missing.
} }
macro_rules! tarball_name {
($target_name:expr) => {
self.versions.tarball_name(&PkgType::from_component(pkgname), $target_name).unwrap()
};
}
let mut target_from_compressed_tar = |target_name| {
let target = Target::from_compressed_tar(self, &tarball_name!(target_name));
if target.available {
return target;
}
for (substr, fallback_target) in fallback {
if target_name.contains(substr) {
let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target));
// Fallbacks must always be available.
assert!(t.available);
return t;
}
}
Target::unavailable()
};
let targets = targets let targets = targets
.iter() .iter()
.map(|name| { .map(|name| {
let target = if is_present { let target = if is_present {
let filename = self target_from_compressed_tar(name)
.versions
.tarball_name(&PkgType::from_component(pkgname), name)
.unwrap();
Target::from_compressed_tar(self, &filename)
} else { } else {
// If the component is not present for this build add it anyway but mark it as // If the component is not present for this build add it anyway but mark it as
// unavailable -- this way rustup won't allow upgrades without --force // unavailable -- this way rustup won't allow upgrades without --force

View File

@ -169,7 +169,7 @@ impl Versions {
} }
pub(crate) fn archive_name( pub(crate) fn archive_name(
&mut self, &self,
package: &PkgType, package: &PkgType,
target: &str, target: &str,
extension: &str, extension: &str,
@ -189,11 +189,7 @@ impl Versions {
} }
} }
pub(crate) fn tarball_name( pub(crate) fn tarball_name(&self, package: &PkgType, target: &str) -> Result<String, Error> {
&mut self,
package: &PkgType,
target: &str,
) -> Result<String, Error> {
self.archive_name(package, target, "tar.gz") self.archive_name(package, target, "tar.gz")
} }