Skip to content

Commit

Permalink
Normalize case of context root under Win32
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb committed Jan 20, 2021
1 parent 8152606 commit 9ea7357
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Unreleased
- Fixed wrong workspace discovery from `dune ocaml-merlin` (#4127, fixes #4125,
@voodoos)

- Fixed a bug that could result in needless recompilation under Windows due to
case differences in the result of `Sys.getcwd` (observed under `emacs`).
(#3966, @nojb).

2.8.1 (14/01/2021)
------------------

Expand Down
11 changes: 10 additions & 1 deletion bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,18 @@ let prefix_target common s = common.target_prefix ^ s

let instrument_with t = t.instrument_with

(* To avoid needless recompilations under Windows, where the case of
[Sys.getcwd] can vary between different invocations of [dune], normalize to
lowercase. *)
let normalize_path p =
if Sys.win32 then
Path.External.lowercase_ascii p
else
p

let set_dirs c =
if c.root.dir <> Filename.current_dir_name then Sys.chdir c.root.dir;
Path.set_root (Path.External.cwd ());
Path.set_root (normalize_path (Path.External.cwd ()));
Path.Build.set_build_dir (Path.Build.Kind.of_string c.build_dir)

let set_common_other ?log_file c ~targets =
Expand Down
4 changes: 4 additions & 0 deletions src/stdune/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module External : sig
val cwd : unit -> t

val as_local : t -> string

val lowercase_ascii : t -> t
end = struct
module T =
Interned.No_interning
Expand Down Expand Up @@ -164,6 +166,8 @@ end = struct
else
String.is_prefix ~prefix:(to_string a ^ "/") (to_string b)

let lowercase_ascii t = make (String.lowercase_ascii (to_string t))

module Set = struct
include T.Set

Expand Down
2 changes: 2 additions & 0 deletions src/stdune/path.mli
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ module External : sig
val relative : t -> string -> t

val mkdir_p : ?perms:int -> t -> unit

val lowercase_ascii : t -> t
end

module Build : sig
Expand Down

0 comments on commit 9ea7357

Please sign in to comment.