Skip to content

Commit

Permalink
Add re_exports to requires
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Sep 18, 2019
1 parent fb5e551 commit ee0852f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/dune/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1171,11 +1171,17 @@ end = struct
~f:(fun (acc_res, acc_selects, acc_re_exports) dep ->
match (dep : Lib_dep.t) with
| Re_export (loc, name) ->
let lib = resolve_dep db name ~allow_private_deps ~loc ~stack in
let acc_re_exports =
let* lib = resolve_dep db name ~allow_private_deps ~loc ~stack in
let+ acc_re_exports = acc_re_exports in
let+ lib = lib
and+ acc_re_exports = acc_re_exports in
lib :: acc_re_exports
in
let acc_res =
let+ lib = lib
and+ acc_res = acc_res in
lib :: acc_res
in
(acc_res, acc_selects, acc_re_exports)
| Direct (loc, name) ->
let res =
Expand Down Expand Up @@ -1810,10 +1816,8 @@ module Meta = struct
end

let to_dune_lib ({ info; _ } as lib) ~modules ~foreign_objects ~dir =
let add_loc =
let loc = Lib_info.loc info in
List.map ~f:(fun x -> (loc, x.name))
in
let loc = Lib_info.loc info in
let add_loc = List.map ~f:(fun x -> (loc, x.name)) in
let obj_dir =
match Obj_dir.to_local (obj_dir lib) with
| None -> assert false
Expand Down Expand Up @@ -1849,12 +1853,13 @@ let to_dune_lib ({ info; _ } as lib) ~modules ~foreign_objects ~dir =
let sub_systems = Sub_system.public_info lib in
let* main_module_name = main_module_name lib in
let* requires = lib.requires in
let requires = add_loc requires in
let+ re_exports = lib.re_exports in
let re_exports = add_loc re_exports in
let requires =
List.map ~f:Lib_dep.direct requires
@ List.map ~f:Lib_dep.re_export re_exports
List.map requires ~f:(fun lib ->
if List.exists re_exports ~f:(fun r -> r = lib) then
Lib_dep.Re_export (loc, lib.name)
else
Direct (loc, lib.name))
in
let info =
Lib_info.for_dune_package info ~ppx_runtime_deps ~requires ~foreign_objects
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/re-exported-deps/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ transtive deps expressed in the dune-package
(archives (byte aaa/aaa.cma) (native aaa/aaa.cmxa))
(plugins (byte aaa/aaa.cma) (native aaa/aaa.cmxs))
(foreign_archives (native aaa/aaa$ext_lib))
(requires (re_export pkg.bbb))
(requires pkg.ccc (re_export pkg.bbb))
(main_module_name Aaa)
(modes byte native)
(modules (singleton (name Aaa) (obj_name aaa) (visibility public) (impl))))
Expand Down

0 comments on commit ee0852f

Please sign in to comment.