Skip to content

Commit

Permalink
fix: remove .merlin handling from the engine
Browse files Browse the repository at this point in the history
We haven't relied on .merlin files in the rules for over 2 years. It's
OK to get rid of them now.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: c07ac682-fad3-49b0-8b93-92dd0ef9e529 -->
  • Loading branch information
rgrinberg committed May 26, 2023
1 parent 784fa0e commit ead1e47
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 108 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Unreleased
----------

- Remove some compatibility code for old version of dune that generated
`.merlin` files. Now dune will never remove `.merlin` files automatically
(#7562)

- Add additional metadata to the traces provided by `--trace-file` whenever
`--trace-extended` is passed (#7778, @rleshchinskiy)

Expand Down
4 changes: 0 additions & 4 deletions src/dune_engine/load_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,6 @@ end = struct
source_files_to_ignore
|> Path.Source.Set.of_list
in
let source_files_to_ignore =
Target_promotion.delete_stale_dot_merlin_file ~dir
~source_files_to_ignore
in
Path.Source.Set.diff files source_files_to_ignore
in
let subdirs = Filename.Set.diff subdirs source_dirnames_to_ignore in
Expand Down
39 changes: 0 additions & 39 deletions src/dune_engine/target_promotion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,55 +41,16 @@ module To_delete = struct
if Path.Source.Set.mem db p then None
else Some (Path.Source.Set.add db p))

let remove p =
modify_db (fun db ->
if Path.Source.Set.mem db p then Some (Path.Source.Set.remove db p)
else None)

let dump () =
if !needs_dumping && Path.build_dir_exists () then (
needs_dumping := false;
get_db () |> P.dump fn)

let mem p = Path.Source.Set.mem !(Lazy.force db) p

let () = Hooks.End_of_build.always dump
end

let files_in_source_tree_to_delete () = To_delete.get_db ()

(* TODO: Delete this step after users of Dune <2.8 are sufficiently rare. This
step is sketchy because it's using the [To_delete] database and that can get
out of date (see a comment on [To_delete]), so we should not widen the scope
of it too much. *)
let delete_stale_dot_merlin_file ~dir ~source_files_to_ignore =
(* If a [.merlin] file is present in the [To_delete] set but not in the
[Source_files_to_ignore] that means the rule that ordered its promotion is
no more valid. This would happen when upgrading to Dune 2.8 from earlier
version without and building uncleaned projects. We delete these leftover
files here. *)
let merlin_file = ".merlin" in
let source_dir = Path.Build.drop_build_context_exn dir in
let merlin_in_src = Path.Source.(relative source_dir merlin_file) in
let source_files_to_ignore =
if
To_delete.mem merlin_in_src
&& not (Path.Source.Set.mem source_files_to_ignore merlin_in_src)
then (
Log.info
[ Pp.textf "Deleting left-over Merlin file %s.\n"
(Path.Source.to_string merlin_in_src)
];
(* We remove the file from the promoted database *)
To_delete.remove merlin_in_src;
Path.Source.unlink_no_err merlin_in_src;
(* We need to keep ignoring the .merlin file for that build or Dune will
attempt to copy it and fail because it has been deleted *)
Path.Source.Set.add source_files_to_ignore merlin_in_src)
else source_files_to_ignore
in
source_files_to_ignore

let promote_target_if_not_up_to_date ~src ~src_digest ~dst ~promote_source
~promote_until_clean =
let open Fiber.O in
Expand Down
5 changes: 0 additions & 5 deletions src/dune_engine/target_promotion.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ val promote :

(** The set of files created in the source tree that need to be deleted. *)
val files_in_source_tree_to_delete : unit -> Path.Source.Set.t

val delete_stale_dot_merlin_file :
dir:Path.Build.t
-> source_files_to_ignore:Path.Source.Set.t
-> Path.Source.Set.t

This file was deleted.

Empty file.
59 changes: 0 additions & 59 deletions test/blackbox-tests/test-cases/promote/merlin-files.t/run.t

This file was deleted.

0 comments on commit ead1e47

Please sign in to comment.