From 68dc8217310dca1a4eddaa5145ba934037869a61 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Mon, 1 May 2023 11:04:18 -0500 Subject: T5194: import load_interface_definitions from vyconf --- src/generate.ml | 16 ++++++++++++++++ src/generate.mli | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/generate.ml create mode 100644 src/generate.mli diff --git a/src/generate.ml b/src/generate.ml new file mode 100644 index 0000000..c90cfc9 --- /dev/null +++ b/src/generate.ml @@ -0,0 +1,16 @@ +(* Load interface definitions from a directory into a reference tree *) +let load_interface_definitions dir = + let open Reference_tree in + let relative_paths = FileUtil.ls dir in + let absolute_paths = + try Ok (List.map Util.absolute_path relative_paths) + with Sys_error no_dir_msg -> Error no_dir_msg + in + let load_aux tree file = + load_from_xml tree file + in + try begin match absolute_paths with + | Ok paths -> Ok (List.fold_left load_aux default paths) + | Error msg -> Error msg end + with Bad_interface_definition msg -> Error msg + diff --git a/src/generate.mli b/src/generate.mli new file mode 100644 index 0000000..cbb03ff --- /dev/null +++ b/src/generate.mli @@ -0,0 +1 @@ +val load_interface_definitions : string -> (Reference_tree.t, string) result -- cgit v1.2.3