aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-21 11:40:40 +0100
committerAleksey Kladov <[email protected]>2019-10-21 11:40:40 +0100
commit4aa7873588a218d4f771095073680f5040011f9c (patch)
tree3931ed78be20c6218f9968b803f6dd25ae8202fd /xtask
parent6b9bd7bdd2712a7e85d6bfc70c231dbe36c2e585 (diff)
try to warn about old rust
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/main.rs42
1 files changed, 40 insertions, 2 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 623058436..c08915aac 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -8,9 +8,12 @@ use pico_args::Arguments;
8use std::{env, path::PathBuf}; 8use std::{env, path::PathBuf};
9use xtask::{ 9use xtask::{
10 gen_tests, generate_boilerplate, install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt, 10 gen_tests, generate_boilerplate, install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt,
11 Cmd, Overwrite, Result, 11 run_with_output, Cmd, Overwrite, Result,
12}; 12};
13 13
14// Latest stable, feel free to send a PR if this lags behind.
15const REQUIRED_RUST_VERSION: u32 = 38;
16
14struct InstallOpt { 17struct InstallOpt {
15 client: Option<ClientOpt>, 18 client: Option<ClientOpt>,
16 server: Option<ServerOpt>, 19 server: Option<ServerOpt>,
@@ -210,9 +213,44 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
210} 213}
211 214
212fn install_server(opts: ServerOpt) -> Result<()> { 215fn install_server(opts: ServerOpt) -> Result<()> {
213 if opts.jemalloc { 216 let mut old_rust = false;
217 if let Ok(output) = run_with_output("cargo --version", ".") {
218 if let Ok(stdout) = String::from_utf8(output.stdout) {
219 if !check_version(&stdout, REQUIRED_RUST_VERSION) {
220 old_rust = true;
221 }
222 }
223 }
224
225 if old_rust {
226 eprintln!(
227 "\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n",
228 REQUIRED_RUST_VERSION
229 )
230 }
231
232 let res = if opts.jemalloc {
214 run("cargo install --path crates/ra_lsp_server --locked --force --features jemalloc", ".") 233 run("cargo install --path crates/ra_lsp_server --locked --force --features jemalloc", ".")
215 } else { 234 } else {
216 run("cargo install --path crates/ra_lsp_server --locked --force", ".") 235 run("cargo install --path crates/ra_lsp_server --locked --force", ".")
236 };
237
238 if res.is_err() && old_rust {
239 eprintln!(
240 "\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n",
241 REQUIRED_RUST_VERSION
242 )
243 }
244
245 res
246}
247
248fn check_version(version_output: &str, min_minor_version: u32) -> bool {
249 // Parse second the number out of
250 // cargo 1.39.0-beta (1c6ec66d5 2019-09-30)
251 let minor: Option<u32> = version_output.split('.').nth(1).and_then(|it| it.parse().ok());
252 match minor {
253 None => true,
254 Some(minor) => minor >= min_minor_version,
217 } 255 }
218} 256}