Cleanup lib stuff
This commit is contained in:
parent
130cadf855
commit
3a266c686e
|
@ -16,47 +16,6 @@ module Gen(P : Params) = struct
|
|||
|
||||
let ctx = SC.context sctx
|
||||
|
||||
let real_requires ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps =
|
||||
let all_pps =
|
||||
List.map (Preprocess_map.pps preprocess) ~f:Pp.to_string
|
||||
in
|
||||
let vrequires = SC.Libs.vrequires sctx ~dir ~item in
|
||||
SC.add_rule sctx
|
||||
(Build.record_lib_deps ~dir ~kind:dep_kind (List.map virtual_deps ~f:Lib_dep.direct)
|
||||
>>>
|
||||
Build.fanout
|
||||
(SC.Libs.closure sctx ~dir ~dep_kind libraries)
|
||||
(SC.Libs.closed_ppx_runtime_deps_of sctx ~dir ~dep_kind
|
||||
(List.map all_pps ~f:Lib_dep.direct))
|
||||
>>>
|
||||
Build.arr (fun (libs, rt_deps) ->
|
||||
Lib.remove_dups_preserve_order (libs @ rt_deps))
|
||||
>>>
|
||||
Build.store_vfile vrequires);
|
||||
Build.vpath vrequires
|
||||
|
||||
let requires ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps =
|
||||
let real_requires =
|
||||
real_requires ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps
|
||||
in
|
||||
let requires =
|
||||
if ctx.merlin then
|
||||
(* 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
|
||||
(requires, real_requires)
|
||||
|
||||
module Merlin = struct
|
||||
type t =
|
||||
{ requires : (unit, Lib.t list) Build.t
|
||||
|
@ -152,18 +111,6 @@ module Gen(P : Params) = struct
|
|||
| t :: ts -> dot_merlin ~dir (List.fold_left ts ~init:t ~f:merge_two)
|
||||
end
|
||||
|
||||
let setup_runtime_deps ~dir ~dep_kind ~item ~libraries ~ppx_runtime_libraries =
|
||||
let vruntime_deps = SC.Libs.vruntime_deps sctx ~dir ~item in
|
||||
SC.add_rule sctx
|
||||
(Build.fanout
|
||||
(SC.Libs.closure sctx ~dir ~dep_kind (List.map ppx_runtime_libraries ~f:Lib_dep.direct))
|
||||
(SC.Libs.closed_ppx_runtime_deps_of sctx ~dir ~dep_kind libraries)
|
||||
>>>
|
||||
Build.arr (fun (rt_deps, rt_deps_of_deps) ->
|
||||
Lib.remove_dups_preserve_order (rt_deps @ rt_deps_of_deps))
|
||||
>>>
|
||||
Build.store_vfile vruntime_deps)
|
||||
|
||||
(* +-----------------------------------------------------------------+
|
||||
| Ordered set lang evaluation |
|
||||
+-----------------------------------------------------------------+ *)
|
||||
|
@ -515,13 +462,13 @@ module Gen(P : Params) = struct
|
|||
>>> Build.update_file_dyn (Path.relative dir m.impl.name)));
|
||||
|
||||
let requires, real_requires =
|
||||
requires ~dir ~dep_kind ~item:lib.name
|
||||
SC.Libs.requires sctx ~dir ~dep_kind ~item:lib.name
|
||||
~libraries:lib.buildable.libraries
|
||||
~preprocess:lib.buildable.preprocess
|
||||
~virtual_deps:lib.virtual_deps
|
||||
in
|
||||
|
||||
setup_runtime_deps ~dir ~dep_kind ~item:lib.name
|
||||
SC.Libs.setup_runtime_deps sctx ~dir ~dep_kind ~item:lib.name
|
||||
~libraries:lib.buildable.libraries
|
||||
~ppx_runtime_libraries:lib.ppx_runtime_libraries;
|
||||
SC.Libs.add_select_rules sctx ~dir lib.buildable.libraries;
|
||||
|
@ -694,7 +641,7 @@ module Gen(P : Params) = struct
|
|||
let dep_graph = Ocamldep.rules sctx ~dir ~item ~modules ~alias_module:None in
|
||||
|
||||
let requires, real_requires =
|
||||
requires ~dir ~dep_kind ~item
|
||||
SC.Libs.requires sctx ~dir ~dep_kind ~item
|
||||
~libraries:exes.buildable.libraries
|
||||
~preprocess:exes.buildable.preprocess
|
||||
~virtual_deps:[]
|
||||
|
|
|
@ -262,6 +262,58 @@ module Libs = struct
|
|||
>>>
|
||||
Build.action_context_independent ~targets:[dst]
|
||||
(Copy_and_add_line_directive (src, dst))))
|
||||
|
||||
let real_requires t ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps =
|
||||
let all_pps =
|
||||
List.map (Preprocess_map.pps preprocess) ~f:Pp.to_string
|
||||
in
|
||||
let vrequires = vrequires t ~dir ~item in
|
||||
add_rule t
|
||||
(Build.record_lib_deps ~dir ~kind:dep_kind (List.map virtual_deps ~f:Lib_dep.direct)
|
||||
>>>
|
||||
Build.fanout
|
||||
(closure t ~dir ~dep_kind libraries)
|
||||
(closed_ppx_runtime_deps_of t ~dir ~dep_kind
|
||||
(List.map all_pps ~f:Lib_dep.direct))
|
||||
>>>
|
||||
Build.arr (fun (libs, rt_deps) ->
|
||||
Lib.remove_dups_preserve_order (libs @ rt_deps))
|
||||
>>>
|
||||
Build.store_vfile vrequires);
|
||||
Build.vpath vrequires
|
||||
|
||||
let requires t ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps =
|
||||
let real_requires =
|
||||
real_requires t ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps
|
||||
in
|
||||
let requires =
|
||||
if t.context.merlin then
|
||||
(* 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
|
||||
(requires, real_requires)
|
||||
|
||||
let setup_runtime_deps t ~dir ~dep_kind ~item ~libraries ~ppx_runtime_libraries =
|
||||
let vruntime_deps = vruntime_deps t ~dir ~item in
|
||||
add_rule t
|
||||
(Build.fanout
|
||||
(closure t ~dir ~dep_kind (List.map ppx_runtime_libraries ~f:Lib_dep.direct))
|
||||
(closed_ppx_runtime_deps_of t ~dir ~dep_kind libraries)
|
||||
>>>
|
||||
Build.arr (fun (rt_deps, rt_deps_of_deps) ->
|
||||
Lib.remove_dups_preserve_order (rt_deps @ rt_deps_of_deps))
|
||||
>>>
|
||||
Build.store_vfile vruntime_deps)
|
||||
end
|
||||
|
||||
module Deps = struct
|
||||
|
|
|
@ -48,29 +48,37 @@ val sources_and_targets_known_so_far : t -> src_path:Path.t -> String_set.t
|
|||
|
||||
module Libs : sig
|
||||
val find : t -> from:Path.t -> string -> Lib.t option
|
||||
val vrequires : t -> dir:Path.t -> item:string -> Lib.t list Build.Vspec.t
|
||||
val load_requires : t -> dir:Path.t -> item:string -> (unit, Lib.t list) Build.t
|
||||
|
||||
val vruntime_deps : t -> dir:Path.t -> item:string -> Lib.t list Build.Vspec.t
|
||||
val load_requires : t -> dir:Path.t -> item:string -> (unit, Lib.t list) Build.t
|
||||
val load_runtime_deps : t -> dir:Path.t -> item:string -> (unit, Lib.t list) Build.t
|
||||
|
||||
val closure
|
||||
: t
|
||||
-> dir:Path.t
|
||||
-> dep_kind:Build.lib_dep_kind
|
||||
-> Lib_deps.t
|
||||
-> (unit, Lib.t list) Build.t
|
||||
|
||||
val closed_ppx_runtime_deps_of
|
||||
: t
|
||||
-> dir:Path.t
|
||||
-> dep_kind:Build.lib_dep_kind
|
||||
-> Lib_deps.t
|
||||
-> (unit, Lib.t list) Build.t
|
||||
|
||||
val lib_is_available : t -> from:Path.t -> string -> bool
|
||||
|
||||
(** Add rules for (select ...) forms *)
|
||||
val add_select_rules : t -> dir:Path.t -> Lib_deps.t -> unit
|
||||
|
||||
(** 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 an added dependency on the
|
||||
.merlin. *)
|
||||
val requires
|
||||
: t
|
||||
-> dir:Path.t
|
||||
-> dep_kind:Build.lib_dep_kind
|
||||
-> item:string (** Library name or first exe name *)
|
||||
-> libraries:Lib_deps.t
|
||||
-> preprocess:Preprocess_map.t
|
||||
-> virtual_deps:string list
|
||||
-> (unit, Lib.t list) Build.t * (unit, Lib.t list) Build.t
|
||||
|
||||
(** Setup the rules for ppx runtime dependencies *)
|
||||
val setup_runtime_deps
|
||||
: t
|
||||
-> dir:Path.t
|
||||
-> dep_kind:Build.lib_dep_kind
|
||||
-> item:string (** Library name or first exe name *)
|
||||
-> libraries:Lib_deps.t
|
||||
-> ppx_runtime_libraries:string list
|
||||
-> unit
|
||||
end
|
||||
|
||||
(** Interpret dependencies written in jbuild files *)
|
||||
|
|
Loading…
Reference in New Issue