From b03fe625b5bbdd5fd9971b9890621b01cb7a18fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= Date: Fri, 26 Jul 2019 22:30:35 +0200 Subject: [PATCH] Show the progress of the file tree scanning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: François Bobot --- CHANGES.md | 3 +++ src/file_tree.ml | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 06d5ecf28d0..c95714227c5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/src/file_tree.ml b/src/file_tree.ml index 994bcbaf198..12979c82836 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -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 @@ -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) ]