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 =
Arg_spec.S [ iflags
; Hidden_deps
(Lib_deps.file_deps sctx libs ~ext:".cmi")
(Lib_deps.L.file_deps sctx libs ~ext:".cmi")
]
in
let cmx_includes =
@ -29,9 +29,9 @@ module Includes = struct
".cmi"
else
".cmi-and-.cmx"))
|> Lib_deps.file_deps_with_exts sctx
|> Lib_deps.L.file_deps_with_exts sctx
else
Lib_deps.file_deps sctx libs ~ext:".cmi-and-.cmx"
Lib_deps.L.file_deps sctx libs ~ext:".cmi-and-.cmx"
)
]
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))
|> Path.Set.of_list)
let file_deps_of_lib t (lib : Lib.t) ~ext =
if Lib.is_local lib then
Alias.stamp_file
(lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~ext)
else
Build_system.stamp_file_for_files_of (Super_context.build_system t)
~dir:(Lib.obj_dir lib) ~ext
module L = struct
let file_deps_of_lib t (lib : Lib.t) ~ext =
if Lib.is_local lib then
Alias.stamp_file
(lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~ext)
else
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 =
List.rev_map lib_exts ~f:(fun (lib, ext) -> file_deps_of_lib t lib ~ext)
let file_deps_with_exts t lib_exts =
List.rev_map lib_exts ~f:(fun (lib, ext) -> file_deps_of_lib t lib ~ext)
let file_deps t libs ~ext =
List.rev_map libs ~f:(file_deps_of_lib t ~ext)
let file_deps t libs ~ext =
List.rev_map libs ~f:(file_deps_of_lib t ~ext)
end

View File

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

View File

@ -273,7 +273,7 @@ module Gen (P : Install_rules.Params) = struct
[ Hidden_deps h_files
; Arg_spec.of_result_map requires ~f:(fun libs ->
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