diff options
author | Muhammad Mominul Huque <[email protected]> | 2018-10-15 18:52:11 +0100 |
---|---|---|
committer | Muhammad Mominul Huque <[email protected]> | 2018-10-15 18:52:11 +0100 |
commit | ce73df065f89bb5aa17517de16c10f9e4d3abaeb (patch) | |
tree | c8afdd06e562f5cd0040b41f577a881887b5a26a /crates/tools/src | |
parent | 33b378797c33bf29af4104e0b11c31252451df0c (diff) |
Use CARGO_MANIFEST_DIR for locating the grammar.ron file
Diffstat (limited to 'crates/tools/src')
-rw-r--r-- | crates/tools/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/tools/src/main.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 7b5a60847..ba7d10caa 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs | |||
@@ -71,9 +71,9 @@ pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> { | |||
71 | Ok(()) | 71 | Ok(()) |
72 | } | 72 | } |
73 | 73 | ||
74 | pub fn render_template(template: &str, grammarfile: &str) -> Result<String> { | 74 | pub fn render_template(template: &str) -> Result<String> { |
75 | let grammar: ron::value::Value = { | 75 | let grammar: ron::value::Value = { |
76 | let text = fs::read_to_string(grammarfile)?; | 76 | let text = fs::read_to_string(format!("{}{}", Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).parent().unwrap().to_str().unwrap(), "/ra_syntax/src/grammar.ron"))?; |
77 | ron::de::from_str(&text)? | 77 | ron::de::from_str(&text)? |
78 | }; | 78 | }; |
79 | let template = fs::read_to_string(template)?; | 79 | let template = fs::read_to_string(template)?; |
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 179c1163f..aa6d964e6 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -45,8 +45,8 @@ fn main() -> Result<()> { | |||
45 | fn run_gen_command(name: &str, verify: bool) -> Result<()> { | 45 | fn run_gen_command(name: &str, verify: bool) -> Result<()> { |
46 | match name { | 46 | match name { |
47 | "gen-kinds" => { | 47 | "gen-kinds" => { |
48 | update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR)?, verify)?; | 48 | update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE)?, verify)?; |
49 | update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR)?, verify)?; | 49 | update(Path::new(AST), &render_template(AST_TEMPLATE)?, verify)?; |
50 | }, | 50 | }, |
51 | "gen-tests" => { | 51 | "gen-tests" => { |
52 | gen_tests(verify)? | 52 | gen_tests(verify)? |