aboutsummaryrefslogtreecommitdiff
path: root/crates/tools/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tools/src/main.rs')
-rw-r--r--crates/tools/src/main.rs45
1 files changed, 33 insertions, 12 deletions
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs
index 6eacfc190..b662d78df 100644
--- a/crates/tools/src/main.rs
+++ b/crates/tools/src/main.rs
@@ -11,7 +11,10 @@ use std::{
11 path::{Path, PathBuf}, 11 path::{Path, PathBuf},
12 process::Command, 12 process::Command,
13}; 13};
14use tools::{AST, AST_TEMPLATE, Result, SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, Test, collect_tests, render_template, update, project_root}; 14use tools::{
15 collect_tests, project_root, render_template, update, Result, Test, AST, AST_TEMPLATE,
16 SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE,
17};
15 18
16const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; 19const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar";
17const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; 20const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline";
@@ -40,18 +43,23 @@ fn main() -> Result<()> {
40fn run_gen_command(name: &str, verify: bool) -> Result<()> { 43fn run_gen_command(name: &str, verify: bool) -> Result<()> {
41 match name { 44 match name {
42 "gen-kinds" => { 45 "gen-kinds" => {
43 update(&project_root().join(SYNTAX_KINDS), &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE))?, verify)?; 46 update(
44 update(&project_root().join(AST), &render_template(&project_root().join(AST_TEMPLATE))?, verify)?; 47 &project_root().join(SYNTAX_KINDS),
45 }, 48 &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE))?,
46 "gen-tests" => { 49 verify,
47 gen_tests(verify)? 50 )?;
48 }, 51 update(
52 &project_root().join(AST),
53 &render_template(&project_root().join(AST_TEMPLATE))?,
54 verify,
55 )?;
56 }
57 "gen-tests" => gen_tests(verify)?,
49 _ => unreachable!(), 58 _ => unreachable!(),
50 } 59 }
51 Ok(()) 60 Ok(())
52} 61}
53 62
54
55fn gen_tests(verify: bool) -> Result<()> { 63fn gen_tests(verify: bool) -> Result<()> {
56 let tests = tests_from_dir(Path::new(GRAMMAR_DIR))?; 64 let tests = tests_from_dir(Path::new(GRAMMAR_DIR))?;
57 65
@@ -133,11 +141,20 @@ fn install_code_extension() -> Result<()> {
133 } else { 141 } else {
134 run(r"npm install", "./editors/code")?; 142 run(r"npm install", "./editors/code")?;
135 } 143 }
136 run(r"node ./node_modules/vsce/out/vsce package", "./editors/code")?; 144 run(
145 r"node ./node_modules/vsce/out/vsce package",
146 "./editors/code",
147 )?;
137 if cfg!(windows) { 148 if cfg!(windows) {
138 run(r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix", "./editors/code")?; 149 run(
150 r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix",
151 "./editors/code",
152 )?;
139 } else { 153 } else {
140 run(r"code --install-extension ./ra-lsp-0.0.1.vsix", "./editors/code")?; 154 run(
155 r"code --install-extension ./ra-lsp-0.0.1.vsix",
156 "./editors/code",
157 )?;
141 } 158 }
142 Ok(()) 159 Ok(())
143} 160}
@@ -145,7 +162,11 @@ fn install_code_extension() -> Result<()> {
145fn run(cmdline: &'static str, dir: &str) -> Result<()> { 162fn run(cmdline: &'static str, dir: &str) -> Result<()> {
146 eprintln!("\nwill run: {}", cmdline); 163 eprintln!("\nwill run: {}", cmdline);
147 let manifest_dir = env!("CARGO_MANIFEST_DIR"); 164 let manifest_dir = env!("CARGO_MANIFEST_DIR");
148 let project_dir = Path::new(manifest_dir).ancestors().nth(2).unwrap().join(dir); 165 let project_dir = Path::new(manifest_dir)
166 .ancestors()
167 .nth(2)
168 .unwrap()
169 .join(dir);
149 let mut args = cmdline.split_whitespace(); 170 let mut args = cmdline.split_whitespace();
150 let exec = args.next().unwrap(); 171 let exec = args.next().unwrap();
151 let status = Command::new(exec) 172 let status = Command::new(exec)