From 3866134ca3a904a62d7950648bae7537865701c6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 10 Jul 2018 01:31:45 +0700 Subject: [PATCH] Add docs for named deps Signed-off-by: Rudi Grinberg --- doc/dune-files.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/dune-files.rst b/doc/dune-files.rst index b832f6cf..f50d4cbc 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -1115,6 +1115,8 @@ Dependency specification Dependencies in ``dune`` files can be specified using one of the following syntax: +- ``(:name )`` will bind the the list of dependencies to the + ``name`` variable. This variable will be available as ``%{name}`` in actions. - ``(file )`` or simply ````: depend on this file - ``(alias )``: depend on the construction of this alias, for instance: ``(alias src/runtest)`` @@ -1142,6 +1144,33 @@ syntax: In all these cases, the argument supports `Variables expansion`_. +Named Dependencies +~~~~~~~~~~~~~~~~~~ + +dune allows a user to organize dependency lists by naming them. The user is +allowed to assign a group of dependencies a name that can later be referred to +in actions (like the ``%{deps}`` and ``%{targets}`` built in variables). + +One instance where is useful is for naming globs. Here's an example of an +imaginary bundle command: + +.. code:: scheme + + (rule + (targets archive.tar) + (deps + index.html + (:css (glob_files *.css)) + (:js foo.js bar.js) + (:img (glob_files *.png) (glob_files *.jpg))) + (action + (run %{bin:bundle} index.html -css %{css} -js %{js} -img %{img} -o %{targets}))) + +Note that such named dependency list can also include unnamed dependencies (like +``index.html`` in the example above). Also, such user defined names wil shadow +built in variables. So ``(:root x)`` will shadow the built in ``%{root}`` +variable. + .. _glob: Glob