Merge pull request #1213 from rgrinberg/lib-deps
Move SC.Libs to own module
This commit is contained in:
commit
daac91da82
|
@ -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
|
||||||
(SC.Libs.file_deps sctx libs ~ext:".cmi")
|
(Lib_file_deps.L.file_deps sctx libs ~exts:[".cmi"])
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
let cmx_includes =
|
let cmx_includes =
|
||||||
|
@ -26,12 +26,12 @@ module Includes = struct
|
||||||
( if opaque then
|
( if opaque then
|
||||||
List.map libs ~f:(fun lib ->
|
List.map libs ~f:(fun lib ->
|
||||||
(lib, if Lib.is_local lib then
|
(lib, if Lib.is_local lib then
|
||||||
".cmi"
|
[".cmi"]
|
||||||
else
|
else
|
||||||
".cmi-and-.cmx"))
|
[".cmi"; ".cmx"]))
|
||||||
|> SC.Libs.file_deps_with_exts sctx
|
|> Lib_file_deps.L.file_deps_with_exts sctx
|
||||||
else
|
else
|
||||||
SC.Libs.file_deps sctx libs ~ext:".cmi-and-.cmx"
|
Lib_file_deps.L.file_deps sctx libs ~exts:[".cmi"; ".cmx"]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
open Stdune
|
||||||
|
open Dune_file
|
||||||
|
open Build_system
|
||||||
|
|
||||||
|
let string_of_exts = String.concat ~sep:"-and-"
|
||||||
|
|
||||||
|
let lib_files_alias ~dir ~name ~exts =
|
||||||
|
Alias.make (sprintf "lib-%s%s-all"
|
||||||
|
(Lib_name.to_string name) (string_of_exts exts)) ~dir
|
||||||
|
|
||||||
|
let setup_file_deps_alias t ~dir ~exts lib files =
|
||||||
|
Super_context.add_alias_deps t
|
||||||
|
(lib_files_alias ~dir ~name:(Library.best_name lib) ~exts) files
|
||||||
|
|
||||||
|
let setup_file_deps_group_alias t ~dir ~exts lib =
|
||||||
|
setup_file_deps_alias t lib ~dir ~exts
|
||||||
|
(List.map exts ~f:(fun ext ->
|
||||||
|
Alias.stamp_file
|
||||||
|
(lib_files_alias ~dir ~name:(Library.best_name lib) ~exts:[ext]))
|
||||||
|
|> Path.Set.of_list)
|
||||||
|
|
||||||
|
module L = struct
|
||||||
|
let file_deps_of_lib t (lib : Lib.t) ~exts =
|
||||||
|
if Lib.is_local lib then
|
||||||
|
Alias.stamp_file
|
||||||
|
(lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~exts)
|
||||||
|
else
|
||||||
|
Build_system.stamp_file_for_files_of (Super_context.build_system t)
|
||||||
|
~dir:(Lib.obj_dir lib) ~ext:(string_of_exts exts)
|
||||||
|
|
||||||
|
let file_deps_with_exts t lib_exts =
|
||||||
|
List.rev_map lib_exts ~f:(fun (lib, exts) -> file_deps_of_lib t lib ~exts)
|
||||||
|
|
||||||
|
let file_deps t libs ~exts =
|
||||||
|
List.rev_map libs ~f:(file_deps_of_lib t ~exts)
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
open Stdune
|
||||||
|
|
||||||
|
module L : sig
|
||||||
|
|
||||||
|
(** [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 -> exts:string list -> Path.t list
|
||||||
|
|
||||||
|
val file_deps_with_exts
|
||||||
|
: Super_context.t
|
||||||
|
-> (Lib.t * string list) list
|
||||||
|
-> Path.t list
|
||||||
|
end
|
||||||
|
|
||||||
|
(** Setup the alias that depends on all files with a given extension for a
|
||||||
|
library *)
|
||||||
|
val setup_file_deps_alias
|
||||||
|
: Super_context.t
|
||||||
|
-> dir:Path.t
|
||||||
|
-> exts:string list
|
||||||
|
-> Dune_file.Library.t
|
||||||
|
-> Path.Set.t
|
||||||
|
-> unit
|
||||||
|
|
||||||
|
(** Setup an alias that depend on all files with the given extensions.*)
|
||||||
|
val setup_file_deps_group_alias
|
||||||
|
: Super_context.t
|
||||||
|
-> dir:Path.t
|
||||||
|
-> exts:string list
|
||||||
|
-> Dune_file.Library.t
|
||||||
|
-> unit
|
|
@ -1,9 +1,12 @@
|
||||||
open! Stdune
|
open! Stdune
|
||||||
open Import
|
open Import
|
||||||
open Build.O
|
open Build.O
|
||||||
open Dune_file
|
|
||||||
open! No_io
|
open! No_io
|
||||||
|
|
||||||
|
module Buildable = Dune_file.Buildable
|
||||||
|
module Library = Dune_file.Library
|
||||||
|
module Mode_conf = Dune_file.Mode_conf
|
||||||
|
|
||||||
module SC = Super_context
|
module SC = Super_context
|
||||||
|
|
||||||
module Gen (P : Install_rules.Params) = struct
|
module Gen (P : Install_rules.Params) = struct
|
||||||
|
@ -270,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 (SC.Libs.file_deps sctx libs ~ext:".h")
|
; Hidden_deps (Lib_file_deps.L.file_deps sctx libs ~exts:[".h"])
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
|
@ -404,11 +407,11 @@ module Gen (P : Install_rules.Params) = struct
|
||||||
List.iter Cm_kind.all ~f:(fun cm_kind ->
|
List.iter Cm_kind.all ~f:(fun cm_kind ->
|
||||||
let files = add_cms ~cm_kind ~init:Path.Set.empty modules in
|
let files = add_cms ~cm_kind ~init:Path.Set.empty modules in
|
||||||
let files = add_cms ~cm_kind ~init:files wrapped_compat in
|
let files = add_cms ~cm_kind ~init:files wrapped_compat in
|
||||||
SC.Libs.setup_file_deps_alias sctx ~dir lib ~ext:(Cm_kind.ext cm_kind)
|
Lib_file_deps.setup_file_deps_alias sctx ~dir lib ~exts:[Cm_kind.ext cm_kind]
|
||||||
files);
|
files);
|
||||||
|
|
||||||
SC.Libs.setup_file_deps_group_alias sctx ~dir lib ~exts:[".cmi"; ".cmx"];
|
Lib_file_deps.setup_file_deps_group_alias sctx ~dir lib ~exts:[".cmi"; ".cmx"];
|
||||||
SC.Libs.setup_file_deps_alias sctx ~dir lib ~ext:".h"
|
Lib_file_deps.setup_file_deps_alias sctx ~dir lib ~exts:[".h"]
|
||||||
(List.map lib.install_c_headers ~f:(fun header ->
|
(List.map lib.install_c_headers ~f:(fun header ->
|
||||||
Path.relative dir (header ^ ".h"))
|
Path.relative dir (header ^ ".h"))
|
||||||
|> Path.Set.of_list);
|
|> Path.Set.of_list);
|
||||||
|
|
|
@ -679,7 +679,7 @@ module Libs = struct
|
||||||
let with_lib_deps t compile_info ~dir ~f =
|
let with_lib_deps t compile_info ~dir ~f =
|
||||||
let prefix =
|
let prefix =
|
||||||
Build.record_lib_deps
|
Build.record_lib_deps
|
||||||
(Lib_deps.info
|
(Dune_file.Lib_deps.info
|
||||||
(Lib.Compile.user_written_deps compile_info)
|
(Lib.Compile.user_written_deps compile_info)
|
||||||
~kind:(if Lib.Compile.optional compile_info then
|
~kind:(if Lib.Compile.optional compile_info then
|
||||||
Optional
|
Optional
|
||||||
|
@ -695,35 +695,6 @@ module Libs = struct
|
||||||
prefix
|
prefix
|
||||||
in
|
in
|
||||||
prefix_rules t prefix ~f
|
prefix_rules t prefix ~f
|
||||||
|
|
||||||
let lib_files_alias ~dir ~name ~ext =
|
|
||||||
Alias.make (sprintf "lib-%s%s-all" (Lib_name.to_string name) ext) ~dir
|
|
||||||
|
|
||||||
let setup_file_deps_alias t ~dir ~ext lib files =
|
|
||||||
add_alias_deps t
|
|
||||||
(lib_files_alias ~dir ~name:(Library.best_name lib) ~ext) files
|
|
||||||
|
|
||||||
let setup_file_deps_group_alias t ~dir ~exts lib =
|
|
||||||
setup_file_deps_alias t lib ~dir
|
|
||||||
~ext:(String.concat exts ~sep:"-and-")
|
|
||||||
(List.map exts ~f:(fun ext ->
|
|
||||||
Alias.stamp_file
|
|
||||||
(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 t.build_system
|
|
||||||
~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 t libs ~ext =
|
|
||||||
List.rev_map libs ~f:(file_deps_of_lib t ~ext)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Deps = struct
|
module Deps = struct
|
||||||
|
|
|
@ -195,33 +195,6 @@ module Libs : sig
|
||||||
|
|
||||||
(** Generate the rules for the [(select ...)] forms in library dependencies *)
|
(** Generate the rules for the [(select ...)] forms in library dependencies *)
|
||||||
val gen_select_rules : t -> dir:Path.t -> Lib.Compile.t -> unit
|
val gen_select_rules : t -> dir:Path.t -> Lib.Compile.t -> unit
|
||||||
|
|
||||||
(** [file_deps t libs ~ext] returns a list of path dependencies for
|
|
||||||
all the files with extension [ext] of libraries [libs]. *)
|
|
||||||
val file_deps : t -> Lib.L.t -> ext:string -> Path.t list
|
|
||||||
|
|
||||||
val file_deps_with_exts : t -> (Lib.t * string) list -> Path.t list
|
|
||||||
|
|
||||||
(** Setup the alias that depends on all files with a given extension
|
|
||||||
for a library *)
|
|
||||||
val setup_file_deps_alias
|
|
||||||
: t
|
|
||||||
-> dir:Path.t
|
|
||||||
-> ext:string
|
|
||||||
-> Library.t
|
|
||||||
-> Path.Set.t
|
|
||||||
-> unit
|
|
||||||
|
|
||||||
(** Setup an alias that depend on all files with the given extensions.
|
|
||||||
|
|
||||||
To depend on this alias, use [~ext:"ext1-and-ext2-...-extn"]
|
|
||||||
*)
|
|
||||||
val setup_file_deps_group_alias
|
|
||||||
: t
|
|
||||||
-> dir:Path.t
|
|
||||||
-> exts:string list
|
|
||||||
-> Library.t
|
|
||||||
-> unit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Interpret dependencies written in jbuild files *)
|
(** Interpret dependencies written in jbuild files *)
|
||||||
|
|
Loading…
Reference in New Issue