Skip to content

Commit

Permalink
Auto merge of #51122 - oli-obk:clippy, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Did you mean to block nightlies on clippy?

Discussion: https://gitter.im/rust-lang/WG-clippy?at=5b073b6597a0361fb760cdc2

r? @alexcrichton

did I forget anything?

cc @nrc @Manishearth
  • Loading branch information
bors committed Jul 2, 2018
2 parents e75e782 + 78adefd commit 4faaf7e
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,23 @@ dependencies = [

[[package]]
name = "clippy"
version = "0.0.202"
version = "0.0.211"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy-mini-macro-test 0.2.0",
"clippy_lints 0.0.202",
"clippy_lints 0.0.211",
"compiletest_rs 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand All @@ -329,7 +332,8 @@ version = "0.2.0"

[[package]]
name = "clippy_lints"
version = "0.0.202"
version = "0.0.205"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -349,8 +353,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.0.205"
source = "registry+https://github.com/rust-lang/crates.io-index"
version = "0.0.211"
dependencies = [
"cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ def bootstrap(help_triggered):
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
env["BOOTSTRAP_PYTHON"] = sys.executable
env["BUILD_DIR"] = build.build_dir
env["RUSTC_BOOTSTRAP"] = '1'
run(args, env=env, verbose=build.verbose)


Expand Down
113 changes: 113 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub fn pkgname(builder: &Builder, component: &str) -> String {
format!("{}-{}", component, builder.cargo_package_vers())
} else if component == "rls" {
format!("{}-{}", component, builder.rls_package_vers())
} else if component == "clippy" {
format!("{}-{}", component, builder.clippy_package_vers())
} else if component == "rustfmt" {
format!("{}-{}", component, builder.rustfmt_package_vers())
} else if component == "llvm-tools" {
Expand Down Expand Up @@ -1183,6 +1185,82 @@ impl Step for Rls {
}
}

#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Clippy {
pub stage: u32,
pub target: Interned<String>,
}

impl Step for Clippy {
type Output = Option<PathBuf>;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun) -> ShouldRun {
run.path("clippy")
}

fn make_run(run: RunConfig) {
run.builder.ensure(Clippy {
stage: run.builder.top_stage,
target: run.target,
});
}

fn run(self, builder: &Builder) -> Option<PathBuf> {
let stage = self.stage;
let target = self.target;
assert!(builder.config.extended);

builder.info(&format!("Dist clippy stage{} ({})", stage, target));
let src = builder.src.join("src/tools/clippy");
let release_num = builder.release_num("clippy");
let name = pkgname(builder, "clippy");
let version = builder.clippy_info.version(builder, &release_num);

let tmp = tmpdir(builder);
let image = tmp.join("clippy-image");
drop(fs::remove_dir_all(&image));
t!(fs::create_dir_all(&image));

// Prepare the image directory
// We expect clippy to build, because we've exited this step above if tool
// state for clippy isn't testing.
let clippy = builder.ensure(tool::Clippy {
compiler: builder.compiler(stage, builder.config.build),
target, extra_features: Vec::new()
}).or_else(|| { println!("Unable to build clippy, skipping dist"); None })?;

builder.install(&clippy, &image.join("bin"), 0o755);
let doc = image.join("share/doc/clippy");
builder.install(&src.join("README.md"), &doc, 0o644);
builder.install(&src.join("LICENSE"), &doc, 0o644);

// Prepare the overlay
let overlay = tmp.join("clippy-overlay");
drop(fs::remove_dir_all(&overlay));
t!(fs::create_dir_all(&overlay));
builder.install(&src.join("README.md"), &overlay, 0o644);
builder.install(&src.join("LICENSE"), &doc, 0o644);
builder.create(&overlay.join("version"), &version);

// Generate the installer tarball
let mut cmd = rust_installer(builder);
cmd.arg("generate")
.arg("--product-name=Rust")
.arg("--rel-manifest-dir=rustlib")
.arg("--success-message=clippy-ready-to-serve.")
.arg("--image-dir").arg(&image)
.arg("--work-dir").arg(&tmpdir(builder))
.arg("--output-dir").arg(&distdir(builder))
.arg("--non-installed-overlay").arg(&overlay)
.arg(format!("--package-name={}-{}", name, target))
.arg("--legacy-manifest-dirs=rustlib,cargo")
.arg("--component-name=clippy-preview");

builder.run(&mut cmd);
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target)))
}
}

