diff options
Diffstat (limited to 'xtask/src/main.rs')
-rw-r--r-- | xtask/src/main.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index db901ced2..e04e45f15 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -1,5 +1,12 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! See https://github.com/matklad/cargo-xtask/. |
2 | 2 | //! | |
3 | //! This binary defines various auxiliary build commands, which are not | ||
4 | //! expressible with just `cargo`. Notably, it provides `cargo xtask codegen` | ||
5 | //! for code generation and `cargo xtask install` for installation of | ||
6 | //! rust-analyzer server and client. | ||
7 | //! | ||
8 | //! This binary is integrated into the `cargo` command line by using an alias in | ||
9 | //! `.cargo/config`. | ||
3 | mod help; | 10 | mod help; |
4 | 11 | ||
5 | use core::fmt::Write; | 12 | use core::fmt::Write; |
@@ -53,7 +60,7 @@ fn main() -> Result<()> { | |||
53 | matches.finish().or_else(handle_extra_flags)?; | 60 | matches.finish().or_else(handle_extra_flags)?; |
54 | let opts = InstallOpt { | 61 | let opts = InstallOpt { |
55 | client: if server { None } else { Some(ClientOpt::VsCode) }, | 62 | client: if server { None } else { Some(ClientOpt::VsCode) }, |
56 | server: if client_code { None } else { Some(ServerOpt { jemalloc: jemalloc }) }, | 63 | server: if client_code { None } else { Some(ServerOpt { jemalloc }) }, |
57 | }; | 64 | }; |
58 | install(opts)? | 65 | install(opts)? |
59 | } | 66 | } |
@@ -64,6 +71,7 @@ fn main() -> Result<()> { | |||
64 | } | 71 | } |
65 | codegen::generate_syntax(Mode::Overwrite)?; | 72 | codegen::generate_syntax(Mode::Overwrite)?; |
66 | codegen::generate_parser_tests(Mode::Overwrite)?; | 73 | codegen::generate_parser_tests(Mode::Overwrite)?; |
74 | codegen::generate_assists_docs(Mode::Overwrite)?; | ||
67 | } | 75 | } |
68 | "format" => { | 76 | "format" => { |
69 | if matches.contains(["-h", "--help"]) { | 77 | if matches.contains(["-h", "--help"]) { |
@@ -158,6 +166,17 @@ fn fix_path_for_mac() -> Result<()> { | |||
158 | } | 166 | } |
159 | 167 | ||
160 | fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | 168 | fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { |
169 | let npm_version = Cmd { | ||
170 | unix: r"npm --version", | ||
171 | windows: r"cmd.exe /c npm.cmd --version", | ||
172 | work_dir: "./editors/code", | ||
173 | } | ||
174 | .run(); | ||
175 | |||
176 | if npm_version.is_err() { | ||
177 | eprintln!("\nERROR: `npm --version` failed, `npm` is required to build the VS Code plugin") | ||
178 | } | ||
179 | |||
161 | Cmd { unix: r"npm ci", windows: r"cmd.exe /c npm.cmd ci", work_dir: "./editors/code" }.run()?; | 180 | Cmd { unix: r"npm ci", windows: r"cmd.exe /c npm.cmd ci", work_dir: "./editors/code" }.run()?; |
162 | Cmd { | 181 | Cmd { |
163 | unix: r"npm run package", | 182 | unix: r"npm run package", |
@@ -210,6 +229,7 @@ fn install_server(opts: ServerOpt) -> Result<()> { | |||
210 | let mut old_rust = false; | 229 | let mut old_rust = false; |
211 | if let Ok(output) = run_with_output("cargo --version", ".") { | 230 | if let Ok(output) = run_with_output("cargo --version", ".") { |
212 | if let Ok(stdout) = String::from_utf8(output.stdout) { | 231 | if let Ok(stdout) = String::from_utf8(output.stdout) { |
232 | println!("{}", stdout); | ||
213 | if !check_version(&stdout, REQUIRED_RUST_VERSION) { | 233 | if !check_version(&stdout, REQUIRED_RUST_VERSION) { |
214 | old_rust = true; | 234 | old_rust = true; |
215 | } | 235 | } |