diff --git a/CHANGES.md b/CHANGES.md index 4e9445007c4..72e9a4bc9ad 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,9 @@ - Fix `dune --version`. The bootstrap didn't compute the version correctly. (#2929, fixes #2911, @diml) +- Do not open the log file in `dune clean`. (#2965, fixes #2964 and + #2921, @diml) + 2.0.0 (20/11/2019) ------------------ diff --git a/bin/common.ml b/bin/common.ml index db26d7de3fd..c996a0bf126 100644 --- a/bin/common.ml +++ b/bin/common.ml @@ -68,9 +68,9 @@ let set_dirs c = Path.set_root (Path.External.cwd ()); Path.Build.set_build_dir (Path.Build.Kind.of_string c.build_dir) -let set_common_other c ~targets = +let set_common_other ?log_file c ~targets = Console.init c.config.display; - Log.init (); + Log.init () ?file:log_file; Clflags.debug_dep_path := c.debug_dep_path; Clflags.debug_findlib := c.debug_findlib; Clflags.debug_backtraces := c.debug_backtraces; @@ -92,9 +92,9 @@ let set_common_other c ~targets = Clflags.ignore_promoted_rules := c.ignore_promoted_rules; Option.iter ~f:Dune.Stats.enable c.stats_trace_file -let set_common c ~targets = +let set_common ?log_file c ~targets = set_dirs c; - set_common_other c ~targets + set_common_other ?log_file c ~targets let footer = `Blocks diff --git a/bin/common.mli b/bin/common.mli index d0dd8ea02ad..1e83b4ebd12 100644 --- a/bin/common.mli +++ b/bin/common.mli @@ -1,3 +1,5 @@ +open Stdune + type t val workspace_file : t -> Arg.Path.t option @@ -20,16 +22,17 @@ val default_target : t -> Arg.Dep.t val prefix_target : t -> string -> string -(** [set_common common ~targets] is [set_dirs common] followed by +(** [set_common ?log common ~targets] is [set_dirs common] followed by [set_common_other common ~targets]. In general, [set_common] executes sequence of side-effecting actions to initialize Dune's working environment - based on the options determined in a [Common.t] record *) -val set_common : t -> targets:Arg.Dep.t list -> unit + based on the options determined in a [Common.t] record.contents. *) +val set_common : ?log_file:Log.File.t -> t -> targets:Arg.Dep.t list -> unit (** [set_common_other common ~targets] sets all stateful values dictated by [common], except those accounted for by [set_dirs]. [targets] are used to obtain external library dependency hints, if needed. *) -val set_common_other : t -> targets:Arg.Dep.t list -> unit +val set_common_other : + ?log_file:Log.File.t -> t -> targets:Arg.Dep.t list -> unit (** [set_dirs common] sets the workspace root and build directories, and makes the root the current working directory *) diff --git a/bin/main.ml b/bin/main.ml index b3021fc138c..8d50ece8f79 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -89,7 +89,12 @@ let clean = in let term = let+ common = Common.term in - Common.set_common common ~targets:[]; + (* Pass [No_log_file] to prevent the log file from being created. Indeed, we + are going to delete the whole build directory right after and that + includes deleting the log file. Not only creating the log file would be + useless but with some FS this also causes [dune clean] to fail (cf + https://github.com/ocaml/dune/issues/2964). *) + Common.set_common common ~targets:[] ~log_file:No_log_file; Build_system.files_in_source_tree_to_delete () |> Path.Set.iter ~f:Path.unlink_no_err; Path.rm_rf Path.build_dir