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,3 @@
(library (name foo))
(include_subdirs unqualified)

View file

@ -0,0 +1,7 @@
$ dune build
File "dune", line 1, characters 0-0:
Error: Module "X" appears in several directories:
- _build/default/a
- _build/default/b
This is not allowed, please rename one of them.
[1]

View file

@ -0,0 +1,2 @@
(include_subdirs unqualified)
(include_subdirs unqualified)

View file

@ -0,0 +1,6 @@
$ dune build
File "dune", line 2, characters 0-29:
2 | (include_subdirs unqualified)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The 'include_subdirs' stanza cannot appear more than once
[1]

View file

@ -0,0 +1,7 @@
(executable
(name main)
(libraries foo))
(alias
(name default)
(action (run ./main.exe)))

View file

@ -0,0 +1 @@
let () = print_endline Foo.x

View file

@ -0,0 +1,8 @@
$ dune build
File "src/gen/dune", line 1, characters 0-23:
1 | (executable (name gen))
^^^^^^^^^^^^^^^^^^^^^^^
Error: This stanza is not allowed in a sub-directory of directory with
(include_subdirs unqualified).
Hint: add (include_subdirs no) to this file.
[1]

View file

@ -0,0 +1,5 @@
(library (name foo))
(rule (with-stdout-to generated.ml (run gen/gen.exe)))
(include_subdirs unqualified)

View file

@ -0,0 +1 @@
let x = Generated.x ^ Blah.x

View file

@ -0,0 +1 @@
(executable (name gen))

View file

@ -0,0 +1 @@
let x = print_endline {|let x = "Hello, "|}

View file

@ -0,0 +1,39 @@
include_subdirs should not recurse past project root
$ cat >dune-project <<EOF
> (lang dune 3.1)
> EOF
$ cat >dune <<EOF
> (include_subdirs unqualified)
> (executable
> (name foo))
> EOF
$ cat >foo.ml <<EOF
> print_endline Bar.v;;
> EOF
$ mkdir subproj
$ cat >subproj/bar.ml <<EOF
> let v = "unusable"
> EOF
Works if [subproj] is just a separate directory and not a separate project.
$ dune exec ./foo.exe
unusable
$ cat >subproj/dune-project <<EOF
> (lang dune 3.1)
> EOF
Doesn't work with when we make [subproj] a separate project with a dune-project
file, since include_subdirs is stopped.
$ dune exec ./foo.exe
File "foo.ml", line 1, characters 14-19:
1 | print_endline Bar.v;;
^^^^^
Error: Unbound module Bar
[1]

View file

@ -0,0 +1,3 @@
(alias
(name default)
(action (run src/foo.exe)))

View file

@ -0,0 +1,5 @@
Simple test with a multi dir exe
--------------------------------
$ dune build
Hello, world!

View file

@ -0,0 +1,2 @@
(executable (name foo))
(include_subdirs unqualified)

View file

@ -0,0 +1 @@
let () = prerr_endline X.x

View file

@ -0,0 +1,7 @@
(executable
(name main)
(libraries foo))
(alias
(name default)
(action (run ./main.exe)))

View file

@ -0,0 +1 @@
let () = print_endline Foo.x

View file

@ -0,0 +1,5 @@
Test that include_subdirs stop the recursion
--------------------------------------------
$ dune build
Hello, world!

View file

@ -0,0 +1,5 @@
(library (name foo))
(rule (with-stdout-to generated.ml (run gen/gen.exe)))
(include_subdirs unqualified)

View file

@ -0,0 +1 @@
let x = Generated.x ^ Blah.x

View file

@ -0,0 +1,2 @@
(executable (name gen))
(include_subdirs no)

View file

@ -0,0 +1 @@
let x = print_endline {|let x = "Hello, "|}

View file

@ -0,0 +1,11 @@
(test
(name main)
(libraries foo)
(modules main))
(library
(name foo)
(modules foo)
(c_names stub1 sub/stub2))
(include_subdirs unqualified)

View file

@ -0,0 +1,2 @@
external x : unit -> string = "dune_test_x"
external y : unit -> string = "dune_test_y"

View file

@ -0,0 +1,2 @@
#include <caml/mlvalues.h>
#include <caml/alloc.h>

View file

@ -0,0 +1 @@
let () = print_endline (Foo.x () ^ Foo.y ())

View file

@ -0,0 +1,11 @@
Test with C stubs in sub-directories
------------------------------------
$ dune runtest
File "dune", line 9, characters 16-25:
9 | (c_names stub1 sub/stub2))
^^^^^^^^^
Error: Relative part of stub is not necessary and should be removed. To
include sources in subdirectories, use the (include_subdirs ...) stanza.
[1]

View file

@ -0,0 +1,6 @@
#include "include/dune_test.h"
CAMLprim value dune_test_x()
{
return caml_copy_string("Hello,");
}

View file

@ -0,0 +1,6 @@
#include "../include/dune_test.h"
CAMLprim value dune_test_y()
{
return caml_copy_string(" world!");
}

View file

@ -0,0 +1,10 @@
(executable
(name main)
(modules main))
(library
(name foo)
(preprocess (action (run ./main.exe %{input-file})))
(modules foo))
(include_subdirs unqualified)

View file

@ -0,0 +1,2 @@
let () =
print_endline "print_endline \"foo\""

View file

@ -0,0 +1,5 @@
Test for (include_subdir unqualified) with (preprocess (action ...))
--------------------------------------------------------------------
$ dune exec ./main.exe @all
print_endline "foo"