Skip to content

Commit bef411b

Browse files
committed
testing unwrapped libs with instantiated deps
Signed-off-by: ArthurW <arthur@tarides.com>
1 parent 1047cec commit bef411b

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/dune_rules/ml_sources.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ let make_lib_modules
403403
kind, main_module_name, wrapped
404404
in
405405
let has_instances = has_instances lib.buildable in
406-
let wrapped = if has_instances then Wrapped.Simple true else wrapped in
407406
let open Memo.O in
408407
let* sources, modules =
409408
let { Buildable.loc = stanza_loc; modules = modules_settings; _ } = lib.buildable in

src/dune_rules/root_module.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ let entries sctx ~requires_compile =
1616
Action_builder.List.map requires ~f:(fun lib ->
1717
Action_builder.of_memo (entry_module_names sctx lib) >>= Resolve.read)
1818
in
19-
Action_builder.return (List.concat l)
19+
Action_builder.return (List.concat l |> List.sort_uniq ~compare:Module_name.compare)
2020
;;

test/blackbox-tests/test-cases/oxcaml/unwrapped-with-instantiate.t

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,29 @@ Testing that it also works with another layer of library:
135135
$ dune exec ./bin/bin.exe
136136
lib:helper:IMPL
137137
lib2:lib:helper:IMPL helper:IMPL
138+
139+
TODO: An unwrapped library currently has to instantiate the functors manually,
140+
because we don't have a file where to put the instantiations:
141+
142+
$ mkdir unwrap_lib
143+
$ cat > unwrap_lib/unwrap_a.ml <<EOF
144+
> module Lib = Lib(Param)(Impl) [@jane.non_erasable.instances]
145+
> let a () = "a:" ^ Lib.v ()
146+
> EOF
147+
$ echo 'let b () = "b:" ^ Unwrap_a.a ()' > unwrap_lib/unwrap_b.ml
148+
$ cat > unwrap_lib/dune <<EOF
149+
> (library
150+
> (name unwrap_lib)
151+
> (wrapped false)
152+
> (flags "-w" "-53") ; ignore misplaced-attribute warning
153+
> (libraries (lib impl)))
154+
> EOF
155+
156+
$ echo 'let () = print_endline (Unwrap_a.a () ^ "," ^ Unwrap_b.b ())' > bin/bin.ml
157+
$ cat > bin/dune <<EOF
158+
> (executable (name bin) (libraries unwrap_lib))
159+
> EOF
160+
161+
$ dune exec ./bin/bin.exe
162+
a:lib:helper:IMPL,b:a:lib:helper:IMPL
163+

0 commit comments

Comments
 (0)