This commit is contained in:
Jérémie Dimino 2018-02-13 15:56:59 +00:00 committed by GitHub
parent 473b8d11ed
commit 8e27f1966d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 29 deletions

View File

@ -88,7 +88,7 @@ let static_deps t ~all_targets =
loop (Build.repr t) { rule_deps = Pset.empty; action_deps = Pset.empty } loop (Build.repr t) { rule_deps = Pset.empty; action_deps = Pset.empty }
let lib_deps = 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 -> = fun t acc ->
match t with match t with
| Arr _ -> acc | Arr _ -> acc
@ -105,17 +105,13 @@ let lib_deps =
| Dyn_paths t -> loop t acc | Dyn_paths t -> loop t acc
| Contents _ -> acc | Contents _ -> acc
| Lines_of _ -> acc | Lines_of _ -> acc
| Record_lib_deps deps -> | Record_lib_deps deps -> Build.merge_lib_deps deps acc
begin match acc with
| None -> Some deps
| Some acc -> Some (Build.merge_lib_deps deps acc)
end
| Fail _ -> acc | Fail _ -> acc
| If_file_exists (_, state) -> | If_file_exists (_, state) ->
loop (get_if_file_exists_exn state) acc loop (get_if_file_exists_exn state) acc
| Memo m -> loop m.t acc | Memo m -> loop m.t acc
in in
fun t -> loop (Build.repr t) None fun t -> loop (Build.repr t) String_map.empty
let targets = let targets =
let rec loop : type a b. (a, b) t -> Target.t list -> Target.t list = fun t acc -> let rec loop : type a b. (a, b) t -> Target.t list -> Target.t list = fun t acc ->

View File

@ -47,7 +47,7 @@ val static_deps
val lib_deps val lib_deps
: (_, _) Build.t : (_, _) Build.t
-> Build.lib_deps option -> Build.lib_deps
val targets val targets
: (_, _) Build.t : (_, _) Build.t

View File

@ -1165,7 +1165,7 @@ module Ir_set = Set.Make(Internal_rule)
let rules_for_files t paths = let rules_for_files t paths =
List.filter_map paths ~f:(fun path -> 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 match Hashtbl.find t.files path with
| None -> None | None -> None
| Some (File_spec.T { rule; _ }) -> Some rule) | 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 let targets = static_deps_of_request t request in
List.fold_left (rules_for_targets t targets) ~init:Pmap.empty List.fold_left (rules_for_targets t targets) ~init:Pmap.empty
~f:(fun acc (rule : Internal_rule.t) -> ~f:(fun acc (rule : Internal_rule.t) ->
let lib_deps = let deps = Build_interpret.lib_deps rule.build in
match Build_interpret.lib_deps rule.build with if String_map.is_empty deps then
| None -> Pmap.empty acc
| Some deps -> Pmap.singleton rule.dir deps in else
Pmap.merge acc lib_deps ~f:(fun _ a b -> let deps =
match a, b with match Pmap.find rule.dir acc with
| None, None -> None | None -> deps
| Some a, None -> Some a | Some deps' -> Build.merge_lib_deps deps deps'
| None, Some b -> Some b in
| Some a, Some b -> Some (Build.merge_lib_deps a b))) Pmap.add acc ~key:rule.dir ~data:deps)
let all_lib_deps_by_context t ~request = let all_lib_deps_by_context t ~request =
let targets = static_deps_of_request t request in let targets = static_deps_of_request t request in
rules_for_targets t targets let rules = rules_for_targets t targets in
|> List.fold_left ~init:[] ~f:(fun acc (rule : Internal_rule.t) -> List.fold_left rules ~init:[] ~f:(fun acc (rule : Internal_rule.t) ->
let lib_deps = let deps = Build_interpret.lib_deps rule.build in
match Build_interpret.lib_deps rule.build with if String_map.is_empty deps then
| None -> Pmap.empty acc
| Some deps -> Pmap.singleton rule.dir deps in else
Path.Map.fold lib_deps ~init:acc ~f:(fun ~key:path ~data:lib_deps acc -> match Path.extract_build_context rule.dir with
match Path.extract_build_context path with
| None -> acc | None -> acc
| Some (context, _) -> (context, lib_deps) :: acc)) | Some (context, _) -> (context, deps) :: acc)
|> String_map.of_alist_multi |> String_map.of_alist_multi
|> String_map.map ~f:(function |> String_map.map ~f:(function
| [] -> String_map.empty | [] -> String_map.empty

View File

@ -303,7 +303,8 @@ module Libs = struct
in in
let vrequires = vrequires t ~dir ~item in let vrequires = vrequires t ~dir ~item in
add_rule t 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 Build.fanout
(closure t ~scope ~dep_kind libraries) (closure t ~scope ~dep_kind libraries)

View File

@ -1 +1,5 @@
$ $JBUILDER external-lib-deps --root . -j1 --display quiet @install $ $JBUILDER external-lib-deps --root . -j1 --display quiet @install
These are the external library dependencies in the default context:
- a
- b
- c