Skip to content

Commit 9036d0c

Browse files
committed
Add separate parser git and version, bump to 0.6.0
Signed-off-by: James Goppert <james.goppert@gmail.com>
1 parent e0f9124 commit 9036d0c

8 files changed

+19
-16
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rumoca_parser"
33
authors = ["James Goppert", "Benjamin Perseghetti"]
44
description = "A Modelica translator with focus on Casadi, Sympy, JAX, and Collimator generation"
5-
version = "0.5.0"
5+
version = "0.6.0"
66
edition = "2021"
77
license = "Apache-2.0"
88

build.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ fn main() {
88

99
// Attempt to retrieve the current Git version
1010
let output = Command::new("git")
11-
.args(["describe", "--dirty", "--tags"])
11+
.args(["describe", "--dirty", "--tags", "--long"])
1212
.output()
1313
.expect("Failed to execute git command");
1414

1515
if output.status.success() {
1616
// Convert the hash to a String and trim it
17-
let git_hash = String::from_utf8_lossy(&output.stdout).trim().to_string();
17+
let git_ver = String::from_utf8_lossy(&output.stdout).trim().to_string();
1818

1919
// Pass the Git hash to your Rust code via an environment variable
20-
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
20+
println!("cargo:rustc-env=GIT_VER={}", git_ver);
2121

2222
// Optionally, display a warning during the build with the hash
23-
println!("cargo:warning=Using Git version: {}", git_hash);
23+
println!("cargo:warning=Using Git version: {}", git_ver);
2424
} else {
2525
eprintln!(
2626
"Failed to retrieve Git version: {}",

src/s1_parser/ast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub struct StoredDefinition {
1616
pub classes: Vec<ClassDefinition>,
1717
pub within: Option<Name>,
1818
pub model_md5: String,
19-
pub rumoca_git_hash: String,
19+
pub rumoca_parser_version: String,
20+
pub rumoca_parser_git: String,
2021
}
2122

2223
#[derive(CommonTraits!, Default)]

src/s1_parser/modelica.lalrpop

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ pub StoredDefinition: ast::StoredDefinition = {
151151
span: ast::Span { left, right},
152152
classes,
153153
within,
154-
rumoca_git_hash: "".to_string(),
154+
rumoca_parser_version: "".to_string(),
155+
rumoca_parser_git: "".to_string(),
155156
model_md5: "".to_string(),
156157
}
157158
}

src/s1_parser/parser_helper.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub fn parse_file(filename: &str) -> ast::StoredDefinition {
6868
let mut def = result.unwrap();
6969
let digest = md5::compute(file_txt);
7070
def.model_md5 = format!("{:x}", digest);
71-
//def.rumoca_git_hash = env!("GIT_HASH").to_string();
71+
def.rumoca_parser_version = env!("CARGO_PKG_VERSION").to_string();
72+
def.rumoca_parser_git = option_env!("GIT_VER").unwrap_or("").to_string();
7273
def
7374
}

src/s1_parser/print_visitor.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ impl Visitor for PrintVisitor {
112112
fn exit_component_reference(&mut self, comp: &ast::ComponentReference) {
113113
let mut s: String = "".to_string();
114114
for (index, part) in comp.parts.iter().enumerate() {
115-
if index != 0 || comp.local {
116-
s += ".";
117-
}
118-
s += &part.name;
119-
}
120-
self.print(&s);
115+
if index != 0 || comp.local {
116+
s += ".";
117+
}
118+
s += &part.name;
119+
}
120+
self.print(&s);
121121
}
122122
}

src/s1_parser/walker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Walker {
3939
}
4040
}
4141
}
42-
ast::ClassSpecifier::Extends { .. } => {},
42+
ast::ClassSpecifier::Extends { .. } => {}
4343
}
4444
visitor.exit_class_definition(class);
4545
visitor.exit_any();

0 commit comments

Comments
 (0)