diff --git a/src/Cargo.lock b/src/Cargo.lock index 5d09507c41bf143423152d8c70d744251f4aa76c..dd4b09fa20d7cf6460a82d23bee069d9a73b9ed8 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -307,12 +307,12 @@ 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)", "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)", @@ -329,7 +329,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)", @@ -349,8 +350,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)", diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 4fd6c81e5978682ec19ea71b65387362bfe3cabd..103fba0c62b1db9f76053baa035bafdd0787a554 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -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" { @@ -1183,6 +1185,83 @@ fn run(self, builder: &Builder) -> Option { } } +#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Clippy { + pub stage: u32, + pub target: Interned, +} + +impl Step for Clippy { + type Output = Option; + 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 { + 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-MIT"), &overlay, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &overlay, 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 { @@ -1304,6 +1383,7 @@ fn run(self, builder: &Builder) { 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), @@ -1340,6 +1420,7 @@ fn run(self, builder: &Builder) { 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); @@ -1409,6 +1490,9 @@ fn filter(contents: &str, marker: &str) -> String { 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"); } @@ -1446,6 +1530,9 @@ fn filter(contents: &str, marker: &str) -> String { 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); @@ -1474,6 +1561,8 @@ fn filter(contents: &str, marker: &str) -> String { format!("{}-{}", name, target) } else if name == "rls" { "rls-preview".to_string() + } else if name == "clippy" { + "clippy-preview".to_string() } else { name.to_string() }; @@ -1490,6 +1579,9 @@ fn filter(contents: &str, marker: &str) -> String { if rls_installer.is_some() { prepare("rls"); } + if clippy_installer.is_some() { + prepare("clippy"); + } if target.contains("windows-gnu") { prepare("rust-mingw"); } @@ -1570,6 +1662,18 @@ fn filter(contents: &str, marker: &str) -> String { .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") @@ -1612,6 +1716,9 @@ fn filter(contents: &str, marker: &str) -> String { 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"); } @@ -1627,6 +1734,9 @@ fn filter(contents: &str, marker: &str) -> String { 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") { @@ -1656,6 +1766,9 @@ fn filter(contents: &str, marker: &str) -> String { 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"); @@ -1741,6 +1854,7 @@ fn run(self, builder: &Builder) { 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); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index b37a007e86390249fec901326a0220ddd6ab11ba..97fd6f77646637a68c1b9fed02d8181b1d96bc56 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -39,6 +39,9 @@ pub fn install_cargo(builder: &Builder, stage: u32, host: Interned) { pub fn install_rls(builder: &Builder, stage: u32, host: Interned) { install_sh(builder, "rls", "rls", stage, Some(host)); } +pub fn install_clippy(builder: &Builder, stage: u32, host: Interned) { + install_sh(builder, "clippy", "clippy", stage, Some(host)); +} pub fn install_rustfmt(builder: &Builder, stage: u32, host: Interned) { install_sh(builder, "rustfmt", "rustfmt", stage, Some(host)); @@ -216,6 +219,14 @@ fn run($sel, $builder: &Builder) { 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) { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b5d450b88392d0d8bd1c575f72bd4fe0cbc5f5bd..414f17dfad40059db52db5e79f5b95c3172a9764 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -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, @@ -363,6 +364,7 @@ pub fn new(config: Config) -> 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 { @@ -384,6 +386,7 @@ pub fn new(config: Config) -> Build { rust_info, cargo_info, rls_info, + clippy_info, rustfmt_info, cc: HashMap::new(), cxx: HashMap::new(), @@ -968,6 +971,11 @@ fn rls_package_vers(&self) -> String { 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")) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 0a428a61d120299354400223834a0eacfa0e1501..23b3f5a0826ecab3837d33527d637d2c8cbd3f47 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -118,7 +118,7 @@ fn run(self, builder: &Builder) -> Option { 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 { diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 35fc2182313c95de4b4a65076a3741f4e7473038..92c4545429f546f6bea2991264159cc71ec7ba02 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -183,6 +183,7 @@ struct Builder { rust_release: String, cargo_release: String, rls_release: String, + clippy_release: String, rustfmt_release: String, llvm_tools_release: String, @@ -196,12 +197,14 @@ struct Builder { rust_version: Option, cargo_version: Option, rls_version: Option, + clippy_version: Option, rustfmt_version: Option, llvm_tools_version: Option, rust_git_commit_hash: Option, cargo_git_commit_hash: Option, rls_git_commit_hash: Option, + clippy_git_commit_hash: Option, rustfmt_git_commit_hash: Option, llvm_tools_git_commit_hash: Option, } @@ -214,6 +217,7 @@ fn main() { let rust_release = args.next().unwrap(); let cargo_release = args.next().unwrap(); let rls_release = args.next().unwrap(); + let clippy_release = args.next().unwrap(); let rustfmt_release = args.next().unwrap(); let llvm_tools_release = args.next().unwrap(); let s3_address = args.next().unwrap(); @@ -224,6 +228,7 @@ fn main() { rust_release, cargo_release, rls_release, + clippy_release, rustfmt_release, llvm_tools_release, @@ -237,12 +242,14 @@ fn main() { rust_version: None, cargo_version: None, rls_version: None, + clippy_version: None, rustfmt_version: None, llvm_tools_version: None, rust_git_commit_hash: None, cargo_git_commit_hash: None, rls_git_commit_hash: None, + clippy_git_commit_hash: None, rustfmt_git_commit_hash: None, llvm_tools_git_commit_hash: None, }.build(); @@ -259,6 +266,7 @@ fn build(&mut self) { self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu"); self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu"); self.rls_git_commit_hash = self.git_commit_hash("rls", "x86_64-unknown-linux-gnu"); + self.clippy_git_commit_hash = self.git_commit_hash("clippy", "x86_64-unknown-linux-gnu"); self.rustfmt_git_commit_hash = self.git_commit_hash("rustfmt", "x86_64-unknown-linux-gnu"); self.llvm_tools_git_commit_hash = self.git_commit_hash("llvm-tools", "x86_64-unknown-linux-gnu"); @@ -296,10 +304,12 @@ fn build_manifest(&mut self) -> Manifest { self.package("rust-docs", &mut manifest.pkg, TARGETS); self.package("rust-src", &mut manifest.pkg, &["*"]); self.package("rls-preview", &mut manifest.pkg, HOSTS); + self.package("clippy-preview", &mut manifest.pkg, HOSTS); self.package("rustfmt-preview", &mut manifest.pkg, HOSTS); self.package("rust-analysis", &mut manifest.pkg, TARGETS); self.package("llvm-tools", &mut manifest.pkg, TARGETS); + let clippy_present = manifest.pkg.contains_key("clippy-preview"); let rls_present = manifest.pkg.contains_key("rls-preview"); let rustfmt_present = manifest.pkg.contains_key("rustfmt-preview"); let llvm_tools_present = manifest.pkg.contains_key("llvm-tools"); @@ -345,6 +355,12 @@ fn build_manifest(&mut self) -> Manifest { }); } + if clippy_present { + extensions.push(Component { + pkg: "clippy-preview".to_string(), + target: host.to_string(), + }); + } if rls_present { extensions.push(Component { pkg: "rls-preview".to_string(), @@ -470,6 +486,8 @@ fn filename(&self, component: &str, target: &str) -> String { format!("cargo-{}-{}.tar.gz", self.cargo_release, target) } else if component == "rls" || component == "rls-preview" { format!("rls-{}-{}.tar.gz", self.rls_release, target) + } else if component == "clippy" || component == "clippy-preview" { + format!("clippy-{}-{}.tar.gz", self.clippy_release, target) } else if component == "rustfmt" || component == "rustfmt-preview" { format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target) } else if component == "llvm_tools" { @@ -484,6 +502,8 @@ fn cached_version(&self, component: &str) -> &Option { &self.cargo_version } else if component == "rls" || component == "rls-preview" { &self.rls_version + } else if component == "clippy" || component == "clippy-preview" { + &self.clippy_version } else if component == "rustfmt" || component == "rustfmt-preview" { &self.rustfmt_version } else if component == "llvm-tools" { @@ -498,6 +518,8 @@ fn cached_git_commit_hash(&self, component: &str) -> &Option { &self.cargo_git_commit_hash } else if component == "rls" || component == "rls-preview" { &self.rls_git_commit_hash + } else if component == "clippy" || component == "clippy-preview" { + &self.clippy_git_commit_hash } else if component == "rustfmt" || component == "rustfmt-preview" { &self.rustfmt_git_commit_hash } else if component == "llvm-tools" { diff --git a/src/tools/clippy b/src/tools/clippy index ebe0b0eed596243a2839867363cb31d93f0b9754..b4b6e6558e3ccd5ef11758297dc064acceb15ef2 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit ebe0b0eed596243a2839867363cb31d93f0b9754 +Subproject commit b4b6e6558e3ccd5ef11758297dc064acceb15ef2