Skip to content

Commit

Permalink
Show the progress of the file tree scanning
Browse files Browse the repository at this point in the history
Signed-off-by: François Bobot <francois.bobot@cea.fr>
  • Loading branch information
bobot committed Jul 27, 2019
1 parent f03f703 commit b03fe62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
2.0.0 (unreleased)
------------------

- Indicate the progress of the initial file tree loading (#2459, fixes #2374,
@bobot)

- Build `.cm[ox]` files for executables more eagerly. This speeds up builds at
the cost of building unnecessary artifacts in some cases. Some of these extra
artifacts can fail to built, so this is a breaking change. (#2268, @rgrinberg)
Expand Down
14 changes: 11 additions & 3 deletions src/file_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ let readdir path =

let load ?(warn_when_seeing_jbuild_file=true) path ~ancestor_vcs =
let open Result.O in
let nb_path_visited = ref 0 in
let rec walk path ~dirs_visited ~project:parent_project ~vcs ~(dir_status : Sub_dirs.Status.t)
: (_, _) Result.t =
incr nb_path_visited;
if !nb_path_visited mod 100 = 0 then
Console.update_status_line
(Pp.verbatim (Printf.sprintf "scanned %i directories" !nb_path_visited));
let+ { dirs; files } = readdir path in
let project =
if dir_status = Data_only then
Expand Down Expand Up @@ -347,14 +352,17 @@ let load ?(warn_when_seeing_jbuild_file=true) path ~ancestor_vcs =
in
Dir.create ~path ~contents ~status:dir_status ~project ~vcs
in
match
let walk =
walk path
~dirs_visited:(File.Map.singleton (File.of_source_path path) path)
~dir_status:Normal
~project:(Lazy.force Dune_project.anonymous)
~vcs:ancestor_vcs
with
| Ok dir -> dir
in
Console.clear_status_line ();
match walk with
| Ok dir ->
dir
| Error m ->
User_error.raise [ Pp.textf "Unable to load source %s.@.Reason:%s@."
(Path.Source.to_string_maybe_quoted path) (Unix.error_message m) ]
Expand Down

0 comments on commit b03fe62

Please sign in to comment.