Clerk: allow to include non-yet-existing directories

Useful when you have wide `-I` options that not all targets may depend on.
This commit is contained in:
Louis Gesbert 2023-12-07 15:10:22 +01:00
parent a988ad473b
commit 5b1462d529
2 changed files with 4 additions and 3 deletions

View File

@ -53,7 +53,7 @@ module Cli = struct
let include_dirs =
Arg.(
value
& opt_all dir []
& opt_all string []
& info ["I"; "include"] ~docv:"DIR"
~doc:
"Make modules from the given directory available from everywhere.")

View File

@ -213,14 +213,15 @@ module Tree = struct
let rec build path =
lazy
(Array.fold_left
(let entries = try Sys.readdir path with Sys_error _ -> [||] in
Array.fold_left
(fun m f ->
let path = path / f in
match Sys.is_directory path with
| true -> Map.add f (path, D (build path)) m
| false -> Map.add f (path, F) m
| exception Sys_error _ -> m)
Map.empty (Sys.readdir path))
Map.empty entries)
let subtree t path =
let rec aux t = function