Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize case of context root under Win32 #3966

Merged
merged 2 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Unreleased
----------

- 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.2 (21/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