parent
473b8d11ed
commit
8e27f1966d
|
@ -88,7 +88,7 @@ let static_deps t ~all_targets =
|
|||
loop (Build.repr t) { rule_deps = Pset.empty; action_deps = Pset.empty }
|
||||
|
||||
let lib_deps =
|
||||
let rec loop : type a b. (a, b) t -> Build.lib_deps option -> Build.lib_deps option
|
||||
let rec loop : type a b. (a, b) t -> Build.lib_deps -> Build.lib_deps
|
||||
= fun t acc ->
|
||||
match t with
|
||||
| Arr _ -> acc
|
||||
|
@ -105,17 +105,13 @@ let lib_deps =
|
|||
| Dyn_paths t -> loop t acc
|
||||
| Contents _ -> acc
|
||||
| Lines_of _ -> acc
|
||||
| Record_lib_deps deps ->
|
||||
begin match acc with
|
||||
| None -> Some deps
|
||||
| Some acc -> Some (Build.merge_lib_deps deps acc)
|
||||
end
|
||||
| Record_lib_deps deps -> Build.merge_lib_deps deps acc
|
||||
| Fail _ -> acc
|
||||
| If_file_exists (_, state) ->
|
||||
loop (get_if_file_exists_exn state) acc
|
||||
| Memo m -> loop m.t acc
|
||||
in
|
||||
fun t -> loop (Build.repr t) None
|
||||
fun t -> loop (Build.repr t) String_map.empty
|
||||
|
||||
let targets =
|
||||
let rec loop : type a b. (a, b) t -> Target.t list -> Target.t list = fun t acc ->
|
||||
|
|
|
@ -47,7 +47,7 @@ val static_deps
|
|||
|
||||
val lib_deps
|
||||
: (_, _) Build.t
|
||||
-> Build.lib_deps option
|
||||
-> Build.lib_deps
|
||||
|
||||
val targets
|
||||
: (_, _) Build.t
|
||||
|
|
|
@ -1165,7 +1165,7 @@ module Ir_set = Set.Make(Internal_rule)
|
|||
|
||||
let rules_for_files t paths =
|
||||
List.filter_map paths ~f:(fun path ->
|
||||
if Path.is_in_build_dir path then load_dir t ~dir:path;
|
||||
if Path.is_in_build_dir path then load_dir t ~dir:(Path.parent path);
|
||||
match Hashtbl.find t.files path with
|
||||
| None -> None
|
||||
| Some (File_spec.T { rule; _ }) -> Some rule)
|
||||
|
@ -1207,29 +1207,28 @@ let all_lib_deps t ~request =
|
|||
let targets = static_deps_of_request t request in
|
||||
List.fold_left (rules_for_targets t targets) ~init:Pmap.empty
|
||||
~f:(fun acc (rule : Internal_rule.t) ->
|
||||
let lib_deps =
|
||||
match Build_interpret.lib_deps rule.build with
|
||||
| None -> Pmap.empty
|
||||
| Some deps -> Pmap.singleton rule.dir deps in
|
||||
Pmap.merge acc lib_deps ~f:(fun _ a b ->
|
||||
match a, b with
|
||||
| None, None -> None
|
||||
| Some a, None -> Some a
|
||||
| None, Some b -> Some b
|
||||
| Some a, Some b -> Some (Build.merge_lib_deps a b)))
|
||||
let deps = Build_interpret.lib_deps rule.build in
|
||||
if String_map.is_empty deps then
|
||||
acc
|
||||
else
|
||||
let deps =
|
||||
match Pmap.find rule.dir acc with
|
||||
| None -> deps
|
||||
| Some deps' -> Build.merge_lib_deps deps deps'
|
||||
in
|
||||
Pmap.add acc ~key:rule.dir ~data:deps)
|
||||
|
||||
let all_lib_deps_by_context t ~request =
|
||||
let targets = static_deps_of_request t request in
|
||||
rules_for_targets t targets
|
||||
|> List.fold_left ~init:[] ~f:(fun acc (rule : Internal_rule.t) ->
|
||||
let lib_deps =
|
||||
match Build_interpret.lib_deps rule.build with
|
||||
| None -> Pmap.empty
|
||||
| Some deps -> Pmap.singleton rule.dir deps in
|
||||
Path.Map.fold lib_deps ~init:acc ~f:(fun ~key:path ~data:lib_deps acc ->
|
||||
match Path.extract_build_context path with
|
||||
let rules = rules_for_targets t targets in
|
||||
List.fold_left rules ~init:[] ~f:(fun acc (rule : Internal_rule.t) ->
|
||||
let deps = Build_interpret.lib_deps rule.build in
|
||||
if String_map.is_empty deps then
|
||||
acc
|
||||
else
|
||||
match Path.extract_build_context rule.dir with
|
||||
| None -> acc
|
||||
| Some (context, _) -> (context, lib_deps) :: acc))
|
||||
| Some (context, _) -> (context, deps) :: acc)
|
||||
|> String_map.of_alist_multi
|
||||
|> String_map.map ~f:(function
|
||||
| [] -> String_map.empty
|
||||
|
|
|
@ -303,7 +303,8 @@ module Libs = struct
|
|||
in
|
||||
let vrequires = vrequires t ~dir ~item in
|
||||
add_rule t
|
||||
(Build.record_lib_deps ~kind:dep_kind (List.map virtual_deps ~f:Lib_dep.direct)
|
||||
(Build.record_lib_deps ~kind:dep_kind
|
||||
(List.map virtual_deps ~f:Lib_dep.direct)
|
||||
>>>
|
||||
Build.fanout
|
||||
(closure t ~scope ~dep_kind libraries)
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
$ $JBUILDER external-lib-deps --root . -j1 --display quiet @install
|
||||
These are the external library dependencies in the default context:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
|
|
Loading…
Reference in New Issue