aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/main.rs')
-rw-r--r--xtask/src/main.rs46
1 files changed, 30 insertions, 16 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index dec48629c..5a99f4a76 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -10,6 +10,7 @@
10 10
11use std::env; 11use std::env;
12 12
13use anyhow::bail;
13use codegen::CodegenCmd; 14use codegen::CodegenCmd;
14use pico_args::Arguments; 15use pico_args::Arguments;
15use xshell::{cmd, cp, pushd}; 16use xshell::{cmd, cp, pushd};
@@ -49,7 +50,8 @@ FLAGS:
49 --client[=CLIENT] Install only VS Code plugin. 50 --client[=CLIENT] Install only VS Code plugin.
50 CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss' 51 CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'
51 --server Install only the language server 52 --server Install only the language server
52 --mimalloc Use mimalloc for server 53 --mimalloc Use mimalloc allocator for server
54 --jemalloc Use jemalloc allocator for server
53 -h, --help Prints help information 55 -h, --help Prints help information
54 " 56 "
55 ); 57 );
@@ -65,12 +67,17 @@ FLAGS:
65 return Ok(()); 67 return Ok(());
66 } 68 }
67 69
68 let malloc = 70 let malloc = if args.contains("--mimalloc") {
69 if args.contains("--mimalloc") { Malloc::Mimalloc } else { Malloc::System }; 71 Malloc::Mimalloc
72 } else if args.contains("--jemalloc") {
73 Malloc::Jemalloc
74 } else {
75 Malloc::System
76 };
70 77
71 let client_opt = args.opt_value_from_str("--client")?; 78 let client_opt = args.opt_value_from_str("--client")?;
72 79
73 args.finish()?; 80 finish_args(args)?;
74 81
75 InstallCmd { 82 InstallCmd {
76 client: if server { None } else { Some(client_opt.unwrap_or_default()) }, 83 client: if server { None } else { Some(client_opt.unwrap_or_default()) },
@@ -80,53 +87,53 @@ FLAGS:
80 } 87 }
81 "codegen" => { 88 "codegen" => {
82 let features = args.contains("--features"); 89 let features = args.contains("--features");
83 args.finish()?; 90 finish_args(args)?;
84 CodegenCmd { features }.run() 91 CodegenCmd { features }.run()
85 } 92 }
86 "format" => { 93 "format" => {
87 args.finish()?; 94 finish_args(args)?;
88 run_rustfmt(Mode::Overwrite) 95 run_rustfmt(Mode::Overwrite)
89 } 96 }
90 "install-pre-commit-hook" => { 97 "install-pre-commit-hook" => {
91 args.finish()?; 98 finish_args(args)?;
92 pre_commit::install_hook() 99 pre_commit::install_hook()
93 } 100 }
94 "lint" => { 101 "lint" => {
95 args.finish()?; 102 finish_args(args)?;
96 run_clippy() 103 run_clippy()
97 } 104 }
98 "fuzz-tests" => { 105 "fuzz-tests" => {
99 args.finish()?; 106 finish_args(args)?;
100 run_fuzzer() 107 run_fuzzer()
101 } 108 }
102 "pre-cache" => { 109 "pre-cache" => {
103 args.finish()?; 110 finish_args(args)?;
104 PreCacheCmd.run() 111 PreCacheCmd.run()
105 } 112 }
106 "release" => { 113 "release" => {
107 let dry_run = args.contains("--dry-run"); 114 let dry_run = args.contains("--dry-run");
108 args.finish()?; 115 finish_args(args)?;
109 ReleaseCmd { dry_run }.run() 116 ReleaseCmd { dry_run }.run()
110 } 117 }
111 "promote" => { 118 "promote" => {
112 let dry_run = args.contains("--dry-run"); 119 let dry_run = args.contains("--dry-run");
113 args.finish()?; 120 finish_args(args)?;
114 PromoteCmd { dry_run }.run() 121 PromoteCmd { dry_run }.run()
115 } 122 }
116 "dist" => { 123 "dist" => {
117 let nightly = args.contains("--nightly"); 124 let nightly = args.contains("--nightly");
118 let client_version: Option<String> = args.opt_value_from_str("--client")?; 125 let client_version: Option<String> = args.opt_value_from_str("--client")?;
119 args.finish()?; 126 finish_args(args)?;
120 DistCmd { nightly, client_version }.run() 127 DistCmd { nightly, client_version }.run()
121 } 128 }
122 "metrics" => { 129 "metrics" => {
123 let dry_run = args.contains("--dry-run"); 130 let dry_run = args.contains("--dry-run");
124 args.finish()?; 131 finish_args(args)?;
125 MetricsCmd { dry_run }.run() 132 MetricsCmd { dry_run }.run()
126 } 133 }
127 "bb" => { 134 "bb" => {
128 let suffix: String = args.free_from_str()?.unwrap(); 135 let suffix: String = args.free_from_str()?;
129 args.finish()?; 136 finish_args(args)?;
130 cmd!("cargo build --release").run()?; 137 cmd!("cargo build --release").run()?;
131 cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?; 138 cp("./target/release/rust-analyzer", format!("./target/rust-analyzer-{}", suffix))?;
132 Ok(()) 139 Ok(())
@@ -155,3 +162,10 @@ SUBCOMMANDS:
155 } 162 }
156 } 163 }
157} 164}
165
166fn finish_args(args: Arguments) -> Result<()> {
167 if !args.finish().is_empty() {
168 bail!("Unused arguments.");
169 }
170 Ok(())
171}