Rollup merge of #46031 - Keruspe:cargofmt, r=Mark-Simulacrum
rustbuild: distribute cargo-fmt alongside rustfmt Not sure whether we want that nor if it's the right way to do so, but it feels quite weird to have rustfmt without cargo-fmt. Or are there other plans wrt that? What do you think @nrc ?
This commit is contained in:
commit
f8b3e7cee9
2 changed files with 60 additions and 138 deletions
|
@ -1168,7 +1168,12 @@ impl Step for Rustfmt {
|
||||||
compiler: builder.compiler(stage, build.build),
|
compiler: builder.compiler(stage, build.build),
|
||||||
target
|
target
|
||||||
}).expect("Rustfmt to build: toolstate is testing");
|
}).expect("Rustfmt to build: toolstate is testing");
|
||||||
|
let cargofmt = builder.ensure(tool::Cargofmt {
|
||||||
|
compiler: builder.compiler(stage, build.build),
|
||||||
|
target
|
||||||
|
}).expect("Cargofmt to build: toolstate is testing");
|
||||||
install(&rustfmt, &image.join("bin"), 0o755);
|
install(&rustfmt, &image.join("bin"), 0o755);
|
||||||
|
install(&cargofmt, &image.join("bin"), 0o755);
|
||||||
let doc = image.join("share/doc/rustfmt");
|
let doc = image.join("share/doc/rustfmt");
|
||||||
install(&src.join("README.md"), &doc, 0o644);
|
install(&src.join("README.md"), &doc, 0o644);
|
||||||
install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
install(&src.join("LICENSE-MIT"), &doc, 0o644);
|
||||||
|
|
|
@ -403,71 +403,66 @@ impl Step for Cargo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
macro_rules! tool_extended {
|
||||||
pub struct Clippy {
|
(($sel:ident, $builder:ident),
|
||||||
pub compiler: Compiler,
|
$($name:ident,
|
||||||
pub target: Interned<String>,
|
$toolstate:ident,
|
||||||
|
$path:expr,
|
||||||
|
$tool_name:expr,
|
||||||
|
$extra_deps:block;)+) => {
|
||||||
|
$(
|
||||||
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
|
pub struct $name {
|
||||||
|
pub compiler: Compiler,
|
||||||
|
pub target: Interned<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Step for $name {
|
||||||
|
type Output = Option<PathBuf>;
|
||||||
|
const DEFAULT: bool = true;
|
||||||
|
const ONLY_HOSTS: bool = true;
|
||||||
|
|
||||||
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
||||||
|
let builder = run.builder;
|
||||||
|
run.path($path).default_condition(builder.build.config.extended)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_run(run: RunConfig) {
|
||||||
|
run.builder.ensure($name {
|
||||||
|
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
|
||||||
|
target: run.target,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run($sel, $builder: &Builder) -> Option<PathBuf> {
|
||||||
|
$extra_deps
|
||||||
|
let toolstate = $builder.build.config.toolstate.$toolstate;
|
||||||
|
$builder.ensure(ToolBuild {
|
||||||
|
compiler: $sel.compiler,
|
||||||
|
target: $sel.target,
|
||||||
|
tool: $tool_name,
|
||||||
|
mode: Mode::Librustc,
|
||||||
|
path: $path,
|
||||||
|
expectation: toolstate.passes(ToolState::Compiling),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step for Clippy {
|
tool_extended!((self, builder),
|
||||||
type Output = Option<PathBuf>;
|
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", {};
|
||||||
const DEFAULT: bool = true;
|
Clippy, clippy, "src/tools/clippy", "clippy-driver", {
|
||||||
const ONLY_HOSTS: bool = true;
|
|
||||||
|
|
||||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
||||||
let builder = run.builder;
|
|
||||||
run.path("src/tools/clippy").default_condition(builder.build.config.extended)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_run(run: RunConfig) {
|
|
||||||
run.builder.ensure(Clippy {
|
|
||||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
|
|
||||||
target: run.target,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(self, builder: &Builder) -> Option<PathBuf> {
|
|
||||||
// Clippy depends on procedural macros (serde), which requires a full host
|
// Clippy depends on procedural macros (serde), which requires a full host
|
||||||
// compiler to be available, so we need to depend on that.
|
// compiler to be available, so we need to depend on that.
|
||||||
builder.ensure(compile::Rustc {
|
builder.ensure(compile::Rustc {
|
||||||
compiler: self.compiler,
|
compiler: self.compiler,
|
||||||
target: builder.build.build,
|
target: builder.build.build,
|
||||||
});
|
});
|
||||||
builder.ensure(ToolBuild {
|
};
|
||||||
compiler: self.compiler,
|
Miri, miri, "src/tools/miri", "miri", {};
|
||||||
target: self.target,
|
Rls, rls, "src/tools/rls", "rls", {
|
||||||
tool: "clippy-driver",
|
|
||||||
mode: Mode::Librustc,
|
|
||||||
path: "src/tools/clippy",
|
|
||||||
expectation: builder.build.config.toolstate.clippy.passes(ToolState::Compiling),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
||||||
pub struct Rls {
|
|
||||||
pub compiler: Compiler,
|
|
||||||
pub target: Interned<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Step for Rls {
|
|
||||||
type Output = Option<PathBuf>;
|
|
||||||
const DEFAULT: bool = true;
|
|
||||||
const ONLY_HOSTS: bool = true;
|
|
||||||
|
|
||||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
||||||
let builder = run.builder;
|
|
||||||
run.path("src/tools/rls").default_condition(builder.build.config.extended)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_run(run: RunConfig) {
|
|
||||||
run.builder.ensure(Rls {
|
|
||||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
|
|
||||||
target: run.target,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(self, builder: &Builder) -> Option<PathBuf> {
|
|
||||||
builder.ensure(native::Openssl {
|
builder.ensure(native::Openssl {
|
||||||
target: self.target,
|
target: self.target,
|
||||||
});
|
});
|
||||||
|
@ -477,87 +472,9 @@ impl Step for Rls {
|
||||||
compiler: self.compiler,
|
compiler: self.compiler,
|
||||||
target: builder.build.build,
|
target: builder.build.build,
|
||||||
});
|
});
|
||||||
builder.ensure(ToolBuild {
|
};
|
||||||
compiler: self.compiler,
|
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", {};
|
||||||
target: self.target,
|
);
|
||||||
tool: "rls",
|
|
||||||
mode: Mode::Librustc,
|
|
||||||
path: "src/tools/rls",
|
|
||||||
expectation: builder.build.config.toolstate.rls.passes(ToolState::Compiling),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
||||||
pub struct Rustfmt {
|
|
||||||
pub compiler: Compiler,
|
|
||||||
pub target: Interned<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Step for Rustfmt {
|
|
||||||
type Output = Option<PathBuf>;
|
|
||||||
const DEFAULT: bool = true;
|
|
||||||
const ONLY_HOSTS: bool = true;
|
|
||||||
|
|
||||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
||||||
let builder = run.builder;
|
|
||||||
run.path("src/tools/rustfmt").default_condition(builder.build.config.extended)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_run(run: RunConfig) {
|
|
||||||
run.builder.ensure(Rustfmt {
|
|
||||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
|
|
||||||
target: run.target,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(self, builder: &Builder) -> Option<PathBuf> {
|
|
||||||
builder.ensure(ToolBuild {
|
|
||||||
compiler: self.compiler,
|
|
||||||
target: self.target,
|
|
||||||
tool: "rustfmt",
|
|
||||||
mode: Mode::Librustc,
|
|
||||||
path: "src/tools/rustfmt",
|
|
||||||
expectation: builder.build.config.toolstate.rustfmt.passes(ToolState::Compiling),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
||||||
pub struct Miri {
|
|
||||||
pub compiler: Compiler,
|
|
||||||
pub target: Interned<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Step for Miri {
|
|
||||||
type Output = Option<PathBuf>;
|
|
||||||
const DEFAULT: bool = true;
|
|
||||||
const ONLY_HOSTS: bool = true;
|
|
||||||
|
|
||||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
||||||
let build_miri = run.builder.build.config.test_miri;
|
|
||||||
run.path("src/tools/miri").default_condition(build_miri)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_run(run: RunConfig) {
|
|
||||||
run.builder.ensure(Miri {
|
|
||||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build),
|
|
||||||
target: run.target,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(self, builder: &Builder) -> Option<PathBuf> {
|
|
||||||
builder.ensure(ToolBuild {
|
|
||||||
compiler: self.compiler,
|
|
||||||
target: self.target,
|
|
||||||
tool: "miri",
|
|
||||||
mode: Mode::Librustc,
|
|
||||||
path: "src/tools/miri",
|
|
||||||
expectation: builder.build.config.toolstate.miri.passes(ToolState::Compiling),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Builder<'a> {
|
impl<'a> Builder<'a> {
|
||||||
/// Get a `Command` which is ready to run `tool` in `stage` built for
|
/// Get a `Command` which is ready to run `tool` in `stage` built for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue