diff --git a/ocaml/trexio/read_json.py b/ocaml/trexio/read_json.py index d41bc00..c65e553 100755 --- a/ocaml/trexio/read_json.py +++ b/ocaml/trexio/read_json.py @@ -7,6 +7,21 @@ stubs_file= "trexio_stubs.c" ml_file = "trexio.ml" mli_file = ml_file+"i" +def check_version(): + with open('trexio.opam','r') as f: + for line in f: + if line.startswith("version"): + ocaml_version = line.split(':')[1].strip()[1:-1] + break + with open('../../configure.ac','r') as f: + for line in f: + if line.startswith("AC_INIT"): + trexio_version = line.split(',')[1].strip()[1:-1] + break + if ocaml_version != trexio_version: + print(f"Inconsistent versions:\nTREXIO:{trexio_version}\nOCaml: {ocaml_version}\n") + raise + def write_stubs(data): with open("src/"+stubs_file,'r') as f: @@ -643,6 +658,7 @@ def write_ml(data): def main(): + check_version() with open(json_file,'r') as f: data = json.load(f) for group in data: diff --git a/ocaml/trexio/trexio.opam b/ocaml/trexio/trexio.opam index d3a6a46..f38dc69 100644 --- a/ocaml/trexio/trexio.opam +++ b/ocaml/trexio/trexio.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.3.2" +version: "2.4.0" synopsis: "Binding for the TREXIO Input/Output library" description: "TREXIO is a file format and library for storing wave functions and integrals for quantum chemistry." diff --git a/rust/trexio/build.py b/rust/trexio/build.py index 8e6aa89..2b17df2 100755 --- a/rust/trexio/build.py +++ b/rust/trexio/build.py @@ -1,9 +1,29 @@ #!/usr/bin/env python3 -def main(): +json_file = "../../trex.json" +trexio_h = "../../include/trexio.h" + +def check_version(): + with open('Cargo.toml','r') as f: + for line in f: + if line.startswith("version"): + rust_version = line.split('=')[1].strip()[1:-1] + break + with open('../../configure.ac','r') as f: + for line in f: + if line.startswith("AC_INIT"): + trexio_version = line.split(',')[1].strip()[1:-1] + break + if rust_version != trexio_version: + print(f"Inconsistent versions:\nTREXIO:{trexio_version}\nRust: {rust_version}\n") + raise + + + +def make_interface(): err = {} be = {} - with open("../../include/trexio.h", 'r') as f: + with open(trexio_h, 'r') as f: for line in f: buf = line.lstrip() @@ -11,7 +31,7 @@ def main(): if buf.startswith("#define TREXIO_") and "(trexio_exit_code)" in buf : buf2 = buf.replace(")","").replace("(","").split() err[buf2[1]] = int(buf2[3].strip()) - + # Get backends if buf.startswith("#define TREXIO_") and "(back_end_t)" in buf : buf2 = buf.replace(")","").replace("(","").split() @@ -33,7 +53,12 @@ def main(): f.write(f"#undef TREXIO_AUTO;\n") f.write(f"const back_end_t TREXIO_AUTO = TREXIO_INVALID_BACK_END;\n") - + + +def make_functions(): + pass if __name__ == '__main__': - main() + check_version() + make_interface() + make_functions()