-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: James Goppert <james.goppert@gmail.com>
- Loading branch information
Showing
15 changed files
with
567 additions
and
418 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
// create git hash | ||
// Attempt to retrieve the current Git version | ||
let output = Command::new("git") | ||
.args(["describe", "--dirty", "--tags"]) | ||
.output() | ||
.unwrap(); | ||
let git_hash = String::from_utf8(output.stdout).unwrap(); | ||
.expect("Failed to execute git command"); | ||
|
||
if output.status.success() { | ||
// Convert the hash to a String and trim it | ||
let git_ver = String::from_utf8_lossy(&output.stdout).trim().to_string(); | ||
|
||
// Pass the Git hash to your Rust code via an environment variable | ||
println!("cargo:rustc-env=GIT_VER={}", git_ver); | ||
|
||
// Optionally, display a warning during the build with the hash | ||
println!("cargo:warning=Using Git version: {}", git_ver); | ||
} else { | ||
eprintln!( | ||
"Failed to retrieve Git version: {}", | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
} | ||
|
||
// Rerun this build script if `.git/HEAD` or its references change | ||
println!("cargo:rerun-if-changed=.git/HEAD"); | ||
println!("cargo:rustc-env=GIT_HASH={}", git_hash); | ||
println!("cargo:rerun-if-changed=.git/refs/"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use ordermap::{OrderMap, OrderSet}; | ||
use rumoca_parser::s1_parser::ast::{ | ||
ClassType, Equation, Expression, Modification, Statement, Subscript, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
derive_alias! { | ||
#[derive(CommonTraits!)] = #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]; | ||
} | ||
|
||
//============================================================================= | ||
/// A file level definition holding multiple flat models | ||
#[derive(CommonTraits!, Default)] | ||
pub struct Def { | ||
pub classes: OrderMap<String, Class>, | ||
pub model_md5: String, | ||
pub rumoca_parser_version: String, | ||
pub rumoca_parser_git: String, | ||
pub rumoca_version: String, | ||
pub rumoca_git: String, | ||
pub template_md5: String, | ||
} | ||
|
||
//============================================================================= | ||
/// A flat definition of a DAE | ||
#[derive(CommonTraits!, Default)] | ||
pub struct Class { | ||
pub name: String, | ||
pub class_type: ClassType, | ||
pub description: Vec<String>, | ||
/// dictinoary of components | ||
pub components: OrderMap<String, Component>, | ||
/// constants | ||
pub c: OrderSet<String>, | ||
/// continuous states | ||
pub x: OrderSet<String>, | ||
/// discrete states | ||
pub z: OrderSet<String>, | ||
/// continuous internal variables | ||
pub w: OrderSet<String>, | ||
/// input | ||
pub u: OrderSet<String>, | ||
/// continuous output variables | ||
pub y: OrderSet<String>, | ||
/// parameters | ||
pub p: OrderSet<String>, | ||
/// ordinary diff equation | ||
pub ode: OrderMap<String, Expression>, | ||
/// algebraic eq | ||
pub algebraic: Vec<Equation>, | ||
/// algorithm stms | ||
pub algorithm: Vec<Statement>, | ||
} | ||
|
||
#[derive(CommonTraits!, Default)] | ||
pub struct Component { | ||
pub name: String, | ||
pub start: Option<Modification>, | ||
// pub start_value: ArrayBase<OwnedRepr<f64>, IxDyn>, | ||
pub array_subscripts: Vec<Subscript>, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_ast() { | ||
// class ball | ||
#[allow(unused_variables)] | ||
let class_ball = Class { | ||
name: String::from("Ball"), | ||
..Default::default() | ||
}; | ||
} | ||
} |
Oops, something went wrong.