Use static requires in merlin
This commit is contained in:
parent
04a5fe8359
commit
75269117cd
|
@ -610,7 +610,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
Lib.DB.get_compile_info (Scope.libs scope) lib.name
|
Lib.DB.get_compile_info (Scope.libs scope) lib.name
|
||||||
~allow_overlaps:lib.buildable.allow_overlapping_dependencies
|
~allow_overlaps:lib.buildable.allow_overlapping_dependencies
|
||||||
in
|
in
|
||||||
let requires, real_requires =
|
let requires =
|
||||||
SC.Libs.requires sctx compile_info
|
SC.Libs.requires sctx compile_info
|
||||||
~dir ~has_dot_merlin:true
|
~dir ~has_dot_merlin:true
|
||||||
in
|
in
|
||||||
|
@ -795,7 +795,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
};
|
};
|
||||||
|
|
||||||
Merlin.make ()
|
Merlin.make ()
|
||||||
~requires:real_requires
|
~requires:(Lib.Compile.requires compile_info)
|
||||||
~flags
|
~flags
|
||||||
~preprocess:(Buildable.single_preprocess lib.buildable)
|
~preprocess:(Buildable.single_preprocess lib.buildable)
|
||||||
~libname:lib.name
|
~libname:lib.name
|
||||||
|
@ -823,7 +823,8 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
SC.Deps.interpret sctx exes.buildable.preprocessor_deps
|
SC.Deps.interpret sctx exes.buildable.preprocessor_deps
|
||||||
~scope ~dir
|
~scope ~dir
|
||||||
in
|
in
|
||||||
Preprocessing.pp_and_lint_modules sctx ~dir ~dep_kind:Required ~modules ~scope
|
Preprocessing.pp_and_lint_modules sctx ~dir ~dep_kind:Required ~modules
|
||||||
|
~scope
|
||||||
~preprocess:exes.buildable.preprocess
|
~preprocess:exes.buildable.preprocess
|
||||||
~preprocessor_deps
|
~preprocessor_deps
|
||||||
~lint:exes.buildable.lint
|
~lint:exes.buildable.lint
|
||||||
|
@ -880,7 +881,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
~pps:(Jbuild.Preprocess_map.pps exes.buildable.preprocess)
|
~pps:(Jbuild.Preprocess_map.pps exes.buildable.preprocess)
|
||||||
~allow_overlaps:exes.buildable.allow_overlapping_dependencies
|
~allow_overlaps:exes.buildable.allow_overlapping_dependencies
|
||||||
in
|
in
|
||||||
let requires, real_requires =
|
let requires =
|
||||||
SC.Libs.requires sctx ~dir
|
SC.Libs.requires sctx ~dir
|
||||||
~has_dot_merlin:true
|
~has_dot_merlin:true
|
||||||
compile_info
|
compile_info
|
||||||
|
@ -905,7 +906,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
~js_of_ocaml:exes.buildable.js_of_ocaml;
|
~js_of_ocaml:exes.buildable.js_of_ocaml;
|
||||||
|
|
||||||
Merlin.make ()
|
Merlin.make ()
|
||||||
~requires:real_requires
|
~requires:(Lib.Compile.requires compile_info)
|
||||||
~flags:(Ocaml_flags.common flags)
|
~flags:(Ocaml_flags.common flags)
|
||||||
~preprocess:(Buildable.single_preprocess exes.buildable)
|
~preprocess:(Buildable.single_preprocess exes.buildable)
|
||||||
~objs_dirs:(Path.Set.singleton obj_dir)
|
~objs_dirs:(Path.Set.singleton obj_dir)
|
||||||
|
|
|
@ -194,7 +194,7 @@ include Sub_system.Register_end_point(
|
||||||
(Action.Var_expansion.Strings ([lib.name], Concat))
|
(Action.Var_expansion.Strings ([lib.name], Concat))
|
||||||
in
|
in
|
||||||
|
|
||||||
let runner_libs, _ =
|
let runner_libs =
|
||||||
let open Result.O in
|
let open Result.O in
|
||||||
Lib.Compile.make
|
Lib.Compile.make
|
||||||
(Result.concat_map backends
|
(Result.concat_map backends
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Preprocess = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ requires : (unit, Lib.t list) Build.t
|
{ requires : Lib.Set.t
|
||||||
; flags : (unit, string list) Build.t
|
; flags : (unit, string list) Build.t
|
||||||
; preprocess : Preprocess.t
|
; preprocess : Preprocess.t
|
||||||
; libname : string option
|
; libname : string option
|
||||||
|
@ -41,7 +41,7 @@ type t =
|
||||||
}
|
}
|
||||||
|
|
||||||
let make
|
let make
|
||||||
?(requires=Build.return [])
|
?(requires=Ok [])
|
||||||
?(flags=Build.return [])
|
?(flags=Build.return [])
|
||||||
?(preprocess=Jbuild.Preprocess.No_preprocessing)
|
?(preprocess=Jbuild.Preprocess.No_preprocessing)
|
||||||
?libname
|
?libname
|
||||||
|
@ -49,7 +49,12 @@ let make
|
||||||
?(objs_dirs=Path.Set.empty)
|
?(objs_dirs=Path.Set.empty)
|
||||||
() =
|
() =
|
||||||
(* Merlin shouldn't cause the build to fail, so we just ignore errors *)
|
(* Merlin shouldn't cause the build to fail, so we just ignore errors *)
|
||||||
{ requires = Build.catch requires ~on_error:(fun _ -> [])
|
let requires =
|
||||||
|
match requires with
|
||||||
|
| Ok l -> Lib.Set.of_list l
|
||||||
|
| Error _ -> Lib.Set.empty
|
||||||
|
in
|
||||||
|
{ requires
|
||||||
; flags = Build.catch flags ~on_error:(fun _ -> [])
|
; flags = Build.catch flags ~on_error:(fun _ -> [])
|
||||||
; preprocess = Preprocess.make preprocess
|
; preprocess = Preprocess.make preprocess
|
||||||
; libname
|
; libname
|
||||||
|
@ -92,11 +97,11 @@ let dot_merlin sctx ~dir ~scope ({ requires; flags; _ } as t) =
|
||||||
>>>
|
>>>
|
||||||
Build.create_file (Path.relative dir ".merlin-exists"));
|
Build.create_file (Path.relative dir ".merlin-exists"));
|
||||||
SC.add_rule sctx ~mode:Promote_but_delete_on_clean (
|
SC.add_rule sctx ~mode:Promote_but_delete_on_clean (
|
||||||
requires &&& flags
|
flags
|
||||||
>>^ (fun (libs, flags) ->
|
>>^ (fun flags ->
|
||||||
let ppx_flags = ppx_flags sctx ~dir ~scope ~src_dir:remaindir t in
|
let ppx_flags = ppx_flags sctx ~dir ~scope ~src_dir:remaindir t in
|
||||||
let libs =
|
let libs =
|
||||||
List.fold_left ~f:(fun acc (lib : Lib.t) ->
|
Lib.Set.fold requires ~init:[] ~f:(fun (lib : Lib.t) acc ->
|
||||||
let serialize_path = Path.reach ~from:remaindir in
|
let serialize_path = Path.reach ~from:remaindir in
|
||||||
let bpath = serialize_path (Lib.obj_dir lib) in
|
let bpath = serialize_path (Lib.obj_dir lib) in
|
||||||
let spath =
|
let spath =
|
||||||
|
@ -105,7 +110,7 @@ let dot_merlin sctx ~dir ~scope ({ requires; flags; _ } as t) =
|
||||||
|> serialize_path
|
|> serialize_path
|
||||||
in
|
in
|
||||||
("B " ^ bpath) :: ("S " ^ spath) :: acc
|
("B " ^ bpath) :: ("S " ^ spath) :: acc
|
||||||
) libs ~init:[]
|
)
|
||||||
in
|
in
|
||||||
let source_dirs =
|
let source_dirs =
|
||||||
Path.Set.fold t.source_dirs ~init:[] ~f:(fun path acc ->
|
Path.Set.fold t.source_dirs ~init:[] ~f:(fun path acc ->
|
||||||
|
@ -147,10 +152,7 @@ let dot_merlin sctx ~dir ~scope ({ requires; flags; _ } as t) =
|
||||||
()
|
()
|
||||||
|
|
||||||
let merge_two a b =
|
let merge_two a b =
|
||||||
{ requires =
|
{ requires = Lib.Set.union a.requires b.requires
|
||||||
(Build.fanout a.requires b.requires
|
|
||||||
>>^ fun (x, y) ->
|
|
||||||
Lib.L.remove_dups (x @ y))
|
|
||||||
; flags = a.flags &&& b.flags >>^ (fun (a, b) -> a @ b)
|
; flags = a.flags &&& b.flags >>^ (fun (a, b) -> a @ b)
|
||||||
; preprocess = Preprocess.merge a.preprocess b.preprocess
|
; preprocess = Preprocess.merge a.preprocess b.preprocess
|
||||||
; libname =
|
; libname =
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
(** Merlin rules *)
|
(** Merlin rules *)
|
||||||
|
|
||||||
|
open Import
|
||||||
|
|
||||||
type t
|
type t
|
||||||
|
|
||||||
val make
|
val make
|
||||||
: ?requires:(unit, Lib.t list) Build.t
|
: ?requires:(Lib.t list, exn) result
|
||||||
-> ?flags:(unit, string list) Build.t
|
-> ?flags:(unit, string list) Build.t
|
||||||
-> ?preprocess:Jbuild.Preprocess.t
|
-> ?preprocess:Jbuild.Preprocess.t
|
||||||
-> ?libname:string
|
-> ?libname:string
|
||||||
|
|
|
@ -284,15 +284,12 @@ module Libs = struct
|
||||||
Required)
|
Required)
|
||||||
>>> requires
|
>>> requires
|
||||||
in
|
in
|
||||||
let requires_with_merlin =
|
|
||||||
if t.context.merlin && has_dot_merlin then
|
if t.context.merlin && has_dot_merlin then
|
||||||
Build.path (Path.relative dir ".merlin-exists")
|
Build.path (Path.relative dir ".merlin-exists")
|
||||||
>>>
|
>>>
|
||||||
requires
|
requires
|
||||||
else
|
else
|
||||||
requires
|
requires
|
||||||
in
|
|
||||||
(requires_with_merlin, requires)
|
|
||||||
|
|
||||||
let lib_files_alias ~dir ~name ~ext =
|
let lib_files_alias ~dir ~name ~ext =
|
||||||
Alias.make (sprintf "lib-%s%s-all" name ext) ~dir
|
Alias.make (sprintf "lib-%s%s-all" name ext) ~dir
|
||||||
|
|
|
@ -131,15 +131,13 @@ val resolve_program
|
||||||
|
|
||||||
module Libs : sig
|
module Libs : sig
|
||||||
(** Returns the closed list of dependencies for a dependency list in
|
(** Returns the closed list of dependencies for a dependency list in
|
||||||
a stanza. The second arrow is the same as the first one but with
|
a stanza. *)
|
||||||
an added dependency on the [.merlin] if [(context t).merlin &&
|
|
||||||
has_dot_merlin] is [true]. *)
|
|
||||||
val requires
|
val requires
|
||||||
: t
|
: t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> has_dot_merlin:bool
|
-> has_dot_merlin:bool
|
||||||
-> Lib.Compile.t
|
-> Lib.Compile.t
|
||||||
-> (unit, Lib.L.t) Build.t * (unit, Lib.L.t) Build.t
|
-> (unit, Lib.L.t) Build.t
|
||||||
|
|
||||||
(** [file_deps ~ext] is an arrow that record dependencies on all the
|
(** [file_deps ~ext] is an arrow that record dependencies on all the
|
||||||
files with extension [ext] of the libraries given as input. *)
|
files with extension [ext] of the libraries given as input. *)
|
||||||
|
|
|
@ -62,7 +62,7 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|
||||||
; intf = None
|
; intf = None
|
||||||
; obj_name = "" } in
|
; obj_name = "" } in
|
||||||
let utop_exe_dir = utop_exe_dir ~dir in
|
let utop_exe_dir = utop_exe_dir ~dir in
|
||||||
let requires, _ =
|
let requires =
|
||||||
Lib.DB.find_many (Scope.libs scope)
|
Lib.DB.find_many (Scope.libs scope)
|
||||||
("utop" :: List.map libs ~f:(fun (lib : Library.t) -> lib.name))
|
("utop" :: List.map libs ~f:(fun (lib : Library.t) -> lib.name))
|
||||||
|> Lib.Compile.make
|
|> Lib.Compile.make
|
||||||
|
|
Loading…
Reference in New Issue