From 0b7d664f49822808c9d194941c9c59117d7c9ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dimino?= Date: Sun, 5 Mar 2017 20:58:51 +0000 Subject: [PATCH] Don't recompile everything when the .merlin changes --- src/build.mli | 3 ++- src/gen_rules.ml | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/build.mli b/src/build.mli index 35153c1f..2d5976a8 100644 --- a/src/build.mli +++ b/src/build.mli @@ -71,7 +71,8 @@ val action -> Action.Mini_shexp.t -> (unit, Action.t) t -(** Create a file with the given contents. *) +(** Create a file with the given contents. Do not ovewrite the file if + it hasn't changed. *) val echo : Path.t -> string -> (unit, Action.t) t val echo_dyn : Path.t -> (string, Action.t) t diff --git a/src/gen_rules.ml b/src/gen_rules.ml index fd67dd64..faeb26af 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -733,10 +733,17 @@ end of your list of preprocessors. Consult the manual for more details." in let requires = if ctx.merlin then - match Path.extract_build_context dir with - | Some (_, remaindir) -> - Build.path (Path.relative remaindir ".merlin") >>> real_requires - | _ -> real_requires + (* We don't depend on the dot_merlin directly, otherwise + everytime it changes we would have to rebuild everything. + + .merlin-exists depends on the .merlin and is an empty + file. Depending on it forces the generation of the .merlin + but not recompilation when it changes. Maybe one day we + should add [Build.path_exists] to do the same in + general. *) + Build.path (Path.relative dir ".merlin-exists") + >>> + real_requires else real_requires in @@ -773,6 +780,10 @@ end of your list of preprocessors. Consult the manual for more details." match Path.extract_build_context dir with | Some (_, remaindir) -> let path = Path.relative remaindir ".merlin" in + add_rule + (Build.path path + >>> + Build.echo (Path.relative dir ".merlin-exists") ""); add_rule ( Build.fanout requires (ppx_flags ~dir ~src_dir:remaindir t) >>^ (fun (libs, ppx_flags) ->