diff options
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 4 | ||||
-rw-r--r-- | xtask/src/codegen/gen_diagnostic_docs.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/gen_feature_docs.rs | 2 | ||||
-rw-r--r-- | xtask/src/lib.rs | 6 | ||||
-rw-r--r-- | xtask/src/main.rs | 34 |
5 files changed, 30 insertions, 18 deletions
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 6e18a50a6..51f58180c 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -4,7 +4,7 @@ use std::{fmt, path::Path}; | |||
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE}, | 6 | codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE}, |
7 | project_root, rust_files, Result, | 7 | project_root, rust_files_in, Result, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | pub fn generate_assists_tests(mode: Mode) -> Result<()> { | 10 | pub fn generate_assists_tests(mode: Mode) -> Result<()> { |
@@ -32,7 +32,7 @@ struct Assist { | |||
32 | impl Assist { | 32 | impl Assist { |
33 | fn collect() -> Result<Vec<Assist>> { | 33 | fn collect() -> Result<Vec<Assist>> { |
34 | let mut res = Vec::new(); | 34 | let mut res = Vec::new(); |
35 | for path in rust_files(&project_root().join("crates/assists/src/handlers")) { | 35 | for path in rust_files_in(&project_root().join("crates/assists/src/handlers")) { |
36 | collect_file(&mut res, path.as_path())?; | 36 | collect_file(&mut res, path.as_path())?; |
37 | } | 37 | } |
38 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); | 38 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); |
diff --git a/xtask/src/codegen/gen_diagnostic_docs.rs b/xtask/src/codegen/gen_diagnostic_docs.rs index 00aaea5b7..7c14d4a07 100644 --- a/xtask/src/codegen/gen_diagnostic_docs.rs +++ b/xtask/src/codegen/gen_diagnostic_docs.rs | |||
@@ -27,7 +27,7 @@ struct Diagnostic { | |||
27 | impl Diagnostic { | 27 | impl Diagnostic { |
28 | fn collect() -> Result<Vec<Diagnostic>> { | 28 | fn collect() -> Result<Vec<Diagnostic>> { |
29 | let mut res = Vec::new(); | 29 | let mut res = Vec::new(); |
30 | for path in rust_files(&project_root()) { | 30 | for path in rust_files() { |
31 | collect_file(&mut res, path)?; | 31 | collect_file(&mut res, path)?; |
32 | } | 32 | } |
33 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); | 33 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); |
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 065dd33f1..61081063b 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs | |||
@@ -26,7 +26,7 @@ struct Feature { | |||
26 | impl Feature { | 26 | impl Feature { |
27 | fn collect() -> Result<Vec<Feature>> { | 27 | fn collect() -> Result<Vec<Feature>> { |
28 | let mut res = Vec::new(); | 28 | let mut res = Vec::new(); |
29 | for path in rust_files(&project_root()) { | 29 | for path in rust_files() { |
30 | collect_file(&mut res, path)?; | 30 | collect_file(&mut res, path)?; |
31 | } | 31 | } |
32 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); | 32 | res.sort_by(|lhs, rhs| lhs.id.cmp(&rhs.id)); |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index babec2dbd..16b06b853 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -34,7 +34,11 @@ pub fn project_root() -> PathBuf { | |||
34 | .to_path_buf() | 34 | .to_path_buf() |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn rust_files(path: &Path) -> impl Iterator<Item = PathBuf> { | 37 | pub fn rust_files() -> impl Iterator<Item = PathBuf> { |
38 | rust_files_in(&project_root().join("crates")) | ||
39 | } | ||
40 | |||
41 | pub fn rust_files_in(path: &Path) -> impl Iterator<Item = PathBuf> { | ||
38 | let iter = WalkDir::new(path); | 42 | let iter = WalkDir::new(path); |
39 | return iter | 43 | return iter |
40 | .into_iter() | 44 | .into_iter() |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c3e5c7326..5a99f4a76 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | use std::env; | 11 | use std::env; |
12 | 12 | ||
13 | use anyhow::bail; | ||
13 | use codegen::CodegenCmd; | 14 | use codegen::CodegenCmd; |
14 | use pico_args::Arguments; | 15 | use pico_args::Arguments; |
15 | use xshell::{cmd, cp, pushd}; | 16 | use xshell::{cmd, cp, pushd}; |
@@ -76,7 +77,7 @@ FLAGS: | |||
76 | 77 | ||
77 | let client_opt = args.opt_value_from_str("--client")?; | 78 | let client_opt = args.opt_value_from_str("--client")?; |
78 | 79 | ||
79 | args.finish()?; | 80 | finish_args(args)?; |
80 | 81 | ||
81 | InstallCmd { | 82 | InstallCmd { |
82 | client: if server { None } else { Some(client_opt.unwrap_or_default()) }, | 83 | client: if server { None } else { Some(client_opt.unwrap_or_default()) }, |
@@ -86,53 +87,53 @@ FLAGS: | |||
86 | } | 87 | } |
87 | "codegen" => { | 88 | "codegen" => { |
88 | let features = args.contains("--features"); | 89 | let features = args.contains("--features"); |
89 | args.finish()?; | 90 | finish_args(args)?; |
90 | CodegenCmd { features }.run() | 91 | CodegenCmd { features }.run() |
91 | } | 92 | } |
92 | "format" => { | 93 | "format" => { |
93 | args.finish()?; | 94 | finish_args(args)?; |
94 | run_rustfmt(Mode::Overwrite) | 95 | run_rustfmt(Mode::Overwrite) |
95 | } | 96 | } |
96 | "install-pre-commit-hook" => { | 97 | "install-pre-commit-hook" => { |
97 | args.finish()?; | 98 | finish_args(args)?; |
98 | pre_commit::install_hook() | 99 | pre_commit::install_hook() |
99 | } | 100 | } |
100 | "lint" => { | 101 | "lint" => { |
101 | args.finish()?; | 102 | finish_args(args)?; |
102 | run_clippy() | 103 | run_clippy() |
103 | } | 104 | } |
104 | "fuzz-tests" => { | 105 | "fuzz-tests" => { |
105 | args.finish()?; | 106 | finish_args(args)?; |
106 | run_fuzzer() | 107 | run_fuzzer() |
107 | } | 108 | } |
108 | "pre-cache" => { | 109 | "pre-cache" => { |
109 | args.finish()?; | 110 | finish_args(args)?; |
110 | PreCacheCmd.run() | 111 | PreCacheCmd.run() |
111 | } | 112 | } |
112 | "release" => { | 113 | "release" => { |
113 | let dry_run = args.contains("--dry-run"); | 114 | let dry_run = args.contains("--dry-run"); |
114 | args.finish()?; | 115 | finish_args(args)?; |
115 | ReleaseCmd { dry_run }.run() | 116 | ReleaseCmd { dry_run }.run() |
116 | } | 117 | } |
117 | "promote" => { | 118 | "promote" => { |
118 | let dry_run = args.contains("--dry-run"); | 119 | let dry_run = args.contains("--dry-run"); |
119 | args.finish()?; | 120 | finish_args(args)?; |
120 | PromoteCmd { dry_run }.run() | 121 | PromoteCmd { dry_run }.run() |
121 | } | 122 | } |
122 | "dist" => { | 123 | "dist" => { |
123 | let nightly = args.contains("--nightly"); | 124 | let nightly = args.contains("--nightly"); |
124 | let client_version: Option<String> = args.opt_value_from_str("--client")?; | 125 | let client_version: Option<String> = args.opt_value_from_str("--client")?; |
125 | args.finish()?; | 126 | finish_args(args)?; |
126 | DistCmd { nightly, client_version }.run() | 127 | DistCmd { nightly, client_version }.run() |
127 | } | 128 | } |
128 | "metrics" => { | 129 | "metrics" => { |
129 | let dry_run = args.contains("--dry-run"); | 130 | let dry_run = args.contains("--dry-run"); |
130 | args.finish()?; | 131 | finish_args(args)?; |
131 | MetricsCmd { dry_run }.run() | 132 | MetricsCmd { dry_run }.run() |
132 | } | 133 | } |
133 | "bb" => { | 134 | "bb" => { |
134 | let suffix: String = args.free_from_str()?.unwrap(); | 135 | let suffix: String = args.free_from_str()?; |
135 | args.finish()?; | 136 | finish_args(args)?; |
136 | cmd!("cargo build --release").run()?; | 137 | cmd!("cargo build --release").run()?; |
137 | cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?; | 138 | cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?; |
138 | Ok(()) | 139 | Ok(()) |
@@ -161,3 +162,10 @@ SUBCOMMANDS: | |||
161 | } | 162 | } |
162 | } | 163 | } |
163 | } | 164 | } |
165 | |||
166 | fn finish_args(args: Arguments) -> Result<()> { | ||
167 | if !args.finish().is_empty() { | ||
168 | bail!("Unused arguments."); | ||
169 | } | ||
170 | Ok(()) | ||
171 | } | ||