This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
We try to build a disabled library using the %{cma:..} pfrom
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.14)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= with-foo %{profile})))
|
||||
> EOF
|
||||
|
||||
$ dune build %{cma:./foo}
|
||||
File "command line", line 1, characters 0-12:
|
||||
Error: Library foo does not exist.
|
||||
[1]
|
||||
$ dune build --profile with-foo %{cma:./foo}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(executable
|
||||
(name hello)
|
||||
(enabled_if
|
||||
(= %{arch_sixtyfour} %{arch_sixtyfour})))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = Printf.printf "Hello, World!\n"
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
Testing %{arch_sixtyfour} in enabled_if
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.11)
|
||||
> EOF
|
||||
|
||||
$ dune exec -- ./hello.exe
|
||||
Hello, World!
|
||||
|
||||
Testing the version guard
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.10)
|
||||
> EOF
|
||||
|
||||
$ dune exec -- ./hello.exe
|
||||
File "dune", line 4, characters 5-22:
|
||||
4 | (= %{arch_sixtyfour} %{arch_sixtyfour})))
|
||||
^^^^^^^^^^^^^^^^^
|
||||
Error: %{arch_sixtyfour} is only available since version 3.11 of the dune
|
||||
language. Please update your dune-project file to have (lang dune 3.11).
|
||||
[1]
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "foo"
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "foo"
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
(rule
|
||||
(alias print_context)
|
||||
(action (echo %{context_name})))
|
||||
|
||||
(library
|
||||
(name bar)
|
||||
(modules bar)
|
||||
(enabled_if (= %{context_name} "not-the-context-name")))
|
||||
|
||||
(library
|
||||
(name foo)
|
||||
(modules foo)
|
||||
(enabled_if (= %{context_name} "default")))
|
||||
|
||||
(executable
|
||||
(name bar_exe)
|
||||
(modules bar_exe)
|
||||
(libraries bar))
|
||||
|
||||
(executable
|
||||
(name foo_exe)
|
||||
(modules foo_exe)
|
||||
(libraries foo))
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
Since dune 2.8 libraries `enabled_if` can use the `%{context_name}` variable.
|
||||
|
||||
dune < 2.8
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 2.7)
|
||||
> EOF
|
||||
|
||||
$ dune build bar
|
||||
File "dune", line 8, characters 16-31:
|
||||
8 | (enabled_if (= %{context_name} "not-the-context-name")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: %{context_name} is only available since version 2.8 of the dune
|
||||
language. Please update your dune-project file to have (lang dune 2.8).
|
||||
File "dune", line 13, characters 16-31:
|
||||
13 | (enabled_if (= %{context_name} "default")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: %{context_name} is only available since version 2.8 of the dune
|
||||
language. Please update your dune-project file to have (lang dune 2.8).
|
||||
[1]
|
||||
|
||||
|
||||
dune >= 2.8
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 2.8)
|
||||
> EOF
|
||||
|
||||
+ Print the context
|
||||
$ dune build @print_context
|
||||
default
|
||||
|
||||
+ Not the actual context
|
||||
$ dune exec ./bar_exe.exe
|
||||
File "dune", line 18, characters 12-15:
|
||||
18 | (libraries bar))
|
||||
^^^
|
||||
Error: Library "bar" in _build/default is hidden (unsatisfied 'enabled_if').
|
||||
-> required by _build/default/.bar_exe.eobjs/native/dune__exe__Bar_exe.cmx
|
||||
-> required by _build/default/bar_exe.exe
|
||||
[1]
|
||||
|
||||
+ The actual context
|
||||
$ dune exec ./foo_exe.exe
|
||||
bar
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
$ cat > dune <<EOF
|
||||
> (executable
|
||||
> (name test)
|
||||
> (enabled_if
|
||||
> (= %{system} unknown)))
|
||||
> (rule
|
||||
> (enabled_if
|
||||
> (= %{system} unknown))
|
||||
> (alias runtest)
|
||||
> (action
|
||||
> (run ./test.exe)))
|
||||
> EOF
|
||||
|
||||
$ cat > test.ml <<EOF
|
||||
> let () = print_string "Hello world"
|
||||
> EOF
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.13)
|
||||
> (package
|
||||
> (name pack)
|
||||
> (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
$ dune runtest
|
||||
$ dune describe 2>&1
|
||||
((root
|
||||
$TESTCASE_ROOT)
|
||||
(build_context _build/default))
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
Test enabled_if with 'env' variable.
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.14)
|
||||
> (name dune-test)
|
||||
> (package
|
||||
> (name dune-test))
|
||||
> EOF
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (executable
|
||||
> (name main)
|
||||
> (public_name dune_test)
|
||||
> (modules main)
|
||||
> (package dune-test)
|
||||
> (modes exe))
|
||||
> (executable
|
||||
> (name main_2)
|
||||
> (public_name dune_test_2)
|
||||
> (enabled_if (= enabled %{env:MYVAR=disabled}))
|
||||
> (modules main_2)
|
||||
> (package dune-test)
|
||||
> (modes exe))
|
||||
> EOF
|
||||
|
||||
$ MYVAR=disabled dune exec -- dune_test
|
||||
File "dune", line 10, characters 24-45:
|
||||
10 | (enabled_if (= enabled %{env:MYVAR=disabled}))
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: %{env:..} is only available since version 3.15 of the dune language.
|
||||
Please update your dune-project file to have (lang dune 3.15).
|
||||
[1]
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.15)
|
||||
> (name dune-test)
|
||||
> (package
|
||||
> (name dune-test))
|
||||
> EOF
|
||||
|
||||
$ cat > main.ml <<EOF
|
||||
> let () = print_string "Hello world"
|
||||
> EOF
|
||||
|
||||
$ MYVAR=disabled dune exec -- dune_test
|
||||
Hello world
|
||||
$ MYVAR=enabled dune exec -- dune_test
|
||||
File "dune", line 11, characters 10-16:
|
||||
11 | (modules main_2)
|
||||
^^^^^^
|
||||
Error: Module Main_2 doesn't exist.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Using same executable name in two contexts, where the executables are defined
|
||||
in the same dune file
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> EOF
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.13)
|
||||
>
|
||||
> (context default)
|
||||
>
|
||||
> (context
|
||||
> (default
|
||||
> (name alt-context)))
|
||||
> EOF
|
||||
$ cat > dune << EOF
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
$ cat > foo.ml <<EOF
|
||||
> let () = print_endline "foo"
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
Using same executable name in two contexts
|
||||
|
||||
$ mkdir -p a b
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> EOF
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.13)
|
||||
>
|
||||
> (context default)
|
||||
>
|
||||
> (context
|
||||
> (default
|
||||
> (name alt-context)))
|
||||
> EOF
|
||||
$ cat > a/dune << EOF
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
$ cat > a/foo.ml <<EOF
|
||||
> let () = print_endline "foo"
|
||||
> EOF
|
||||
|
||||
$ cat > b/dune << EOF
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
$ cat > b/foo.ml <<EOF
|
||||
> let () = print_endline "foo"
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executable
|
||||
(name foo)
|
||||
(enabled_if (<> %{project_root} "")))
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
The next ones use forbidden variables For dune 2.3 -> 2.5 it is a warning
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 2.3)
|
||||
> EOF
|
||||
$ dune exec ./foo.exe
|
||||
File "dune", line 3, characters 17-32:
|
||||
3 | (enabled_if (<> %{project_root} "")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Warning: Only architecture, system, model, os_type, ccomp_type, profile,
|
||||
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
|
||||
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
|
||||
bar
|
||||
|
||||
For dune >= 2.6 it is an error
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 2.6)
|
||||
> EOF
|
||||
$ dune exec ./foo.exe
|
||||
File "dune", line 3, characters 17-32:
|
||||
3 | (enabled_if (<> %{project_root} "")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: Only architecture, system, model, os_type, ccomp_type, profile,
|
||||
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
|
||||
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name foo)
|
||||
(enabled_if (= %{project_root} "")))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.3)
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
This one uses forbidden variables
|
||||
$ dune build foo
|
||||
File "dune", line 3, characters 16-31:
|
||||
3 | (enabled_if (= %{project_root} "")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: Only context_name, profile, architecture, system, model, os_type,
|
||||
ccomp_type and ocaml_version variables are allowed in this 'enabled_if'
|
||||
field. Please upgrade your dune language to at least 3.15.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(executable
|
||||
(name foo))
|
||||
|
||||
(install
|
||||
(section bin)
|
||||
(enabled_if (= %{project_root} ""))
|
||||
(files (foo.exe as foo.x)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.6)
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Tests for enabled_if in install stanza using forbidden variable.
|
||||
$ dune build @install
|
||||
File "dune", line 6, characters 16-31:
|
||||
6 | (enabled_if (= %{project_root} ""))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: Only architecture, system, model, os_type, ccomp_type, profile,
|
||||
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
|
||||
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
(dirs :standard \ forbidden_var)
|
||||
|
||||
(executable
|
||||
(name foo)
|
||||
(enabled_if true))
|
||||
|
||||
(install
|
||||
(section bin)
|
||||
(enabled_if false)
|
||||
(files (foo.exe as foo.x)))
|
||||
|
||||
(install
|
||||
(section bin)
|
||||
(enabled_if true)
|
||||
(files (foo.exe as bar.x)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.6)
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Tests for enabled_if in install stanza. Only bar.x should be installed.
|
||||
|
||||
$ dune build @install
|
||||
$ ls _build/install/default/bin
|
||||
bar.x
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Test cycles in enabled_if field of libraries
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.15)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if %{read:foo}))
|
||||
> (rule (with-stdout-to foo (echo true)))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
Error: Dependency cycle between:
|
||||
library "foo" in _build/default
|
||||
-> %{read:foo} at dune:3
|
||||
-> library "foo" in _build/default
|
||||
[1]
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Test behavior when targeting artifacts of a disabled library
|
||||
|
||||
$ mkdir -p a b
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if false))
|
||||
> EOF
|
||||
$ cat > foo.ml <<EOF
|
||||
> let x = "foo"
|
||||
> EOF
|
||||
|
||||
$ dune build %{cmo:foo}
|
||||
File "command line", line 1, characters 0-10:
|
||||
Error: Module Foo does not exist.
|
||||
[1]
|
||||
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
Using same library name in two contexts, where the libraries are defined
|
||||
in the same dune file
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> (package (name bar) (allow_empty))
|
||||
> (package (name baz) (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.13)
|
||||
>
|
||||
> (context default)
|
||||
>
|
||||
> (context
|
||||
> (default
|
||||
> (name alt-context)))
|
||||
> EOF
|
||||
$ cat > dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
$ cat > foo.ml <<EOF
|
||||
> let x = "foo"
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
||||
For public libraries
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name bar.foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name baz.foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
||||
Mixing public and private libraries
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name baz.foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
Using same library name in two contexts
|
||||
|
||||
For private libraries
|
||||
|
||||
$ mkdir -p a b
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> (package (name bar) (allow_empty))
|
||||
> (package (name baz) (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.13)
|
||||
>
|
||||
> (context default)
|
||||
>
|
||||
> (context
|
||||
> (default
|
||||
> (name alt-context)))
|
||||
> EOF
|
||||
$ cat > a/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
$ cat > a/foo.ml <<EOF
|
||||
> let x = "foo"
|
||||
> EOF
|
||||
|
||||
$ cat > b/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
$ cat > b/foo.ml <<EOF
|
||||
> let x = "foo"
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
||||
For public libraries
|
||||
|
||||
$ cat > a/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name bar.foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
|
||||
$ cat > b/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name baz.foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
||||
Mixing public and private libraries
|
||||
|
||||
$ cat > a/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
|
||||
$ cat > b/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name baz.foo)
|
||||
> (enabled_if (= %{context_name} "alt-context")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
(library
|
||||
(name allcaml)
|
||||
(modules allcaml)
|
||||
(enabled_if (> %{ocaml_version} 0.0.0)))
|
||||
|
||||
(library
|
||||
(name futurecaml)
|
||||
(modules futurecaml)
|
||||
(enabled_if (> %{ocaml_version} 500.04.0)))
|
||||
|
||||
(rule (with-stdout-to allcaml.ml (echo "")))
|
||||
|
||||
(rule (with-stdout-to futurecaml.ml (echo "")))
|
||||
|
||||
(rule (with-stdout-to main.ml (echo "")))
|
||||
|
||||
(rule (with-stdout-to main2.ml (echo "")))
|
||||
|
||||
(executable
|
||||
(name main)
|
||||
(modules main)
|
||||
(libraries allcaml))
|
||||
|
||||
(executable
|
||||
(name main2)
|
||||
(modules main2)
|
||||
(libraries futurecaml))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.5)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Since dune 2.5 libraries `enabled_if` can use the `%{ocaml_version}` variable.
|
||||
|
||||
This library is enabled (all versions)
|
||||
$ dune build main.exe
|
||||
|
||||
This one is disabled (version too low)
|
||||
$ dune build main2.exe
|
||||
File "dune", line 27, characters 12-22:
|
||||
27 | (libraries futurecaml))
|
||||
^^^^^^^^^^
|
||||
Error: Library "futurecaml" in _build/default is hidden (unsatisfied
|
||||
'enabled_if').
|
||||
-> required by _build/default/.main2.eobjs/native/dune__exe__Main2.cmx
|
||||
-> required by _build/default/main2.exe
|
||||
[1]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
(library
|
||||
(name lte414caml)
|
||||
(modules lte414caml)
|
||||
(enabled_if
|
||||
(<= %{ocaml_version} %{ocaml_version})))
|
||||
|
||||
(rule
|
||||
(with-stdout-to
|
||||
lte414caml.ml
|
||||
(echo "")))
|
||||
|
||||
(rule
|
||||
(with-stdout-to
|
||||
main.ml
|
||||
(echo "")))
|
||||
|
||||
(executable
|
||||
(name main)
|
||||
(modules main)
|
||||
(libraries lte414caml))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ dune build
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
Show that public library names can't be defined twice, even in different
|
||||
contexts
|
||||
|
||||
$ mkdir -p a b
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.13)
|
||||
> (context default)
|
||||
> (context
|
||||
> (default
|
||||
> (name melange)))
|
||||
> EOF
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.13)
|
||||
> (package (name foo) (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ cat > a/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name foo.lib)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
$ cat > a/foo.ml << EOF
|
||||
> let x = "hello"
|
||||
> EOF
|
||||
|
||||
$ cat > b/dune << EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (public_name foo.lib)
|
||||
> (enabled_if (= %{context_name} "melange")))
|
||||
> EOF
|
||||
|
||||
Without any consumers of the libraries
|
||||
|
||||
$ dune build
|
||||
|
||||
With some consumer
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (executable
|
||||
> (name main)
|
||||
> (libraries foo.lib)
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> EOF
|
||||
|
||||
$ cat > main.ml <<EOF
|
||||
> let () = print_endline Foo.x
|
||||
> EOF
|
||||
|
||||
$ dune exec ./main.exe
|
||||
hello
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
(dirs :standard \ forbidden_var)
|
||||
|
||||
(alias
|
||||
(name x)
|
||||
(action (echo "Building alias x"))
|
||||
(enabled_if false))
|
||||
|
||||
(alias
|
||||
(name y)
|
||||
(action (echo "Building alias y"))
|
||||
(enabled_if true))
|
||||
|
||||
(rule
|
||||
(targets a)
|
||||
(action (progn
|
||||
(echo "Building file a")
|
||||
(with-stdout-to a (progn))))
|
||||
(enabled_if false))
|
||||
|
||||
(rule
|
||||
(enabled_if true)
|
||||
(targets b)
|
||||
(action (progn
|
||||
(echo "Building file b")
|
||||
(with-stdout-to b (progn)))))
|
||||
|
||||
(library
|
||||
(name foo)
|
||||
(modules)
|
||||
(enabled_if false))
|
||||
|
||||
(library
|
||||
(name bar)
|
||||
(modules)
|
||||
(libraries foo))
|
||||
|
||||
(library
|
||||
(name baz)
|
||||
(modules)
|
||||
(libraries bar))
|
||||
|
||||
(rule (with-stdout-to main.ml (echo "")))
|
||||
|
||||
(executable (name main) (modes native js) (libraries baz))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.10)
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
Test that `enabled_if` fields work as expected.
|
||||
|
||||
This alias is disabled, building it should do nothing:
|
||||
$ dune build @x
|
||||
|
||||
This one is enabled:
|
||||
$ dune build @y
|
||||
Building alias y
|
||||
|
||||
This rule is disabled, trying to build a should fail:
|
||||
$ dune build a
|
||||
Error: Don't know how to build a
|
||||
Hint: did you mean b?
|
||||
[1]
|
||||
|
||||
This one is enabled:
|
||||
$ dune build b
|
||||
Building file b
|
||||
|
||||
Test the enabled_if field for libraries:
|
||||
|
||||
$ dune build foo
|
||||
Error: Don't know how to build foo
|
||||
[1]
|
||||
|
||||
$ dune build main.exe
|
||||
File "dune", line 35, characters 12-15:
|
||||
35 | (libraries foo))
|
||||
^^^
|
||||
Error: Library "foo" in _build/default is hidden (unsatisfied 'enabled_if').
|
||||
-> required by library "bar" in _build/default
|
||||
-> required by executable main in dune:44
|
||||
-> required by _build/default/main.exe
|
||||
[1]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(executable
|
||||
(name foo)
|
||||
(enabled_if (= %{context_name} "default")))
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_string "bar"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
For dune < 2.7 context_name is not allowed
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 2.6)
|
||||
> EOF
|
||||
$ dune exec ./foo.exe
|
||||
File "dune", line 3, characters 16-31:
|
||||
3 | (enabled_if (= %{context_name} "default")))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: %{context_name} is only available since version 2.7 of the dune
|
||||
language. Please update your dune-project file to have (lang dune 2.7).
|
||||
[1]
|
||||
|
||||
For dune >= 2.7 context_name allowed
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 2.7)
|
||||
> EOF
|
||||
$ dune exec ./foo.exe
|
||||
bar
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
Test %{profile} in enabled_if on executables
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.14)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (= %{profile} foo)))
|
||||
> EOF
|
||||
|
||||
$ touch foo.ml
|
||||
|
||||
$ dune build ./foo.exe
|
||||
Error: Don't know how to build ./foo.exe
|
||||
[1]
|
||||
$ dune build --profile foo ./foo.exe
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Here we demonstrate that we expand any variable in enabled_if on libraries
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.15)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (library
|
||||
> (name foo)
|
||||
> (enabled_if %{env:FOO=false}))
|
||||
> EOF
|
||||
$ dune build %{cma:./foo}
|
||||
File "command line", line 1, characters 0-12:
|
||||
Error: Library foo does not exist.
|
||||
[1]
|
||||
$ FOO=true dune build %{cma:./foo}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Printf.eprintf "Ping"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
(dirs :standard \ forbidden_var install var_context_name)
|
||||
|
||||
(executable
|
||||
(name main)
|
||||
(modules main)
|
||||
(enabled_if true))
|
||||
|
||||
(executable
|
||||
(name dis)
|
||||
(public_name dis)
|
||||
(modules dis)
|
||||
(enabled_if false))
|
||||
|
||||
; Github3494 : Enabled if with allowed variable
|
||||
; in dune 2.3 to 2.5 should not raise an error
|
||||
(executable
|
||||
(name foo)
|
||||
(modules foo)
|
||||
(enabled_if (<> %{os_type} "")))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 2.3)
|
||||
|
|
@ -0,0 +1 @@
|
|||
Printf.eprintf "Ping"
|
||||
|
|
@ -0,0 +1 @@
|
|||
Printf.eprintf "Pong"
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
Test that `enabled_if` fields work as expected for executables.
|
||||
Since 2.3.
|
||||
|
||||
This executable is disabled, any attempt to build it should fail:
|
||||
$ dune build dis.exe
|
||||
Error: Don't know how to build dis.exe
|
||||
[1]
|
||||
$ dune exec ./dis.exe
|
||||
Error: Program './dis.exe' not found!
|
||||
[1]
|
||||
|
||||
This one is enabled
|
||||
$ dune exec ./main.exe
|
||||
Pong
|
||||
|
||||
Installing should silently ignore disabled executables
|
||||
$ dune build @install
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
Demonstrate errors coming from a different context:
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.15)
|
||||
> (package (name bar) (allow_empty))
|
||||
> (package (name baz) (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ cat > dune-workspace << EOF
|
||||
> (lang dune 3.15)
|
||||
>
|
||||
> (context default)
|
||||
>
|
||||
> (context
|
||||
> (default
|
||||
> (name other)))
|
||||
> EOF
|
||||
$ cat > dune << EOF
|
||||
> (rule
|
||||
> (action (write-file foo bar))
|
||||
> (enabled_if (= %{context_name} "default")))
|
||||
> (rule
|
||||
> (targets foo)
|
||||
> (action (system "exit 1"))
|
||||
> (enabled_if (<> %{context_name} "default")))
|
||||
> EOF
|
||||
|
||||
$ cat > foo.ml <<EOF
|
||||
> let t = Str.regexp
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
File "dune", lines 4-7, characters 0-94:
|
||||
4 | (rule
|
||||
5 | (targets foo)
|
||||
6 | (action (system "exit 1"))
|
||||
7 | (enabled_if (<> %{context_name} "default")))
|
||||
Context: other
|
||||
Command exited with code 1.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
For dune >= 3.2, negating expressions is allowed
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.2)
|
||||
> EOF
|
||||
$ cat > dune <<EOF
|
||||
> (executable
|
||||
> (name foo)
|
||||
> (enabled_if (not false)))
|
||||
> EOF
|
||||
$ cat > foo.ml <<EOF
|
||||
> print_endline "runs";;
|
||||
> EOF
|
||||
$ dune exec ./foo.exe
|
||||
runs
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
After the parsing non-ascii characters could be compared through expressions.
|
||||
Linked to the issue #9728
|
||||
|
||||
$ echo '(lang dune 3.0)' > dune-project
|
||||
$ cat >dune <<"EOF"
|
||||
> (rule
|
||||
> (alias default)
|
||||
> (enabled_if (= "É" "\195\137"))
|
||||
> (action (echo "Hello, world!\n")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
Hello, world!
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
Check that %{read:...} is allowed in enabled_if from Dune 3.0
|
||||
|
||||
Doesn't work with < 3.0:
|
||||
|
||||
$ echo '(lang dune 2.9)' > dune-project
|
||||
$ cat >dune <<"EOF"
|
||||
> (rule
|
||||
> (alias default)
|
||||
> (enabled_if %{read:x/x})
|
||||
> (action (echo "Hello, world!\n")))
|
||||
> EOF
|
||||
|
||||
We have to use a sub-directory to avoid a circular dependency. The
|
||||
circular dependency exist because "enabled_if" fields are evaluated at
|
||||
"rule production time" rather than "rule execution time".
|
||||
|
||||
$ mkdir x
|
||||
$ cat >x/dune <<"EOF"
|
||||
> (rule
|
||||
> (with-stdout-to x (system "printf true")))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
File "dune", line 3, characters 13-24:
|
||||
3 | (enabled_if %{read:x/x})
|
||||
^^^^^^^^^^^
|
||||
Error: %{read:..} isn't allowed in this position.
|
||||
[1]
|
||||
|
||||
But works with 3.0:
|
||||
|
||||
$ echo '(lang dune 3.0)' > dune-project
|
||||
$ dune build
|
||||
Hello, world!
|
||||
Loading…
Add table
Add a link
Reference in a new issue