#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustfmt {
Expand Down Expand Up @@ -1304,6 +1382,7 @@ impl Step for Extended {
let rustfmt_installer = builder.ensure(Rustfmt { stage, target });
let rls_installer = builder.ensure(Rls { stage, target });
let llvm_tools_installer = builder.ensure(LlvmTools { stage, target });
let clippy_installer = builder.ensure(Clippy { stage, target });
let mingw_installer = builder.ensure(Mingw { host: target });
let analysis_installer = builder.ensure(Analysis {
compiler: builder.compiler(stage, self.host),
Expand Down Expand Up @@ -1340,6 +1419,7 @@ impl Step for Extended {
tarballs.push(rustc_installer);
tarballs.push(cargo_installer);
tarballs.extend(rls_installer.clone());
tarballs.extend(clippy_installer.clone());
tarballs.extend(rustfmt_installer.clone());
tarballs.extend(llvm_tools_installer.clone());
tarballs.push(analysis_installer);
Expand Down Expand Up @@ -1409,6 +1489,9 @@ impl Step for Extended {
if rls_installer.is_none() {
contents = filter(&contents, "rls");
}
if clippy_installer.is_none() {
contents = filter(&contents, "clippy");
}
if rustfmt_installer.is_none() {
contents = filter(&contents, "rustfmt");
}
Expand Down Expand Up @@ -1446,6 +1529,9 @@ impl Step for Extended {
if rls_installer.is_some() {
prepare("rls");
}
if clippy_installer.is_some() {
prepare("clippy");
}

// create an 'uninstall' package
builder.install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755);
Expand Down Expand Up @@ -1474,6 +1560,8 @@ impl Step for Extended {
format!("{}-{}", name, target)
} else if name == "rls" {
"rls-preview".to_string()
} else if name == "clippy" {
"clippy-preview".to_string()
} else {
name.to_string()
};
Expand All @@ -1490,6 +1578,9 @@ impl Step for Extended {
if rls_installer.is_some() {
prepare("rls");
}
if clippy_installer.is_some() {
prepare("clippy");
}
if target.contains("windows-gnu") {
prepare("rust-mingw");
}
Expand Down Expand Up @@ -1570,6 +1661,18 @@ impl Step for Extended {
.arg("-out").arg(exe.join("RlsGroup.wxs"))
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
}
if clippy_installer.is_some() {
builder.run(Command::new(&heat)
.current_dir(&exe)
.arg("dir")
.arg("clippy")
.args(&heat_flags)
.arg("-cg").arg("ClippyGroup")
.arg("-dr").arg("Clippy")
.arg("-var").arg("var.ClippyDir")
.arg("-out").arg(exe.join("ClippyGroup.wxs"))
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
}
builder.run(Command::new(&heat)
.current_dir(&exe)
.arg("dir")
Expand Down Expand Up @@ -1612,6 +1715,9 @@ impl Step for Extended {
if rls_installer.is_some() {
cmd.arg("-dRlsDir=rls");
}
if clippy_installer.is_some() {
cmd.arg("-dClippyDir=clippy");
}
if target.contains("windows-gnu") {
cmd.arg("-dGccDir=rust-mingw");
}
Expand All @@ -1627,6 +1733,9 @@ impl Step for Extended {
if rls_installer.is_some() {
candle("RlsGroup.wxs".as_ref());
}
if clippy_installer.is_some() {
candle("ClippyGroup.wxs".as_ref());
}
candle("AnalysisGroup.wxs".as_ref());

if target.contains("windows-gnu") {
Expand Down Expand Up @@ -1656,6 +1765,9 @@ impl Step for Extended {
if rls_installer.is_some() {
cmd.arg("RlsGroup.wixobj");
}
if clippy_installer.is_some() {
cmd.arg("ClippyGroup.wixobj");
}

if target.contains("windows-gnu") {
cmd.arg("GccGroup.wixobj");
Expand Down Expand Up @@ -1741,6 +1853,7 @@ impl Step for HashSign {
cmd.arg(builder.rust_package_vers());
cmd.arg(builder.package_vers(&builder.release_num("cargo")));
cmd.arg(builder.package_vers(&builder.release_num("rls")));
cmd.arg(builder.package_vers(&builder.release_num("clippy")));
cmd.arg(builder.package_vers(&builder.release_num("rustfmt")));
cmd.arg(builder.llvm_tools_package_vers());
cmd.arg(addr);
Expand Down
11 changes: 11 additions & 0 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub fn install_cargo(builder: &Builder, stage: u32, host: Interned<String>) {
pub fn install_rls(builder: &Builder, stage: u32, host: Interned<String>) {
install_sh(builder, "rls", "rls", stage, Some(host));
}
pub fn install_clippy(builder: &Builder, stage: u32, host: Interned<String>) {
install_sh(builder, "clippy", "clippy", stage, Some(host));
}

pub fn install_rustfmt(builder: &Builder, stage: u32, host: Interned<String>) {
install_sh(builder, "rustfmt", "rustfmt", stage, Some(host));
Expand Down Expand Up @@ -216,6 +219,14 @@ install!((self, builder, _config),
builder.info(&format!("skipping Install RLS stage{} ({})", self.stage, self.target));
}
};
Clippy, "clippy", Self::should_build(_config), only_hosts: true, {
if builder.ensure(dist::Clippy { stage: self.stage, target: self.target }).is_some() ||
Self::should_install(builder) {
install_clippy(builder, self.stage, self.target);
} else {
builder.info(&format!("skipping Install clippy stage{} ({})", self.stage, self.target));
}
};
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
Self::should_install(builder) {
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ pub struct Build {
rust_info: channel::GitInfo,
cargo_info: channel::GitInfo,
rls_info: channel::GitInfo,
clippy_info: channel::GitInfo,
rustfmt_info: channel::GitInfo,
local_rebuild: bool,
fail_fast: bool,
Expand Down Expand Up @@ -363,6 +364,7 @@ impl Build {
let rust_info = channel::GitInfo::new(&config, &src);
let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo"));
let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls"));
let clippy_info = channel::GitInfo::new(&config, &src.join("src/tools/clippy"));
let rustfmt_info = channel::GitInfo::new(&config, &src.join("src/tools/rustfmt"));

let mut build = Build {
Expand All @@ -384,6 +386,7 @@ impl Build {
rust_info,
cargo_info,
rls_info,
clippy_info,
rustfmt_info,
cc: HashMap::new(),
cxx: HashMap::new(),
Expand Down Expand Up @@ -968,6 +971,11 @@ impl Build {
self.package_vers(&self.release_num("rls"))
}

/// Returns the value of `package_vers` above for clippy
fn clippy_package_vers(&self) -> String {
self.package_vers(&self.release_num("clippy"))
}

/// Returns the value of `package_vers` above for rustfmt
fn rustfmt_package_vers(&self) -> String {
self.package_vers(&self.release_num("rustfmt"))
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Step for ToolBuild {
let mut duplicates = Vec::new();
let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| {
// Only care about big things like the RLS/Cargo for now
if tool != "rls" && tool != "cargo" {
if tool != "rls" && tool != "cargo" && tool != "clippy-driver" {
return
}
let (id, features, filenames) = match msg {
Expand Down
Loading

0 comments on commit 4faaf7e

Please sign in to comment.