Pass common flags to merlin

This commit is contained in:
Jérémie Dimino 2017-03-05 10:32:04 +00:00
parent d58528d14c
commit 05830fc809
1 changed files with 31 additions and 10 deletions

View File

@ -716,7 +716,7 @@ end of your list of preprocessors. Consult the manual for more details."
in in
(requires, real_requires) (requires, real_requires)
let dot_merlin ~dir ~requires ~alias_modules = let dot_merlin ~dir ~requires ~alias_modules ~flags =
if ctx.merlin then if ctx.merlin then
match Path.extract_build_context dir with match Path.extract_build_context dir with
| Some (_, remaindir) -> | Some (_, remaindir) ->
@ -732,12 +732,23 @@ end of your list of preprocessors. Consult the manual for more details."
| Lib.External pkg -> | Lib.External pkg ->
Inr ("PKG " ^ pkg.name)) Inr ("PKG " ^ pkg.name))
in in
let flags =
match
List.fold_left alias_modules ~init:flags ~f:(fun acc m ->
"-open" :: m.Module.name :: acc)
with
| [] -> []
| l -> ["FLG " ^ String.concat ~sep:" " l]
in
let dot_merlin = let dot_merlin =
[ "S ." ; "B " ^ (Path.reach dir ~from:remaindir) ] List.concat
@ internals [ [ "S ."
@ externals ; "B " ^ (Path.reach dir ~from:remaindir)
@ List.map alias_modules ~f:(fun (m : Module.t) -> ]
"FLG -open " ^ m.name) ; internals
; externals
; flags
]
in in
dot_merlin dot_merlin
|> String_set.of_list |> String_set.of_list
@ -752,14 +763,24 @@ end of your list of preprocessors. Consult the manual for more details."
let merge_dot_merlin merlin_deps ~dir = let merge_dot_merlin merlin_deps ~dir =
if ctx.merlin && merlin_deps <> [] then if ctx.merlin && merlin_deps <> [] then
let requires, alias_modules = List.split merlin_deps in let flags, requires, alias_modules =
List.fold_left merlin_deps ~init:([], [], [])
~f:(fun (a1, b1, c1) (a2, b2, c2) ->
(a2 :: a1,
b2 :: b1,
c2 :: c1))
in
let alias_modules = List.filter_map alias_modules ~f:(fun x -> x) in let alias_modules = List.filter_map alias_modules ~f:(fun x -> x) in
let requires = let requires =
Build.all requires Build.all requires
>>^ fun requires -> >>^ fun requires ->
Lib.remove_dups_preserve_order (List.concat requires) Lib.remove_dups_preserve_order (List.concat requires)
in in
dot_merlin ~dir ~requires ~alias_modules let flags =
List.concat_map flags ~f:(fun flags ->
flags.Ocaml_flags.common)
in
dot_merlin ~dir ~requires ~alias_modules ~flags
let setup_runtime_deps ~dir ~dep_kind ~item ~libraries ~ppx_runtime_libraries = let setup_runtime_deps ~dir ~dep_kind ~item ~libraries ~ppx_runtime_libraries =
let vruntime_deps = Lib_db.vruntime_deps ~dir ~item in let vruntime_deps = Lib_db.vruntime_deps ~dir ~item in
@ -1210,7 +1231,7 @@ end of your list of preprocessors. Consult the manual for more details."
: (unit, Lib.t list) Build.t) : (unit, Lib.t list) Build.t)
end; end;
(real_requires, alias_module) (flags, real_requires, alias_module)
(* +-----------------------------------------------------------------+ (* +-----------------------------------------------------------------+
| Executables stuff | | Executables stuff |
@ -1286,7 +1307,7 @@ end of your list of preprocessors. Consult the manual for more details."
build_exe ~flags ~dir ~requires ~name ~mode ~modules ~dep_graph build_exe ~flags ~dir ~requires ~name ~mode ~modules ~dep_graph
~link_flags:exes.link_flags)); ~link_flags:exes.link_flags));
(real_requires, None) (flags, real_requires, None)
(* +-----------------------------------------------------------------+ (* +-----------------------------------------------------------------+
| User actions | | User actions |