diff options
author | Aleksey Kladov <[email protected]> | 2019-11-14 08:11:32 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-14 08:12:52 +0000 |
commit | c65f42325fa9213ad79fcf12115213a923b651df (patch) | |
tree | a8ca8d4f048281a25636c7ec300fbd31f2199a68 /xtask | |
parent | 8af85263f7cd249356382aa61b98094594165364 (diff) |
Revert #2230
Looks like autocfg tries to do slightly more than we need (see #2231),
so let's stick with minimal home-grown solution.
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/Cargo.toml | 1 | ||||
-rw-r--r-- | xtask/src/main.rs | 36 |
2 files changed, 25 insertions, 12 deletions
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index bba4be192..77b9ae2b4 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml | |||
@@ -6,7 +6,6 @@ authors = ["rust-analyzer developers"] | |||
6 | publish = false | 6 | publish = false |
7 | 7 | ||
8 | [dependencies] | 8 | [dependencies] |
9 | autocfg = "0.1" | ||
10 | walkdir = "2.1.3" | 9 | walkdir = "2.1.3" |
11 | pico-args = "0.3.0" | 10 | pico-args = "0.3.0" |
12 | quote = "1.0.2" | 11 | quote = "1.0.2" |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7eab1c949..f14e6c8ae 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -10,18 +10,17 @@ | |||
10 | mod help; | 10 | mod help; |
11 | 11 | ||
12 | use anyhow::Context; | 12 | use anyhow::Context; |
13 | use autocfg; | ||
14 | use core::fmt::Write; | 13 | use core::fmt::Write; |
15 | use core::str; | 14 | use core::str; |
16 | use pico_args::Arguments; | 15 | use pico_args::Arguments; |
17 | use std::{env, path::PathBuf}; | 16 | use std::{env, path::PathBuf}; |
18 | use xtask::{ | 17 | use xtask::{ |
19 | codegen::{self, Mode}, | 18 | codegen::{self, Mode}, |
20 | install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt, Cmd, Result, | 19 | install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt, run_with_output, Cmd, Result, |
21 | }; | 20 | }; |
22 | 21 | ||
23 | // Latest stable, feel free to send a PR if this lags behind. | 22 | // Latest stable, feel free to send a PR if this lags behind. |
24 | const REQUIRED_RUST_VERSION: (usize, usize) = (1, 39); | 23 | const REQUIRED_RUST_VERSION: u32 = 39; |
25 | 24 | ||
26 | struct InstallOpt { | 25 | struct InstallOpt { |
27 | client: Option<ClientOpt>, | 26 | client: Option<ClientOpt>, |
@@ -230,15 +229,20 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
230 | } | 229 | } |
231 | 230 | ||
232 | fn install_server(opts: ServerOpt) -> Result<()> { | 231 | fn install_server(opts: ServerOpt) -> Result<()> { |
233 | let target_dir = env::var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()); | 232 | let mut old_rust = false; |
234 | let ac = autocfg::AutoCfg::with_dir(target_dir)?; | 233 | if let Ok(output) = run_with_output("cargo --version", ".") { |
235 | 234 | if let Ok(stdout) = String::from_utf8(output.stdout) { | |
236 | let old_rust = !ac.probe_rustc_version(REQUIRED_RUST_VERSION.0, REQUIRED_RUST_VERSION.1); | 235 | println!("{}", stdout); |
236 | if !check_version(&stdout, REQUIRED_RUST_VERSION) { | ||
237 | old_rust = true; | ||
238 | } | ||
239 | } | ||
240 | } | ||
237 | 241 | ||
238 | if old_rust { | 242 | if old_rust { |
239 | eprintln!( | 243 | eprintln!( |
240 | "\nWARNING: at least rust {}.{}.0 is required to compile rust-analyzer\n", | 244 | "\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n", |
241 | REQUIRED_RUST_VERSION.0, REQUIRED_RUST_VERSION.1 | 245 | REQUIRED_RUST_VERSION, |
242 | ) | 246 | ) |
243 | } | 247 | } |
244 | 248 | ||
@@ -250,10 +254,20 @@ fn install_server(opts: ServerOpt) -> Result<()> { | |||
250 | 254 | ||
251 | if res.is_err() && old_rust { | 255 | if res.is_err() && old_rust { |
252 | eprintln!( | 256 | eprintln!( |
253 | "\nWARNING: at least rust {}.{}.0 is required to compile rust-analyzer\n", | 257 | "\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n", |
254 | REQUIRED_RUST_VERSION.0, REQUIRED_RUST_VERSION.1 | 258 | REQUIRED_RUST_VERSION, |
255 | ) | 259 | ) |
256 | } | 260 | } |
257 | 261 | ||
258 | res | 262 | res |
259 | } | 263 | } |
264 | |||
265 | fn check_version(version_output: &str, min_minor_version: u32) -> bool { | ||
266 | // Parse second the number out of | ||
267 | // cargo 1.39.0-beta (1c6ec66d5 2019-09-30) | ||
268 | let minor: Option<u32> = version_output.split('.').nth(1).and_then(|it| it.parse().ok()); | ||
269 | match minor { | ||
270 | None => true, | ||
271 | Some(minor) => minor >= min_minor_version, | ||
272 | } | ||
273 | } | ||