summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/run.rs')
-rw-r--r--src/bootstrap/run.rs61
1 files changed, 58 insertions, 3 deletions
diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs
index e14440f57..ec01f744b 100644
--- a/src/bootstrap/run.rs
+++ b/src/bootstrap/run.rs
@@ -1,9 +1,12 @@
use std::path::PathBuf;
use std::process::Command;
+use clap_complete::shells;
+
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::config::TargetSelection;
use crate::dist::distdir;
+use crate::flags::get_completion;
use crate::test;
use crate::tool::{self, SourceType, Tool};
use crate::util::output;
@@ -105,7 +108,7 @@ impl Step for BumpStage0 {
fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = builder.tool_cmd(Tool::BumpStage0);
- cmd.args(builder.config.cmd.args());
+ cmd.args(builder.config.args());
builder.run(&mut cmd);
}
}
@@ -182,8 +185,7 @@ impl Step for Miri {
miri.add_rustc_lib_path(builder, compiler);
// Forward arguments.
miri.arg("--").arg("--target").arg(target.rustc_target_arg());
- miri.args(builder.config.cmd.args());
- miri.args(&builder.config.free_args);
+ miri.args(builder.config.args());
// miri tests need to know about the stage sysroot
miri.env("MIRI_SYSROOT", &miri_sysroot);
@@ -254,3 +256,56 @@ impl Step for GenerateCopyright {
dest
}
}
+
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct GenerateWindowsSys;
+
+impl Step for GenerateWindowsSys {
+ type Output = ();
+ const ONLY_HOSTS: bool = true;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/tools/generate-windows-sys")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ run.builder.ensure(GenerateWindowsSys);
+ }
+
+ fn run(self, builder: &Builder<'_>) {
+ let mut cmd = builder.tool_cmd(Tool::GenerateWindowsSys);
+ cmd.arg(&builder.src);
+ builder.run(&mut cmd);
+ }
+}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct GenerateCompletions;
+
+impl Step for GenerateCompletions {
+ type Output = ();
+
+ /// Uses `clap_complete` to generate shell completions.
+ fn run(self, builder: &Builder<'_>) {
+ // FIXME(clubby789): enable zsh when clap#4898 is fixed
+ let [bash, fish, powershell] = ["x.py.sh", "x.py.fish", "x.py.ps1"]
+ .map(|filename| builder.src.join("src/etc/completions").join(filename));
+ if let Some(comp) = get_completion(shells::Bash, &bash) {
+ std::fs::write(&bash, comp).expect("writing bash completion");
+ }
+ if let Some(comp) = get_completion(shells::Fish, &fish) {
+ std::fs::write(&fish, comp).expect("writing fish completion");
+ }
+ if let Some(comp) = get_completion(shells::PowerShell, &powershell) {
+ std::fs::write(&powershell, comp).expect("writing powershell completion");
+ }
+ }
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.alias("generate-completions")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ run.builder.ensure(GenerateCompletions);
+ }
+}