Move functions that operate on more than 1 module to Lib_deps.L

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-09-02 16:18:11 +04:00
parent e47987a670
commit 0ebad2d50f
4 changed files with 27 additions and 22 deletions

View File

@ -16,7 +16,7 @@ module Includes = struct
let cmi_includes = let cmi_includes =
Arg_spec.S [ iflags Arg_spec.S [ iflags
; Hidden_deps ; Hidden_deps
(Lib_deps.file_deps sctx libs ~ext:".cmi") (Lib_deps.L.file_deps sctx libs ~ext:".cmi")
] ]
in in
let cmx_includes = let cmx_includes =
@ -29,9 +29,9 @@ module Includes = struct
".cmi" ".cmi"
else else
".cmi-and-.cmx")) ".cmi-and-.cmx"))
|> Lib_deps.file_deps_with_exts sctx |> Lib_deps.L.file_deps_with_exts sctx
else else
Lib_deps.file_deps sctx libs ~ext:".cmi-and-.cmx" Lib_deps.L.file_deps sctx libs ~ext:".cmi-and-.cmx"
) )
] ]
in in

View File

@ -17,16 +17,18 @@ let setup_file_deps_group_alias t ~dir ~exts lib =
(lib_files_alias ~dir ~name:(Library.best_name lib) ~ext)) (lib_files_alias ~dir ~name:(Library.best_name lib) ~ext))
|> Path.Set.of_list) |> Path.Set.of_list)
let file_deps_of_lib t (lib : Lib.t) ~ext = module L = struct
if Lib.is_local lib then let file_deps_of_lib t (lib : Lib.t) ~ext =
Alias.stamp_file if Lib.is_local lib then
(lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~ext) Alias.stamp_file
else (lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~ext)
Build_system.stamp_file_for_files_of (Super_context.build_system t) else
~dir:(Lib.obj_dir lib) ~ext Build_system.stamp_file_for_files_of (Super_context.build_system t)
~dir:(Lib.obj_dir lib) ~ext
let file_deps_with_exts t lib_exts = let file_deps_with_exts t lib_exts =
List.rev_map lib_exts ~f:(fun (lib, ext) -> file_deps_of_lib t lib ~ext) List.rev_map lib_exts ~f:(fun (lib, ext) -> file_deps_of_lib t lib ~ext)
let file_deps t libs ~ext = let file_deps t libs ~ext =
List.rev_map libs ~f:(file_deps_of_lib t ~ext) List.rev_map libs ~f:(file_deps_of_lib t ~ext)
end

View File

@ -1,13 +1,16 @@
open Stdune open Stdune
(** [file_deps t libs ~ext] returns a list of path dependencies for all the module L : sig
files with extension [ext] of libraries [libs]. *)
val file_deps : Super_context.t -> Lib.L.t -> ext:string -> Path.t list
val file_deps_with_exts (** [file_deps t libs ~ext] returns a list of path dependencies for all the
: Super_context.t files with extension [ext] of libraries [libs]. *)
-> (Lib.t * string) list val file_deps : Super_context.t -> Lib.L.t -> ext:string -> Path.t list
-> Path.t list
val file_deps_with_exts
: Super_context.t
-> (Lib.t * string) list
-> Path.t list
end
(** Setup the alias that depends on all files with a given extension (** Setup the alias that depends on all files with a given extension
for a library *) for a library *)

View File

@ -273,7 +273,7 @@ module Gen (P : Install_rules.Params) = struct
[ Hidden_deps h_files [ Hidden_deps h_files
; Arg_spec.of_result_map requires ~f:(fun libs -> ; Arg_spec.of_result_map requires ~f:(fun libs ->
S [ Lib.L.c_include_flags libs ~stdlib_dir:ctx.stdlib_dir S [ Lib.L.c_include_flags libs ~stdlib_dir:ctx.stdlib_dir
; Hidden_deps (Lib_deps.file_deps sctx libs ~ext:".h") ; Hidden_deps (Lib_deps.L.file_deps sctx libs ~ext:".h")
]) ])
] ]
in in