1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-01-08 20:33:36 +01:00

Searching for trexio.h

This commit is contained in:
Anthony Scemama 2023-10-23 18:12:32 +02:00
parent 6ff3fdfae0
commit 3c3c0e40be
2 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@ readme = "README.md"
[build-dependencies]
bindgen = "0.65.1"
pkg-config = "0.3.27"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

View File

@ -1,4 +1,3 @@
const TREXIO_H: &str = "../../include/trexio.h";
const WRAPPER_H: &str = "wrapper.h";
const GENERATED_RS: &str = "src/generated.rs";
@ -59,8 +58,18 @@ fn check_version(bindings: &PathBuf) -> Result<(), String> {
fn make_interface() -> io::Result<()> {
let mut err = HashMap::new();
let mut be = HashMap::new();
let trexio_file = File::open(TREXIO_H)?;
let mut trexio_h = PathBuf::new().join("trexio.h");
if let Ok(library) = pkg_config::probe_library("trexio") {
for path in &library.include_paths {
if path.join("trexio.h").exists() {
trexio_h = path.join("trexio.h");
break;
}
}
}
eprintln!("trexio.h : {:?}", trexio_h);
let trexio_file = File::open(trexio_h)?;
let trexio_reader = BufReader::new(trexio_file);
for line in trexio_reader.lines() {
@ -643,7 +652,6 @@ fn make_functions(bindings: &PathBuf) -> std::io::Result<()> {
.replace(r#"\""#,"\"")
.replace(r#"\n"#,"\n")
.replace(r#"\t"#,"");
eprintln!("{}", json_file);
break;
}
}
@ -713,5 +721,4 @@ fn main() {
check_version(&bindings_path).unwrap();
make_interface().unwrap();
make_functions(&bindings_path).unwrap();
}