Update documentation for new binding names

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-10 01:14:02 +07:00
parent 77800e669e
commit 03f134567d
2 changed files with 23 additions and 24 deletions

View File

@ -22,7 +22,7 @@ Stanzas
(rule (rule
(targets foo.ml) (targets foo.ml)
(deps generator/gen.exe) (deps generator/gen.exe)
(action (run %{<} -o %{@}))) (action (run %{deps} -o %{targets})))
The following sections describe the available stanzas and their meaning. The following sections describe the available stanzas and their meaning.
@ -459,7 +459,7 @@ For instance:
(rule (rule
(targets b (targets b
(deps a (deps a
(action (copy %{<} %{@}))))) (action (copy %{deps} %{targets})))))
In this example it is obvious by inspecting the action what the In this example it is obvious by inspecting the action what the
dependencies and targets are. When this is the case you can use the dependencies and targets are. When this is the case you can use the
@ -495,7 +495,7 @@ ocamllex
(rule (rule
(targets <name>.ml) (targets <name>.ml)
(deps <name>.mll) (deps <name>.mll)
(action (chdir %{root} (run %{bin:ocamllex} -q -o %{<})))) (action (chdir %{root} (run %{bin:ocamllex} -q -o %{targets} %{deps}))))
To use a different rule mode, use the long form: To use a different rule mode, use the long form:
@ -515,7 +515,7 @@ ocamlyacc
(rule (rule
(targets <name>.ml <name>.mli) (targets <name>.ml <name>.mli)
(deps <name>.mly) (deps <name>.mly)
(action (chdir %{root} (run %{bin:ocamlyacc} %{<})))) (action (chdir %{root} (run %{bin:ocamlyacc} %{deps}))))
To use a different rule mode, use the long form: To use a different rule mode, use the long form:
@ -866,9 +866,8 @@ Dune supports the following variables:
In addition, ``(action ...)`` fields support the following special variables: In addition, ``(action ...)`` fields support the following special variables:
- ``@`` expands to the list of target - ``targets`` expands to the list of target
- ``<`` expands to the first dependency, or the empty string if there are no - ``deps`` expands to the list of dependencies
dependencies
- ``^`` expands to the list of dependencies, separated by spaces - ``^`` expands to the list of dependencies, separated by spaces
- ``dep:<path>`` expands to ``<path>`` (and adds ``<path>`` as a dependency of - ``dep:<path>`` expands to ``<path>`` (and adds ``<path>`` as a dependency of
the action) the action)
@ -909,7 +908,7 @@ In addition, ``(action ...)`` fields support the following special variables:
The ``%{<kind>:...}`` forms are what allows you to write custom rules that work The ``%{<kind>:...}`` forms are what allows you to write custom rules that work
transparently whether things are installed or not. transparently whether things are installed or not.
Note that aliases are ignored by both ``%{<}`` and ``%{^}``. Note that aliases are ignored by ``%{deps}``
The intent of this last form is to reliably read a list of strings The intent of this last form is to reliably read a list of strings
generated by an OCaml program via: generated by an OCaml program via:
@ -920,13 +919,13 @@ generated by an OCaml program via:
#. Expansion of lists #. Expansion of lists
Forms that expands to list of items, such as ``%{cc}``, ``%{^}``, Forms that expands to list of items, such as ``%{cc}``, ``%{deps}``,
``%{@}`` or ``%{read-lines:...}``, are suitable to be used in, say, ``%{targets}`` or ``%{read-lines:...}``, are suitable to be used in, say,
``(run <prog> <arguments>)``. For instance in: ``(run <prog> <arguments>)``. For instance in:
.. code:: scheme .. code:: scheme
(run foo %{^}) (run foo %{deps})
if there are two dependencies ``a`` and ``b``, the produced command if there are two dependencies ``a`` and ``b``, the produced command
will be equivalent to the shell command: will be equivalent to the shell command:
@ -940,7 +939,7 @@ you have to quote the variable as in:
.. code:: scheme .. code:: scheme
(run foo "%{^}") (run foo "%{deps}")
which is equivalent to the following shell command: which is equivalent to the following shell command:
@ -949,7 +948,7 @@ which is equivalent to the following shell command:
$ foo "a b" $ foo "a b"
(the items of the list are concatenated with space). (the items of the list are concatenated with space).
Note that, since ``%{^}`` is a list of items, the first one may be Note that, since ``%{deps}`` is a list of items, the first one may be
used as a program name, for instance: used as a program name, for instance:
.. code:: scheme .. code:: scheme
@ -957,7 +956,7 @@ used as a program name, for instance:
(rule (rule
(targets result.txt) (targets result.txt)
(deps foo.exe (glob_files *.txt)) (deps foo.exe (glob_files *.txt))
(action (run %{^}))) (action (run %{deps})))
Here is another example: Here is another example:
@ -966,7 +965,7 @@ Here is another example:
(rule (rule
(targets foo.exe) (targets foo.exe)
(deps foo.c) (deps foo.c)
(action (run %{cc} -o %{@} %{<} -lfoolib))) (action (run %{cc} -o %{targets} %{deps} -lfoolib)))
Library dependencies Library dependencies
@ -1052,7 +1051,7 @@ you had setup a rule for every file of the form:
(rule (rule
(targets file.pp.ml) (targets file.pp.ml)
(deps file.ml) (deps file.ml)
(action (with-stdout-to %{@} (chdir %{root} <action>)))) (action (with-stdout-to %{targets} (chdir %{root} <action>))))
The equivalent of a ``-pp <command>`` option passed to the OCaml compiler is The equivalent of a ``-pp <command>`` option passed to the OCaml compiler is
``(system "<command> %{input-file}")``. ``(system "<command> %{input-file}")``.
@ -1105,8 +1104,8 @@ For instance:
.. code:: scheme .. code:: scheme
(preprocess (per_module (preprocess (per_module
(((action (run ./pp.sh X=1 %{<})) (foo bar))) (((action (run ./pp.sh X=1 %{input-file})) (foo bar)))
(((action (run ./pp.sh X=2 %{<})) (baz))))) (((action (run ./pp.sh X=2 %{input-file})) (baz)))))
.. _deps-field: .. _deps-field:
@ -1310,7 +1309,7 @@ To understand why this is important, let's consider this dune file living in
(rule (rule
(targets blah.ml) (targets blah.ml)
(deps blah.mll) (deps blah.mll)
(action (run ocamllex -o %{@} %{<}))) (action (run ocamllex -o %{targets} %{deps})))
Here the command that will be executed is: Here the command that will be executed is:
@ -1334,7 +1333,7 @@ of your project. What you should write instead is:
(rule (rule
(targets blah.ml) (targets blah.ml)
(deps blah.mll) (deps blah.mll)
(action (chdir %{root} (run ocamllex -o %{@} %{<})))) (action (chdir %{root} (run ocamllex -o %{targets} %{deps}))))
Locks Locks
----- -----
@ -1357,13 +1356,13 @@ same lock:
(name runtest) (name runtest)
(deps foo) (deps foo)
(locks m) (locks m)
(action (run test.exe %{<}))) (action (run test.exe %{deps})))
(alias (alias
(name runtest) (name runtest)
(deps bar) (deps bar)
(locks m) (locks m)
(action (run test.exe %{<}))) (action (run test.exe %{deps})))
Dune will make sure that the executions of ``test.exe foo`` and Dune will make sure that the executions of ``test.exe foo`` and
``test.exe bar`` are serialized. ``test.exe bar`` are serialized.
@ -1383,7 +1382,7 @@ simply use an absolute filename:
(name runtest) (name runtest)
(deps foo) (deps foo)
(locks /tcp-port/1042) (locks /tcp-port/1042)
(action (run test.exe %{<}))) (action (run test.exe %{deps})))
.. _ocaml-syntax: .. _ocaml-syntax:

View File

@ -307,7 +307,7 @@ The backend for such a framework looks like this:
(library (library
((name simple_tests) ((name simple_tests)
(inline_tests.backend (inline_tests.backend
((generate_runner (run sed "s/(\\*TEST:\\(.*\\)\\*)/let () = \\1;;/" ${impl-files})) ((generate_runner (run sed "s/(\\*TEST:\\(.*\\)\\*)/let () = \\1;;/" %{impl-files}))
)))) ))))
Now all you have to do is write ``(inline_tests ((backend Now all you have to do is write ``(inline_tests ((backend