This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,73 @@
Test dependency on installed package
$ mkdir a b prefix
$ cat > a/dune-project <<EOF
> (lang dune 3.7)
> (package (name a))
> (using experimental_building_ocaml_compiler_with_dune 0.1)
> EOF
$ cat > a/dune <<EOF
> (library
> (name a)
> (public_name a)
> (stdlib
> (modules_before_stdlib CamlinternalFormatBasics)
> (internal_modules Camlinternal*)))
> EOF
$ cat > a/foo.ml <<EOF
> let x = "foo"
> EOF
$ cat > a/a.ml <<EOF
> module Foo = A__Foo
> EOF
$ dune build --root a
Entering directory 'a'
Leaving directory 'a'
$ dune install --root a --prefix $PWD/prefix --display short
Installing $TESTCASE_ROOT/prefix/lib/a/META
Installing $TESTCASE_ROOT/prefix/lib/a/a.a
Installing $TESTCASE_ROOT/prefix/lib/a/a.cma
Installing $TESTCASE_ROOT/prefix/lib/a/a.cmi
Installing $TESTCASE_ROOT/prefix/lib/a/a.cmt
Installing $TESTCASE_ROOT/prefix/lib/a/a.cmx
Installing $TESTCASE_ROOT/prefix/lib/a/a.cmxa
Installing $TESTCASE_ROOT/prefix/lib/a/a.ml
Installing $TESTCASE_ROOT/prefix/lib/a/a__Foo.cmi
Installing $TESTCASE_ROOT/prefix/lib/a/a__Foo.cmt
Installing $TESTCASE_ROOT/prefix/lib/a/a__Foo.cmx
Installing $TESTCASE_ROOT/prefix/lib/a/dune-package
Installing $TESTCASE_ROOT/prefix/lib/a/foo.ml
Installing $TESTCASE_ROOT/prefix/lib/a/a.cmxs
$ cat >b/dune-project <<EOF
> (lang dune 3.7)
> (package (name b))
> EOF
$ cat > b/dune <<EOF
> (library
> (public_name b)
> (libraries a))
> EOF
$ cat > b/bar.ml <<EOF
> let x = A.Foo.x
> EOF
$ OCAMLPATH=$PWD/prefix/lib/:$OCAMLPATH dune build --root b @install --display=short
Entering directory 'b'
ocamlc .b.objs/byte/b.{cmi,cmo,cmt}
ocamldep .b.objs/b__Bar.impl.d
ocamlopt .b.objs/native/b.{cmx,o}
ocamlc .b.objs/byte/b__Bar.{cmi,cmo,cmt}
ocamlopt .b.objs/native/b__Bar.{cmx,o}
ocamlc b.cma
ocamlopt b.{a,cmxa}
ocamlopt b.cmxs
Leaving directory 'b'

View file

@ -0,0 +1,35 @@
Compile a library with `(stdlib ..)` and multiple globs for internal_modules
$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using experimental_building_ocaml_compiler_with_dune 0.1)
> EOF
$ mkdir stdlib
$ cat > stdlib/other.ml <<EOF
> let other () = Mystdlib.defined_in_stdlib
> EOF
$ cat > stdlib/one_module.ml <<EOF
> let foo = "foo"
> EOF
$ cat > stdlib/mystdlib.ml <<EOF
> let defined_in_stdlib = "defined"
> module One_module = One_module
> module Other = Other
> EOF
$ cat >stdlib/dune <<EOF
> (library
> (name mystdlib)
> (stdlib
> (internal_modules one* other)))
> EOF
Works when setting the correct version
$ dune build
$ find _build/default/stdlib -iname '*.cmi' | sort;
_build/default/stdlib/.mystdlib.objs/byte/mystdlib.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__One_module.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__Other.cmi

View file

@ -0,0 +1,45 @@
Compile a library with `(stdlib ..)` and wrapped settings
$ cat > dune-project <<EOF
> (lang dune 3.7)
> (using experimental_building_ocaml_compiler_with_dune 0.1)
> EOF
$ mkdir stdlib
$ runtest() {
> cat >stdlib/dune <<EOF
> (library
> (name mystdlib)
> (wrapped $1)
> (stdlib
> (internal_modules Camlinternal*)))
> EOF
> dune build
> find _build/default/stdlib -iname '*.cmi' | sort;
> }
$ cat > stdlib/other.ml <<EOF
> let other () = Mystdlib.defined_in_stdlib
> EOF
$ cat > stdlib/one_module.ml <<EOF
> let foo = "foo"
> EOF
$ cat > stdlib/mystdlib.ml <<EOF
> let defined_in_stdlib = "defined"
> module One_module = One_module
> module Other = Other
> EOF
First we test wrapped:
$ runtest "true"
_build/default/stdlib/.mystdlib.objs/byte/mystdlib.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__One_module.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__Other.cmi
And now unwrapped:
$ runtest "false"
_build/default/stdlib/.mystdlib.objs/byte/mystdlib.cmi
_build/default/stdlib/.mystdlib.objs/byte/one_module.cmi
_build/default/stdlib/.mystdlib.objs/byte/other.cmi

View file

@ -0,0 +1,4 @@
(lang dune 1.3)
(using experimental_building_ocaml_compiler_with_dune 0.1)
(package (name stdlib))

View file

@ -0,0 +1,5 @@
Build stdlib with stdlib.ml
$ dune build @all
$ (cd _build/default/src && ls *.cma)
stdlib.cma

View file

@ -0,0 +1,7 @@
(library
(public_name stdlib)
(stdlib
(modules_before_stdlib CamlinternalFormatBasics)
(exit_module std_exit)
(internal_modules Camlinternal*))
(preprocess (action (run cat %{input-file}))))

View file

@ -0,0 +1,3 @@
let append = list_append
let x = Stdlib.list_append

View file

@ -0,0 +1,8 @@
let rec list_append l1 l2 =
match l1 with
[] -> l2
| hd :: tl -> hd :: (list_append tl l2)
type fmt = CamlinternalFormatBasics.fmt = Fmt
module List = Stdlib__List

View file

@ -0,0 +1,18 @@
$ cat > dune-project << EOF
> (lang dune 3.7)
> (using experimental_building_ocaml_compiler_with_dune 0.1)
> EOF
$ cat > dune << EOF
> (library
> (name mystdlib)
> (stdlib)
> (flags :standard -w -8))
> EOF
$ cat > mystdlib.ml << EOF
> (* This triggers warning 8 *)
> let None = None
> EOF
$ dune build