This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
(library
|
||||
(name impl_intf_only)
|
||||
(modules :standard \ run)
|
||||
(implements vlib.intfonly))
|
||||
|
||||
(executable
|
||||
(name run)
|
||||
(libraries impl_intf_only)
|
||||
(modules run))
|
||||
|
||||
(alias
|
||||
(name default)
|
||||
(action (run ./run.exe)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.7)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let () =
|
||||
Printf.printf "magic number: %d\n" (Vlib_intfonly.implme ())
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module X : Foo.S = struct
|
||||
let mli_only = print_endline
|
||||
end
|
||||
|
||||
let implme () = X.mli_only "implemented mli only"; 42
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
(library
|
||||
(name impl_native_only)
|
||||
(modules :standard \ run)
|
||||
(implements vlib.nativeonly))
|
||||
|
||||
(executable
|
||||
(name run)
|
||||
(libraries impl_native_only)
|
||||
(modules run))
|
||||
|
||||
(alias
|
||||
(name default)
|
||||
(action (run ./run.exe)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.7)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let () =
|
||||
Vlib_native_only.run_native ()
|
||||
|
|
@ -0,0 +1 @@
|
|||
let v = "implement virtual module"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
(library
|
||||
(name impl_privatemodule)
|
||||
(modules :standard \ run)
|
||||
(implements vlib.privatemodule))
|
||||
|
||||
(executable
|
||||
(name run)
|
||||
(libraries impl_privatemodule)
|
||||
(modules run))
|
||||
|
||||
(alias
|
||||
(name default)
|
||||
(action (run ./run.exe)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.7)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let () =
|
||||
Vlib_privatemodule.run ()
|
||||
|
|
@ -0,0 +1 @@
|
|||
let name = "implement virtual module"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(executable
|
||||
(name test)
|
||||
(libraries impl))
|
||||
|
||||
(alias
|
||||
(name default)
|
||||
(action (run ./test.exe)))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(lang dune 1.7)
|
||||
|
||||
(package (name dune-vlib))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name impl)
|
||||
(public_name dune-vlib.impl)
|
||||
(implements vlib))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let run () =
|
||||
Bar.bar ();
|
||||
print_endline "Foo.run implemented"
|
||||
|
|
@ -0,0 +1 @@
|
|||
Vlib.Foo.run ();;
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
Test that we can implement external libraries.
|
||||
|
||||
First we create an external library
|
||||
$ dune build --root vlib @install
|
||||
Entering directory 'vlib'
|
||||
Leaving directory 'vlib'
|
||||
|
||||
Then we make sure that we can implement it
|
||||
$ env OCAMLPATH=vlib/_build/install/default/lib dune build @default @install --root impl
|
||||
Entering directory 'impl'
|
||||
bar from vlib
|
||||
Foo.run implemented
|
||||
Leaving directory 'impl'
|
||||
|
||||
Make sure that we can also implement native only variants
|
||||
$ env OCAMLPATH=vlib/_build/install/default/lib dune build --root impl-native-only --debug-dependency-path
|
||||
Entering directory 'impl-native-only'
|
||||
implement virtual module
|
||||
Leaving directory 'impl-native-only'
|
||||
|
||||
We can implement external variants with mli only modules
|
||||
$ env OCAMLPATH=vlib/_build/install/default/lib dune build --root impl-intf-only --debug-dependency-path
|
||||
Entering directory 'impl-intf-only'
|
||||
implemented mli only
|
||||
magic number: 42
|
||||
Leaving directory 'impl-intf-only'
|
||||
|
||||
Implement external virtual libraries with private modules
|
||||
$ env OCAMLPATH=vlib/_build/install/default/lib dune build --root impl-private-module --debug-dependency-path
|
||||
Entering directory 'impl-private-module'
|
||||
Name: implement virtual module. Magic number: 42
|
||||
Leaving directory 'impl-private-module'
|
||||
|
||||
Now we test the following use case:
|
||||
- A virtual library and its implementation are installed
|
||||
- We are able to use the implementation as an external dependency in a project
|
||||
Currently, dune's behavior is broken in this situation. The virtual library's
|
||||
modules remain hidden.
|
||||
$ export OCAMLPATH=$PWD/vlib/_build/install/default/lib:$PWD/impl/_build/install/default/lib
|
||||
$ mkdir use-external-impl && cd use-external-impl
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.0)
|
||||
> EOF
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (name blah)
|
||||
> (libraries dune-vlib.impl))
|
||||
> EOF
|
||||
$ cat >blah.ml <<EOF
|
||||
> Vlib.Foo.run ()
|
||||
> EOF
|
||||
$ dune exec ./blah.exe
|
||||
bar from vlib
|
||||
Foo.run implemented
|
||||
$ cd ..
|
||||
|
|
@ -0,0 +1 @@
|
|||
let bar () = print_endline "bar from vlib"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(public_name vlib)
|
||||
(virtual_modules foo))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.7)
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name vlib_intfonly)
|
||||
(public_name vlib.intfonly)
|
||||
(modules_without_implementation foo)
|
||||
(virtual_modules vlib_intfonly))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module type S = sig
|
||||
val mli_only : string -> unit
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
val implme : unit -> int
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name vlib_native_only)
|
||||
(public_name vlib.nativeonly)
|
||||
(virtual_modules virt_module)
|
||||
(modes native))
|
||||
|
|
@ -0,0 +1 @@
|
|||
val v : string
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
let run_native () =
|
||||
print_endline Virt_module.v
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run_native : unit -> unit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name vlib_privatemodule)
|
||||
(public_name vlib.privatemodule)
|
||||
(virtual_modules virt_module)
|
||||
(private_modules privatemodule))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let number = 42
|
||||
|
|
@ -0,0 +1 @@
|
|||
val name : string
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
let run () =
|
||||
Printf.printf "Name: %s. Magic number: %d\n"
|
||||
Virt_module.name Privatemodule.number
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
Loading…
Add table
Add a link
Reference in a new issue