Rollup merge of #113010 - klensy:ri-rls-fmt, r=ozkanonur
rust-installer & rls: remove exclusion from rustfmt & tidy <strike>based on #112884</strike> `rust-installer` and `rls` no longer submodules, but not removed from exclude list for rustfmt and tidy, preventing running fmt and lints on them.
This commit is contained in:
commit
1cb958a225
12 changed files with 834 additions and 841 deletions
|
@ -16,6 +16,8 @@ ignore = [
|
|||
"tests",
|
||||
|
||||
# do not format submodules
|
||||
# FIXME: sync submodule list with tidy/bootstrap/etc
|
||||
# tidy/src/walk.rs:filter_dirs
|
||||
"library/backtrace",
|
||||
"library/portable-simd",
|
||||
"library/stdarch",
|
||||
|
@ -31,10 +33,8 @@ ignore = [
|
|||
"src/tools/cargo",
|
||||
"src/tools/clippy",
|
||||
"src/tools/miri",
|
||||
"src/tools/rls",
|
||||
"src/tools/rust-analyzer",
|
||||
"src/tools/rustfmt",
|
||||
"src/tools/rust-installer",
|
||||
|
||||
# these are ignored by a standard cargo fmt run
|
||||
"compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file
|
||||
|
|
|
@ -289,7 +289,7 @@ bootstrap_tool!(
|
|||
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true, allow_features = "test";
|
||||
BuildManifest, "src/tools/build-manifest", "build-manifest";
|
||||
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
|
||||
RustInstaller, "src/tools/rust-installer", "rust-installer", is_external_tool = true;
|
||||
RustInstaller, "src/tools/rust-installer", "rust-installer";
|
||||
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
|
||||
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
|
||||
LintDocs, "src/tools/lint-docs", "lint-docs";
|
||||
|
|
|
@ -468,7 +468,8 @@ uninstall_components() {
|
|||
verbose_msg "removing component manifest $_component_manifest"
|
||||
run rm "$_component_manifest"
|
||||
# This is a hard error because the installation is unrecoverable
|
||||
critical_need_ok "failed to remove installed manifest for component '$_installed_component'"
|
||||
local _err_cant_r_manifest="failed to remove installed manifest for component"
|
||||
critical_need_ok "$_err_cant_r_manifest '$_installed_component'"
|
||||
|
||||
# Update the installed component list
|
||||
local _modified_components="$(sed "/^$_installed_component\$/d" "$_md/components")"
|
||||
|
@ -692,7 +693,9 @@ maybe_configure_ld() {
|
|||
fi
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
warn "failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error"
|
||||
local _warn_s="failed to run ldconfig. this may happen when \
|
||||
not installing as root. run with --verbose to see the error"
|
||||
warn "$_warn_s"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -977,7 +980,9 @@ make_dir_recursive "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR"
|
|||
need_ok "failed to create $TEMPLATE_REL_MANIFEST_DIR"
|
||||
|
||||
# Drop the version number into the manifest dir
|
||||
write_to_file "$TEMPLATE_RUST_INSTALLER_VERSION" "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"
|
||||
write_to_file "$TEMPLATE_RUST_INSTALLER_VERSION" \
|
||||
"$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"
|
||||
|
||||
critical_need_ok "failed to write installer version"
|
||||
|
||||
# Install the uninstaller
|
||||
|
@ -992,5 +997,3 @@ maybe_configure_ld "$abs_libdir"
|
|||
echo
|
||||
echo " $TEMPLATE_SUCCESS_MESSAGE"
|
||||
echo
|
||||
|
||||
|
||||
|
|
|
@ -71,25 +71,16 @@ impl Combiner {
|
|||
|
||||
// Merge each installer into the work directory of the new installer.
|
||||
let components = create_new_file(package_dir.join("components"))?;
|
||||
for input_tarball in self
|
||||
.input_tarballs
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|s| !s.is_empty())
|
||||
for input_tarball in self.input_tarballs.split(',').map(str::trim).filter(|s| !s.is_empty())
|
||||
{
|
||||
// Extract the input tarballs
|
||||
let compression =
|
||||
CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| {
|
||||
anyhow::anyhow!("couldn't figure out the format of {}", input_tarball)
|
||||
})?;
|
||||
Archive::new(compression.decode(input_tarball)?)
|
||||
.unpack(&self.work_dir)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"unable to extract '{}' into '{}'",
|
||||
&input_tarball, self.work_dir
|
||||
)
|
||||
})?;
|
||||
Archive::new(compression.decode(input_tarball)?).unpack(&self.work_dir).with_context(
|
||||
|| format!("unable to extract '{}' into '{}'", &input_tarball, self.work_dir),
|
||||
)?;
|
||||
|
||||
let pkg_name =
|
||||
input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension()));
|
||||
|
@ -126,11 +117,7 @@ impl Combiner {
|
|||
|
||||
// Write the installer version.
|
||||
let version = package_dir.join("rust-installer-version");
|
||||
writeln!(
|
||||
create_new_file(version)?,
|
||||
"{}",
|
||||
crate::RUST_INSTALLER_VERSION
|
||||
)
|
||||
writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
|
||||
.context("failed to write new installer version")?;
|
||||
|
||||
// Copy the overlay.
|
||||
|
|
|
@ -86,11 +86,7 @@ impl Generator {
|
|||
|
||||
// Write the installer version (only used by combine-installers.sh)
|
||||
let version = package_dir.join("rust-installer-version");
|
||||
writeln!(
|
||||
create_new_file(version)?,
|
||||
"{}",
|
||||
crate::RUST_INSTALLER_VERSION
|
||||
)
|
||||
writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
|
||||
.context("failed to write new installer version")?;
|
||||
|
||||
// Copy the overlay
|
||||
|
@ -128,33 +124,19 @@ impl Generator {
|
|||
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
|
||||
fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
|
||||
let mut manifest = create_new_file(dst.join("manifest.in"))?;
|
||||
let bulk_dirs: Vec<_> = bulk_dirs
|
||||
.split(',')
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(Path::new)
|
||||
.collect();
|
||||
let bulk_dirs: Vec<_> = bulk_dirs.split(',').filter(|s| !s.is_empty()).map(Path::new).collect();
|
||||
|
||||
let mut paths = BTreeSet::new();
|
||||
copy_with_callback(src, dst, |path, file_type| {
|
||||
// We need paths to be compatible with both Unix and Windows.
|
||||
if path
|
||||
.components()
|
||||
.filter_map(|c| c.as_os_str().to_str())
|
||||
.any(|s| s.contains('\\'))
|
||||
{
|
||||
bail!(
|
||||
"rust-installer doesn't support '\\' in path components: {:?}",
|
||||
path
|
||||
);
|
||||
if path.components().filter_map(|c| c.as_os_str().to_str()).any(|s| s.contains('\\')) {
|
||||
bail!("rust-installer doesn't support '\\' in path components: {:?}", path);
|
||||
}
|
||||
|
||||
// Normalize to Unix-style path separators.
|
||||
let normalized_string;
|
||||
let mut string = path.to_str().ok_or_else(|| {
|
||||
format_err!(
|
||||
"rust-installer doesn't support non-Unicode paths: {:?}",
|
||||
path
|
||||
)
|
||||
format_err!("rust-installer doesn't support non-Unicode paths: {:?}", path)
|
||||
})?;
|
||||
if string.contains('\\') {
|
||||
normalized_string = string.replace('\\', "/");
|
||||
|
|
|
@ -19,8 +19,12 @@ fn main() -> Result<()> {
|
|||
let command_line = CommandLine::parse();
|
||||
match command_line.command {
|
||||
Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?,
|
||||
Subcommand::Generate(generator) => generator.run().context("failed to generate installer")?,
|
||||
Subcommand::Script(scripter) => scripter.run().context("failed to generate installation script")?,
|
||||
Subcommand::Generate(generator) => {
|
||||
generator.run().context("failed to generate installer")?
|
||||
}
|
||||
Subcommand::Script(scripter) => {
|
||||
scripter.run().context("failed to generate installation script")?
|
||||
}
|
||||
Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?,
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -32,22 +32,19 @@ actor! {
|
|||
impl Scripter {
|
||||
/// Generates the actual installer script
|
||||
pub fn run(self) -> Result<()> {
|
||||
// Replace dashes in the success message with spaces (our arg handling botches spaces)
|
||||
// TODO: still needed? Kept for compatibility for now.
|
||||
// Replace dashes in the product name with spaces (our arg handling botches spaces)
|
||||
// FIXME: still needed? Kept for compatibility for now.
|
||||
let product_name = self.product_name.replace('-', " ");
|
||||
|
||||
// Replace dashes in the success message with spaces (our arg handling botches spaces)
|
||||
// TODO: still needed? Kept for compatibility for now.
|
||||
// FIXME: still needed? Kept for compatibility for now.
|
||||
let success_message = self.success_message.replace('-', " ");
|
||||
|
||||
let script = TEMPLATE
|
||||
.replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name))
|
||||
.replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir)
|
||||
.replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message))
|
||||
.replace(
|
||||
"%%TEMPLATE_LEGACY_MANIFEST_DIRS%%",
|
||||
&sh_quote(&self.legacy_manifest_dirs),
|
||||
)
|
||||
.replace("%%TEMPLATE_LEGACY_MANIFEST_DIRS%%", &sh_quote(&self.legacy_manifest_dirs))
|
||||
.replace(
|
||||
"%%TEMPLATE_RUST_INSTALLER_VERSION%%",
|
||||
&sh_quote(&crate::RUST_INSTALLER_VERSION),
|
||||
|
|
|
@ -58,10 +58,7 @@ impl Tarballer {
|
|||
let buf = BufWriter::with_capacity(1024 * 1024, encoder);
|
||||
let mut builder = Builder::new(buf);
|
||||
|
||||
let pool = rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(2)
|
||||
.build()
|
||||
.unwrap();
|
||||
let pool = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
|
||||
pool.install(move || {
|
||||
for path in dirs {
|
||||
let src = Path::new(&self.work_dir).join(&path);
|
||||
|
@ -122,11 +119,7 @@ where
|
|||
let name = name.as_ref();
|
||||
|
||||
if !name.is_relative() && !name.starts_with(root) {
|
||||
bail!(
|
||||
"input '{}' is not in work dir '{}'",
|
||||
name.display(),
|
||||
root.display()
|
||||
);
|
||||
bail!("input '{}' is not in work dir '{}'", name.display(), root.display());
|
||||
}
|
||||
|
||||
let mut dirs = vec![];
|
||||
|
|
|
@ -15,8 +15,7 @@ use std::os::windows::fs::symlink_file;
|
|||
|
||||
/// Converts a `&Path` to a UTF-8 `&str`.
|
||||
pub fn path_to_str(path: &Path) -> Result<&str> {
|
||||
path.to_str()
|
||||
.ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
|
||||
path.to_str().ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
|
||||
}
|
||||
|
||||
/// Wraps `fs::copy` with a nicer error message.
|
||||
|
@ -27,11 +26,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
|
|||
Ok(0)
|
||||
} else {
|
||||
let amt = fs::copy(&from, &to).with_context(|| {
|
||||
format!(
|
||||
"failed to copy '{}' to '{}'",
|
||||
from.as_ref().display(),
|
||||
to.as_ref().display()
|
||||
)
|
||||
format!("failed to copy '{}' to '{}'", from.as_ref().display(), to.as_ref().display())
|
||||
})?;
|
||||
Ok(amt)
|
||||
}
|
||||
|
@ -123,8 +118,12 @@ where
|
|||
}
|
||||
|
||||
macro_rules! actor_field_default {
|
||||
() => { Default::default() };
|
||||
(= $expr:expr) => { $expr.into() }
|
||||
() => {
|
||||
Default::default()
|
||||
};
|
||||
(= $expr:expr) => {
|
||||
$expr.into()
|
||||
};
|
||||
}
|
||||
|
||||
/// Creates an "actor" with default values, setters for all fields, and Clap parser support.
|
||||
|
|
|
@ -458,7 +458,8 @@ uninstall_from_installed_script_with_args_fails() {
|
|||
--output-dir="$OUT_DIR/c1" \
|
||||
--component-name=rustc
|
||||
try "$WORK_DIR/c1/package/install.sh" --prefix="$PREFIX_DIR"
|
||||
expect_output_fail "uninstall.sh does not take any arguments" sh "$PREFIX_DIR/lib/packagelib/uninstall.sh" --prefix=foo
|
||||
expect_output_fail "uninstall.sh does not take any arguments" \
|
||||
sh "$PREFIX_DIR/lib/packagelib/uninstall.sh" --prefix=foo
|
||||
}
|
||||
runtest uninstall_from_installed_script_with_args_fails
|
||||
|
||||
|
@ -680,7 +681,8 @@ select_components_to_install() {
|
|||
try test -e "$PREFIX_DIR/bin/program"
|
||||
try test -e "$PREFIX_DIR/bin/cargo"
|
||||
try test ! -e "$PREFIX_DIR/baz"
|
||||
try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR" --components=rustc,cargo,rust-docs
|
||||
try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR" \
|
||||
--components=rustc,cargo,rust-docs
|
||||
try test ! -e "$PREFIX_DIR/bin/program"
|
||||
try test ! -e "$PREFIX_DIR/bin/cargo"
|
||||
try test ! -e "$PREFIX_DIR/baz"
|
||||
|
@ -733,7 +735,8 @@ select_components_to_uninstall() {
|
|||
try test ! -e "$PREFIX_DIR/bin/cargo"
|
||||
try test -e "$PREFIX_DIR/baz"
|
||||
try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
|
||||
try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR" --components=rustc,cargo,rust-docs
|
||||
try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR" \
|
||||
--components=rustc,cargo,rust-docs
|
||||
try test ! -e "$PREFIX_DIR/bin/program"
|
||||
try test ! -e "$PREFIX_DIR/bin/cargo"
|
||||
try test ! -e "$PREFIX_DIR/baz"
|
||||
|
@ -765,7 +768,8 @@ invalid_component() {
|
|||
--output-dir="$OUT_DIR" \
|
||||
--package-name=rust \
|
||||
--input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz,$OUT_DIR/rust-docs.tar.gz"
|
||||
expect_output_fail "unknown component" "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR" --components=foo
|
||||
expect_output_fail "unknown component" "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR" \
|
||||
--components=foo
|
||||
}
|
||||
runtest invalid_component
|
||||
|
||||
|
|
|
@ -95,17 +95,41 @@ mod os_impl {
|
|||
return true;
|
||||
}
|
||||
|
||||
// FIXME: check when rust-installer test sh files will be removed,
|
||||
// and then remove them from exclude list
|
||||
const RI_EXCLUSION_LIST: &[&str] = &[
|
||||
"src/tools/rust-installer/test/image1/bin/program",
|
||||
"src/tools/rust-installer/test/image1/bin/program2",
|
||||
"src/tools/rust-installer/test/image1/bin/bad-bin",
|
||||
"src/tools/rust-installer/test/image2/bin/oldprogram",
|
||||
"src/tools/rust-installer/test/image3/bin/cargo",
|
||||
];
|
||||
|
||||
fn filter_rust_installer_no_so_bins(path: &Path) -> bool {
|
||||
RI_EXCLUSION_LIST.iter().any(|p| path.ends_with(p))
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
use std::ffi::OsStr;
|
||||
|
||||
const ALLOWED: &[&str] = &["configure", "x"];
|
||||
|
||||
for p in RI_EXCLUSION_LIST {
|
||||
if !path.join(Path::new(p)).exists() {
|
||||
tidy_error!(bad, "rust-installer test bins missed: {p}");
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: we don't need to look at all binaries, only files that have been modified in this branch
|
||||
// (e.g. using `git ls-files`).
|
||||
walk_no_read(
|
||||
&[path],
|
||||
|path, _is_dir| filter_dirs(path) || path.ends_with("src/etc"),
|
||||
|path, _is_dir| {
|
||||
filter_dirs(path)
|
||||
|| path.ends_with("src/etc")
|
||||
|| filter_rust_installer_no_so_bins(path)
|
||||
},
|
||||
&mut |entry| {
|
||||
let file = entry.path();
|
||||
let extension = file.extension();
|
||||
|
|
|
@ -4,6 +4,8 @@ use std::{ffi::OsStr, fs::File, io::Read, path::Path};
|
|||
|
||||
/// The default directory filter.
|
||||
pub fn filter_dirs(path: &Path) -> bool {
|
||||
// FIXME: sync submodule exclusion list with rustfmt.toml
|
||||
// bootstrap/etc
|
||||
let skip = [
|
||||
"tidy-test-file",
|
||||
"compiler/rustc_codegen_cranelift",
|
||||
|
@ -15,9 +17,7 @@ pub fn filter_dirs(path: &Path) -> bool {
|
|||
"src/tools/cargo",
|
||||
"src/tools/clippy",
|
||||
"src/tools/miri",
|
||||
"src/tools/rls",
|
||||
"src/tools/rust-analyzer",
|
||||
"src/tools/rust-installer",
|
||||
"src/tools/rustfmt",
|
||||
"src/doc/book",
|
||||
"src/doc/edition-guide",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue