rust/src/tools/tidy/src/lib.rs

98 lines
2.5 KiB
Rust
Raw Normal View History

// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Library used by tidy and other tools
//!
//! This library contains the tidy lints and exposes it
//! to be used by tools.
#![deny(warnings)]
use std::fs;
use std::path::Path;
macro_rules! t {
($e:expr, $p:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed on {} with {}", stringify!($e), ($p).display(), e),
});
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {}", stringify!($e), e),
})
}
macro_rules! tidy_error {
($bad:expr, $fmt:expr, $($arg:tt)*) => ({
*$bad = true;
2017-12-06 09:25:29 +01:00
eprint!("tidy error: ");
eprintln!($fmt, $($arg)*);
});
}
pub mod bins;
pub mod style;
pub mod errors;
pub mod features;
pub mod cargo;
pub mod pal;
pub mod deps;
pub mod unstable_book;
fn filter_dirs(path: &Path) -> bool {
let skip = [
2017-12-06 09:25:29 +01:00
"src/binaryen",
"src/dlmalloc",
"src/jemalloc",
"src/llvm",
rustc: Split Emscripten to a separate codegen backend This commit introduces a separately compiled backend for Emscripten, avoiding compiling the `JSBackend` target in the main LLVM codegen backend. This builds on the foundation provided by #47671 to create a new codegen backend dedicated solely to Emscripten, removing the `JSBackend` of the main codegen backend in the process. A new field was added to each target for this commit which specifies the backend to use for translation, the default being `llvm` which is the main backend that we use. The Emscripten targets specify an `emscripten` backend instead of the main `llvm` one. There's a whole bunch of consequences of this change, but I'll try to enumerate them here: * A *second* LLVM submodule was added in this commit. The main LLVM submodule will soon start to drift from the Emscripten submodule, but currently they're both at the same revision. * Logic was added to rustbuild to *not* build the Emscripten backend by default. This is gated behind a `--enable-emscripten` flag to the configure script. By default users should neither check out the emscripten submodule nor compile it. * The `init_repo.sh` script was updated to fetch the Emscripten submodule from GitHub the same way we do the main LLVM submodule (a tarball fetch). * The Emscripten backend, turned off by default, is still turned on for a number of targets on CI. We'll only be shipping an Emscripten backend with Tier 1 platforms, though. All cross-compiled platforms will not be receiving an Emscripten backend yet. This commit means that when you download the `rustc` package in Rustup for Tier 1 platforms you'll be receiving two trans backends, one for Emscripten and one that's the general LLVM backend. If you never compile for Emscripten you'll never use the Emscripten backend, so we may update this one day to only download the Emscripten backend when you add the Emscripten target. For now though it's just an extra 10MB gzip'd. Closes #46819
2018-01-24 17:22:34 +01:00
"src/llvm-emscripten",
"src/libbacktrace",
"src/libcompiler_builtins",
"src/librustc_data_structures/owning_ref",
"src/compiler-rt",
"src/liblibc",
"src/vendor",
"src/rt/hoedown",
"src/tools/cargo",
"src/tools/rls",
2017-08-15 14:27:20 +02:00
"src/tools/clippy",
"src/tools/rust-installer",
2017-09-01 08:43:00 +02:00
"src/tools/rustfmt",
"src/tools/miri",
"src/librustc/mir/interpret",
"src/librustc_mir/interpret",
2018-01-18 06:32:32 +01:00
"src/target",
];
skip.iter().any(|p| path.ends_with(p))
}
fn walk_many(paths: &[&Path], skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
for path in paths {
walk(path, skip, f);
}
}
fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
for entry in t!(fs::read_dir(path), path) {
let entry = t!(entry);
let kind = t!(entry.file_type());
let path = entry.path();
if kind.is_dir() {
if !skip(&path) {
walk(&path, skip, f);
}
} else {
f(&path);
}
}
}