diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/Cargo.toml | 1 | ||||
-rw-r--r-- | xtask/src/install.rs | 16 | ||||
-rw-r--r-- | xtask/src/lib.rs | 2 | ||||
-rw-r--r-- | xtask/src/main.rs | 15 | ||||
-rw-r--r-- | xtask/src/not_bash.rs | 5 | ||||
-rw-r--r-- | xtask/tests/tidy.rs | 41 |
6 files changed, 70 insertions, 10 deletions
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 8045a98ea..d1cfb5909 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml | |||
@@ -4,6 +4,7 @@ name = "xtask" | |||
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | publish = false | 6 | publish = false |
7 | license = "MIT OR Apache-2.0" | ||
7 | 8 | ||
8 | [lib] | 9 | [lib] |
9 | doctest = false | 10 | doctest = false |
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 9ba77a3aa..a0dc0c9c2 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -19,7 +19,13 @@ pub enum ClientOpt { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | pub struct ServerOpt { | 21 | pub struct ServerOpt { |
22 | pub jemalloc: bool, | 22 | pub malloc: Malloc, |
23 | } | ||
24 | |||
25 | pub enum Malloc { | ||
26 | System, | ||
27 | Jemalloc, | ||
28 | Mimalloc, | ||
23 | } | 29 | } |
24 | 30 | ||
25 | impl InstallCmd { | 31 | impl InstallCmd { |
@@ -130,8 +136,12 @@ fn install_server(opts: ServerOpt) -> Result<()> { | |||
130 | ) | 136 | ) |
131 | } | 137 | } |
132 | 138 | ||
133 | let jemalloc = if opts.jemalloc { "--features jemalloc" } else { "" }; | 139 | let malloc_feature = match opts.malloc { |
134 | let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", jemalloc); | 140 | Malloc::System => "", |
141 | Malloc::Jemalloc => "--features jemalloc", | ||
142 | Malloc::Mimalloc => "--features mimalloc", | ||
143 | }; | ||
144 | let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature); | ||
135 | 145 | ||
136 | if res.is_err() && old_rust { | 146 | if res.is_err() && old_rust { |
137 | eprintln!( | 147 | eprintln!( |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 747654c1f..94d451e23 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -20,7 +20,7 @@ use walkdir::{DirEntry, WalkDir}; | |||
20 | 20 | ||
21 | use crate::{ | 21 | use crate::{ |
22 | codegen::Mode, | 22 | codegen::Mode, |
23 | not_bash::{fs2, pushd, pushenv, rm_rf, run}, | 23 | not_bash::{fs2, pushd, pushenv, rm_rf}, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | pub use anyhow::{bail, Context as _, Result}; | 26 | pub use anyhow::{bail, Context as _, Result}; |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index f447613d4..399ff7204 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -14,7 +14,7 @@ use pico_args::Arguments; | |||
14 | use xtask::{ | 14 | use xtask::{ |
15 | codegen::{self, Mode}, | 15 | codegen::{self, Mode}, |
16 | dist::run_dist, | 16 | dist::run_dist, |
17 | install::{ClientOpt, InstallCmd, ServerOpt}, | 17 | install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, |
18 | not_bash::pushd, | 18 | not_bash::pushd, |
19 | pre_commit, project_root, | 19 | pre_commit, project_root, |
20 | release::{PromoteCmd, ReleaseCmd}, | 20 | release::{PromoteCmd, ReleaseCmd}, |
@@ -46,6 +46,7 @@ FLAGS: | |||
46 | --client-code Install only VS Code plugin | 46 | --client-code Install only VS Code plugin |
47 | --server Install only the language server | 47 | --server Install only the language server |
48 | --jemalloc Use jemalloc for server | 48 | --jemalloc Use jemalloc for server |
49 | --mimalloc Use mimalloc for server | ||
49 | -h, --help Prints help information | 50 | -h, --help Prints help information |
50 | " | 51 | " |
51 | ); | 52 | ); |
@@ -61,13 +62,21 @@ FLAGS: | |||
61 | return Ok(()); | 62 | return Ok(()); |
62 | } | 63 | } |
63 | 64 | ||
64 | let jemalloc = args.contains("--jemalloc"); | 65 | let malloc = match (args.contains("--jemalloc"), args.contains("--mimalloc")) { |
66 | (false, false) => Malloc::System, | ||
67 | (true, false) => Malloc::Jemalloc, | ||
68 | (false, true) => Malloc::Mimalloc, | ||
69 | (true, true) => { | ||
70 | eprintln!("error: Cannot use both `--jemalloc` and `--mimalloc`"); | ||
71 | return Ok(()); | ||
72 | } | ||
73 | }; | ||
65 | 74 | ||
66 | args.finish()?; | 75 | args.finish()?; |
67 | 76 | ||
68 | InstallCmd { | 77 | InstallCmd { |
69 | client: if server { None } else { Some(ClientOpt::VsCode) }, | 78 | client: if server { None } else { Some(ClientOpt::VsCode) }, |
70 | server: if client_code { None } else { Some(ServerOpt { jemalloc }) }, | 79 | server: if client_code { None } else { Some(ServerOpt { malloc }) }, |
71 | } | 80 | } |
72 | .run() | 81 | .run() |
73 | } | 82 | } |
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index 8844fa216..0f3a56b25 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs | |||
@@ -54,7 +54,8 @@ pub mod fs2 { | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | macro_rules! _run { | 57 | #[macro_export] |
58 | macro_rules! run { | ||
58 | ($($expr:expr),*) => { | 59 | ($($expr:expr),*) => { |
59 | run!($($expr),*; echo = true) | 60 | run!($($expr),*; echo = true) |
60 | }; | 61 | }; |
@@ -65,7 +66,7 @@ macro_rules! _run { | |||
65 | $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin)) | 66 | $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin)) |
66 | }; | 67 | }; |
67 | } | 68 | } |
68 | pub(crate) use _run as run; | 69 | pub use crate::run; |
69 | 70 | ||
70 | pub struct Pushd { | 71 | pub struct Pushd { |
71 | _p: (), | 72 | _p: (), |
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index fcfad609d..72088e414 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -5,7 +5,7 @@ use std::{ | |||
5 | 5 | ||
6 | use xtask::{ | 6 | use xtask::{ |
7 | codegen::{self, Mode}, | 7 | codegen::{self, Mode}, |
8 | not_bash::fs2, | 8 | not_bash::{fs2, run}, |
9 | project_root, run_rustfmt, rust_files, | 9 | project_root, run_rustfmt, rust_files, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -49,6 +49,45 @@ fn rust_files_are_tidy() { | |||
49 | tidy_docs.finish(); | 49 | tidy_docs.finish(); |
50 | } | 50 | } |
51 | 51 | ||
52 | #[test] | ||
53 | fn check_licenses() { | ||
54 | let expected = " | ||
55 | 0BSD OR MIT OR Apache-2.0 | ||
56 | Apache-2.0 | ||
57 | Apache-2.0 / MIT | ||
58 | Apache-2.0 OR BSL-1.0 | ||
59 | Apache-2.0 OR MIT | ||
60 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | ||
61 | Apache-2.0/MIT | ||
62 | BSD-2-Clause | ||
63 | BSD-3-Clause | ||
64 | CC0-1.0 | ||
65 | ISC | ||
66 | MIT | ||
67 | MIT / Apache-2.0 | ||
68 | MIT OR Apache-2.0 | ||
69 | MIT/Apache-2.0 | ||
70 | MIT/Apache-2.0 AND BSD-2-Clause | ||
71 | Unlicense OR MIT | ||
72 | Unlicense/MIT | ||
73 | Zlib | ||
74 | " | ||
75 | .lines() | ||
76 | .filter(|it| !it.is_empty()) | ||
77 | .collect::<Vec<_>>(); | ||
78 | |||
79 | let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); | ||
80 | let mut licenses = meta | ||
81 | .split(|c| c == ',' || c == '{' || c == '}') | ||
82 | .filter(|it| it.contains(r#""license""#)) | ||
83 | .map(|it| it.trim()) | ||
84 | .map(|it| it[r#""license":"#.len()..].trim_matches('"')) | ||
85 | .collect::<Vec<_>>(); | ||
86 | licenses.sort(); | ||
87 | licenses.dedup(); | ||
88 | assert_eq!(licenses, expected); | ||
89 | } | ||
90 | |||
52 | fn check_todo(path: &Path, text: &str) { | 91 | fn check_todo(path: &Path, text: &str) { |
53 | let need_todo = &[ | 92 | let need_todo = &[ |
54 | // This file itself obviously needs to use todo (<- like this!). | 93 | // This file itself obviously needs to use todo (<- like this!). |