diff options
author | Jeremy A. Kolb <[email protected]> | 2018-10-15 22:44:23 +0100 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2018-10-16 14:41:10 +0100 |
commit | 61f3a438d3a729a6be941bca1ff4c6a97a33f221 (patch) | |
tree | 6551967cc8c6e921b66071453ad7888a9121d326 /crates/tools/src/main.rs | |
parent | 39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff) |
Cargo Format
Run `cargo fmt` and ignore generated files
Diffstat (limited to 'crates/tools/src/main.rs')
-rw-r--r-- | crates/tools/src/main.rs | 45 |
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 | }; |
14 | use tools::{AST, AST_TEMPLATE, Result, SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, Test, collect_tests, render_template, update, project_root}; | 14 | use tools::{ |
15 | collect_tests, project_root, render_template, update, Result, Test, AST, AST_TEMPLATE, | ||
16 | SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, | ||
17 | }; | ||
15 | 18 | ||
16 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; | 19 | const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; |
17 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; | 20 | const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; |
@@ -40,18 +43,23 @@ fn main() -> Result<()> { | |||
40 | fn run_gen_command(name: &str, verify: bool) -> Result<()> { | 43 | fn 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 | |||
55 | fn gen_tests(verify: bool) -> Result<()> { | 63 | fn 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<()> { | |||
145 | fn run(cmdline: &'static str, dir: &str) -> Result<()> { | 162 | fn 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) |