From 6710856c1098f71168c47451af53bac9a33b49dd Mon Sep 17 00:00:00 2001 From: Ivan Kozik Date: Tue, 14 Jul 2020 00:12:49 +0000 Subject: Add opt-in mimalloc feature --- xtask/src/install.rs | 16 +++++++++++++--- xtask/src/main.rs | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'xtask/src') 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 { } pub struct ServerOpt { - pub jemalloc: bool, + pub malloc: Malloc, +} + +pub enum Malloc { + System, + Jemalloc, + Mimalloc, } impl InstallCmd { @@ -130,8 +136,12 @@ fn install_server(opts: ServerOpt) -> Result<()> { ) } - let jemalloc = if opts.jemalloc { "--features jemalloc" } else { "" }; - let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", jemalloc); + let malloc_feature = match opts.malloc { + Malloc::System => "", + Malloc::Jemalloc => "--features jemalloc", + Malloc::Mimalloc => "--features mimalloc", + }; + let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature); if res.is_err() && old_rust { eprintln!( 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; use xtask::{ codegen::{self, Mode}, dist::run_dist, - install::{ClientOpt, InstallCmd, ServerOpt}, + install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, not_bash::pushd, pre_commit, project_root, release::{PromoteCmd, ReleaseCmd}, @@ -46,6 +46,7 @@ FLAGS: --client-code Install only VS Code plugin --server Install only the language server --jemalloc Use jemalloc for server + --mimalloc Use mimalloc for server -h, --help Prints help information " ); @@ -61,13 +62,21 @@ FLAGS: return Ok(()); } - let jemalloc = args.contains("--jemalloc"); + let malloc = match (args.contains("--jemalloc"), args.contains("--mimalloc")) { + (false, false) => Malloc::System, + (true, false) => Malloc::Jemalloc, + (false, true) => Malloc::Mimalloc, + (true, true) => { + eprintln!("error: Cannot use both `--jemalloc` and `--mimalloc`"); + return Ok(()); + } + }; args.finish()?; InstallCmd { client: if server { None } else { Some(ClientOpt::VsCode) }, - server: if client_code { None } else { Some(ServerOpt { jemalloc }) }, + server: if client_code { None } else { Some(ServerOpt { malloc }) }, } .run() } -- cgit v1.2.3