aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_tools/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_tools/src/lib.rs')
-rw-r--r--crates/ra_tools/src/lib.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs
index d56e0d2ef..bb7845f7d 100644
--- a/crates/ra_tools/src/lib.rs
+++ b/crates/ra_tools/src/lib.rs
@@ -15,8 +15,8 @@ pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
15 15
16pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron"; 16pub const GRAMMAR: &str = "crates/ra_syntax/src/grammar.ron";
17const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; 17const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar";
18const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/ok"; 18const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok";
19const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/err"; 19const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err";
20 20
21pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs.tera"; 21pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs.tera";
22pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs.tera"; 22pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs.tera";
@@ -79,6 +79,29 @@ pub fn project_root() -> PathBuf {
79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf() 79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf()
80} 80}
81 81
82pub struct Cmd {
83 pub unix: &'static str,
84 pub windows: &'static str,
85 pub work_dir: &'static str,
86}
87
88impl Cmd {
89 pub fn run(self) -> Result<()> {
90 if cfg!(windows) {
91 run(self.windows, self.work_dir)
92 } else {
93 run(self.unix, self.work_dir)
94 }
95 }
96 pub fn run_with_output(self) -> Result<Output> {
97 if cfg!(windows) {
98 run_with_output(self.windows, self.work_dir)
99 } else {
100 run_with_output(self.unix, self.work_dir)
101 }
102 }
103}
104
82pub fn run(cmdline: &str, dir: &str) -> Result<()> { 105pub fn run(cmdline: &str, dir: &str) -> Result<()> {
83 do_run(cmdline, dir, |c| { 106 do_run(cmdline, dir, |c| {
84 c.stdout(Stdio::inherit()); 107 c.stdout(Stdio::inherit());