From b401284b84d1b2bb2d5ff5df72160de21ac2bee9 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Fri, 19 Jan 2018 22:54:05 +0000 Subject: [PATCH] Restore .merlin-exists trick This is needed so that command don't depend on the contents of the .merlin --- src/merlin.ml | 12 ++++++++++++ src/super_context.ml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/merlin.ml b/src/merlin.ml index e20246fd..8a1a1e64 100644 --- a/src/merlin.ml +++ b/src/merlin.ml @@ -31,6 +31,18 @@ let dot_merlin sctx ~dir ({ requires; flags; _ } as t) = match Path.drop_build_context dir with | Some remaindir -> let merlin_file = Path.relative dir ".merlin" in + (* We make the compilation of .ml/.mli files depend on the + existence of .merlin so that they are always generated, however + the command themselves don't read the merlin file, so we don't + want to declare a dependency on the contents of the .merlin + file. + + Currently jbuilder doesn't support declaring a dependency only + on the existence of a file, so we have to use this trick. *) + SC.add_rule sctx + (Build.path merlin_file + >>> + Build.create_file (Path.relative dir ".merlin-exists")); SC.add_rule sctx ~mode:Promote_but_delete_on_clean ( requires &&& flags >>^ (fun (libs, flags) -> diff --git a/src/super_context.ml b/src/super_context.ml index 64c68521..bfaedc5b 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -322,7 +322,7 @@ module Libs = struct in let requires = if t.context.merlin && has_dot_merlin then - Build.path (Path.relative dir ".merlin") + Build.path (Path.relative dir ".merlin-exists") >>> real_requires else