1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-01-09 20:48:53 +01:00

Updated check_version

This commit is contained in:
Anthony Scemama 2023-10-23 15:57:23 +02:00
parent ef2ad322de
commit 49462add49

View File

@ -15,7 +15,7 @@ use std::path::Path;
/// Checks that the version specified in the Cargo.toml file is consistent with the version of the TREXIO C library. /// Checks that the version specified in the Cargo.toml file is consistent with the version of the TREXIO C library.
fn check_version() -> Result<(), String> { fn check_version(bindings: PathBuf) -> Result<(), String> {
// Read version from Cargo.toml // Read version from Cargo.toml
let mut rust_version = String::new(); let mut rust_version = String::new();
{ {
@ -32,21 +32,18 @@ fn check_version() -> Result<(), String> {
} }
} }
// Read version from ../../configure.ac // Check version from TREXIO
let mut trexio_version = String::new(); let mut trexio_version = String::new();
{ let file = File::open(bindings).map_err(|e| e.to_string())?;
let file = File::open("../../configure.ac").map_err(|e| e.to_string())?;
let reader = io::BufReader::new(file); let reader = io::BufReader::new(file);
for line in reader.lines() { for line in reader.lines() {
let line = line.map_err(|e| e.to_string())?; let line = line.map_err(|e| e.to_string())?;
if line.starts_with("AC_INIT") { if line.contains("TREXIO_PACKAGE_VERSION") {
trexio_version = line.split(',').nth(1).unwrap().trim().to_string(); trexio_version = line.split('"').nth(1).unwrap().trim().to_string();
trexio_version = trexio_version[1..trexio_version.len() - 1].to_string(); trexio_version = trexio_version[0..trexio_version.len() - 2].to_string();
break; break;
} }
} }
}
// Compare versions // Compare versions
if rust_version != trexio_version { if rust_version != trexio_version {
@ -668,7 +665,6 @@ impl File {
fn main() { fn main() {
check_version().unwrap();
make_interface().unwrap(); make_interface().unwrap();
make_functions().unwrap(); make_functions().unwrap();
@ -702,4 +698,5 @@ fn main() {
bindings bindings
.write_to_file(out_path.join("bindings.rs")) .write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!"); .expect("Couldn't write bindings!");
check_version(out_path.join("bindings.rs")).unwrap();
} }