Skip to content

Commit

Permalink
simplify to_modules handling
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Chávarri <javier.chavarri@gmail.com>
  • Loading branch information
jchavarri committed Mar 3, 2023
1 parent 559e885 commit 81d3339
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/dune_rules/dep_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ let deps_of_module ({ modules; _ } as md) ~ml_kind m =
let+ deps = Ocamldep.deps_of md ~ml_kind m in
let open Action_builder.O in
let+ deps = deps in
let deps = List.map ~f:Modules.Sourced_module.to_module deps in
match Modules.alias_for modules m with
| [] -> deps
| aliases -> aliases @ deps)
Expand Down Expand Up @@ -94,11 +93,7 @@ let deps_of_vlib_module ({ obj_dir; vimpl; dir; sctx; _ } as md) ~ml_kind
let+ () =
Super_context.add_rule sctx ~dir (Action_builder.symlink ~src ~dst)
in
let open Action_builder.O in
let+ deps =
Ocamldep.read_deps_of ~obj_dir:vlib_obj_dir ~modules ~ml_kind m
in
List.map ~f:Modules.Sourced_module.to_module deps
Ocamldep.read_deps_of ~obj_dir:vlib_obj_dir ~modules ~ml_kind m

let rec deps_of md ~ml_kind (m : Modules.Sourced_module.t) =
let is_alias =
Expand Down
3 changes: 2 additions & 1 deletion src/dune_rules/ocamldep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ let parse_compilation_units ~modules =
let obj_map = Modules.obj_map modules in
List.filter_map ~f:(fun m ->
let obj_name = Module_name.Unique.of_string m in
Module_name.Unique.Map.find obj_map obj_name)
Module_name.Unique.Map.find obj_map obj_name
|> Option.map ~f:Modules.Sourced_module.to_module)

let parse_deps_exn ~file lines =
let invalid () =
Expand Down
4 changes: 2 additions & 2 deletions src/dune_rules/ocamldep.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ val deps_of :
Modules_data.t
-> ml_kind:Ml_kind.t
-> Module.t
-> Modules.Sourced_module.t list Action_builder.t Memo.t
-> Module.t list Action_builder.t Memo.t

val read_deps_of :
obj_dir:Path.Build.t Obj_dir.t
-> modules:Modules.t
-> ml_kind:Ml_kind.t
-> Module.t
-> Modules.Sourced_module.t list Action_builder.t
-> Module.t list Action_builder.t

(** [read_immediate_deps_of ~obj_dir ~modules ~ml_kind unit] returns the
immediate dependencies found in the modules of [modules] for the file with
Expand Down

0 comments on commit 81d3339

Please sign in to comment.