Skip to content

Commit

Permalink
Automatically enable the clippy feature of rls if clippy builds
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 16, 2018
1 parent 3b6412b commit 02ac15c
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 183 deletions.
194 changes: 24 additions & 170 deletions src/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ cargo = { path = "tools/cargo" }
# RLS depends on `rustfmt` from crates.io, so we put this in a `[patch]` section
# for crates.io
rustfmt-nightly = { path = "tools/rustfmt" }
clippy_lints = { path = "tools/clippy/clippy_lints" }
6 changes: 3 additions & 3 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ impl Step for Rls {
// state for RLS isn't testing.
let rls = builder.ensure(tool::Rls {
compiler: builder.compiler(stage, build.build),
target
target, extra_features: Vec::new()
}).or_else(|| { println!("Unable to build RLS, skipping dist"); None })?;

install(&rls, &image.join("bin"), 0o755);
Expand Down Expand Up @@ -1199,11 +1199,11 @@ impl Step for Rustfmt {
// Prepare the image directory
let rustfmt = builder.ensure(tool::Rustfmt {
compiler: builder.compiler(stage, build.build),
target
target, extra_features: Vec::new()
}).or_else(|| { println!("Unable to build Rustfmt, skipping dist"); None })?;
let cargofmt = builder.ensure(tool::Cargofmt {
compiler: builder.compiler(stage, build.build),
target
target, extra_features: Vec::new()
}).or_else(|| { println!("Unable to build Cargofmt, skipping dist"); None })?;

install(&rustfmt, &image.join("bin"), 0o755);
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#![deny(warnings)]
#![feature(core_intrinsics)]
#![feature(slice_concat_ext)]

#[macro_use]
extern crate build_helper;
Expand Down
18 changes: 14 additions & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl Step for Rls {
let host = self.host;
let compiler = builder.compiler(stage, host);

builder.ensure(tool::Rls { compiler, target: self.host });
builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
host,
Expand Down Expand Up @@ -291,7 +291,7 @@ impl Step for Rustfmt {
let host = self.host;
let compiler = builder.compiler(stage, host);

builder.ensure(tool::Rustfmt { compiler, target: self.host });
builder.ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() });
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
host,
Expand Down Expand Up @@ -339,7 +339,12 @@ impl Step for Miri {
let host = self.host;
let compiler = builder.compiler(stage, host);

if let Some(miri) = builder.ensure(tool::Miri { compiler, target: self.host }) {
let miri = builder.ensure(tool::Miri {
compiler,
target: self.host,
extra_features: Vec::new(),
});
if let Some(miri) = miri {
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml"));

Expand Down Expand Up @@ -391,7 +396,12 @@ impl Step for Clippy {
let host = self.host;
let compiler = builder.compiler(stage, host);

if let Some(clippy) = builder.ensure(tool::Clippy { compiler, target: self.host }) {
let clippy = builder.ensure(tool::Clippy {
compiler,
target: self.host,
extra_features: Vec::new(),
});
if let Some(clippy) = clippy {
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml"));

Expand Down
24 changes: 21 additions & 3 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::fs;
use std::env;
use std::path::PathBuf;
use std::process::{Command, exit};
use std::slice::SliceConcatExt;

use Mode;
use Compiler;
Expand Down Expand Up @@ -74,14 +75,15 @@ impl Step for CleanTools {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct ToolBuild {
compiler: Compiler,
target: Interned<String>,
tool: &'static str,
path: &'static str,
mode: Mode,
is_ext_tool: bool,
extra_features: Vec<String>,
}

impl Step for ToolBuild {
Expand Down Expand Up @@ -114,6 +116,7 @@ impl Step for ToolBuild {
println!("Building stage{} tool {} ({})", compiler.stage, tool, target);

let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
cargo.arg("--features").arg(self.extra_features.join(" "));
let is_expected = build.try_run(&mut cargo);
build.save_toolstate(tool, if is_expected {
ToolState::TestFail
Expand Down Expand Up @@ -242,6 +245,7 @@ macro_rules! tool {
mode: $mode,
path: $path,
is_ext_tool: false,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
}
Expand Down Expand Up @@ -291,6 +295,7 @@ impl Step for RemoteTestServer {
mode: Mode::Libstd,
path: "src/tools/remote-test-server",
is_ext_tool: false,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
}
Expand Down Expand Up @@ -409,6 +414,7 @@ impl Step for Cargo {
mode: Mode::Librustc,
path: "src/tools/cargo",
is_ext_tool: false,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
}
Expand All @@ -421,10 +427,11 @@ macro_rules! tool_extended {
$tool_name:expr,
$extra_deps:block;)+) => {
$(
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct $name {
pub compiler: Compiler,
pub target: Interned<String>,
pub extra_features: Vec<String>,
}

impl Step for $name {
Expand All @@ -441,17 +448,20 @@ macro_rules! tool_extended {
run.builder.ensure($name {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
target: run.target,
extra_features: Vec::new(),
});
}

fn run($sel, $builder: &Builder) -> Option<PathBuf> {
#[allow(unused_mut)]
fn run(mut $sel, $builder: &Builder) -> Option<PathBuf> {
$extra_deps
$builder.ensure(ToolBuild {
compiler: $sel.compiler,
target: $sel.target,
tool: $tool_name,
mode: Mode::Librustc,
path: $path,
extra_features: $sel.extra_features,
is_ext_tool: true,
})
}
Expand All @@ -472,6 +482,14 @@ tool_extended!((self, builder),
};
Miri, miri, "src/tools/miri", "miri", {};
Rls, rls, "src/tools/rls", "rls", {
let clippy = builder.ensure(Clippy {
compiler: self.compiler,
target: self.target,
extra_features: Vec::new(),
});
if clippy.is_some() {
self.extra_features.push("clippy".to_owned());
}
builder.ensure(native::Openssl {
target: self.target,
});
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy
2 changes: 1 addition & 1 deletion src/tools/miri
Submodule miri updated from 61833b to d4712c
2 changes: 1 addition & 1 deletion src/tools/rls
Submodule rls updated from b6c524 to fc4db0

0 comments on commit 02ac15c

Please sign in to comment.