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,17 @@
accept_alternative_dune_file_name
---------------------------------
.. describe:: (accept_alternative_dune_file_name ...)
.. versionadded:: 3.0
Specify that the alternative filename ``dune-file`` is accepted in addition
to ``dune``.
This may be useful to avoid problems with ``dune`` files that have the
executable permission in a directory in the ``PATH``, which can unwittingly
happen on Windows.
Note that ``dune`` continues to be accepted even after enabling this option,
but if a file named ``dune-file`` is found in a directory, it will take
precedence over ``dune``.

View file

@ -0,0 +1,19 @@
authors
-------
.. describe:: (authors <strings>)
.. versionadded:: 1.9
Specify authors.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(authors
"Jane Doe <jane.doe@example.com>"
"John Doe <john.doe@example.com>")

View file

@ -0,0 +1,19 @@
bug_reports
-----------
.. describe:: (bug_reports <url>)
.. versionadded:: 1.10
Where bugs should be reported.
If a hosting service is used in ``(source)``, a default value is provided.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(bug_reports https://dev.example.com/project/issues)

View file

@ -0,0 +1,11 @@
cram
----
.. describe:: (cram <status>)
Define whether Cram-style tests are enabled for the project.
`<status>` can be either ``enable`` or ``disable``. The default is
``enable`` starting from the language version 3.0.
.. seealso:: :ref:`cram-tests`

View file

@ -0,0 +1,93 @@
dialect
-------
.. describe:: (dialect ...)
Declare a new :term:`dialect`.
.. describe:: (name <name>)
The name of the dialect being defined. It must be unique in a given
project.
This field is required.
.. describe:: (implementation ...)
Details related to the implementation files (corresponding to `*.ml`).
.. versionchanged:: 3.9 This field is made optional.
.. describe:: (extension <string>)
Specify the file extension used for this dialect.
The extension string must not start with a period and be unique in a
given project (so that a given extension can be mapped back to a
corresponding dialect). In Dune 3.9 and later, the extension string may
contain periods (e.g., `cppo.ml`).
This field is required.
.. describe:: (preprocess <action>)
Run `<action>` to produce a valid OCaml abstract syntax tree.
This action is expected to read the file given in the variable named
``%{input-file}`` and output a *binary* abstract syntax tree on its
standard output.
If the field is not present, it is assumed that the corresponding
source code is already valid OCaml code and can be passed to the OCaml
compiler as-is.
.. seealso:: :ref:`preprocessing-actions`
.. describe:: (format <action>)
Run `<action>` to format source code for this dialect.
The action is expected to read the file given in the variable named
``%{input-file}`` and output the formatted source code on its standard
output.
If the field is not present, the behavior depends on the presence of
``(preprocess)``: if it is also not present (that is, the dialect
consists of valid OCaml code), then the dialect will be formatted as
any other OCaml code. Otherwise no special formatting will be done.
.. seealso:: :doc:`/howto/formatting`
.. describe:: (interface ...)
Details related to the interface files (corresponding to `*.mli`).
This field supports the same sub-fields as ``implementation``.
.. versionchanged:: 3.9 This field is made optional.
.. describe:: (merlin_reader <program> <args>...)
Configure Merlin to use `<program> <args>...` as READER. Merlin's READER
is a mechanism to extend Merlin to support OCaml dialects by providing
a program that transforms a dialect AST into an OCaml AST.
.. seealso:: `merlin/src/extend/extend_protocol.ml <https://github.com/ocaml/merlin/blob/4.14-502_preview2/src/extend/extend_protocol.ml>`_ for the protocol specification.
This field is optional.
.. versionadded:: 3.16
Default dialects
----------------
Dune ships with two dialects pre-configured and enabled:
* ``ocaml`` for the default OCaml syntax which consumes `.ml` and `.mli` files
and uses ``ocamlformat`` for formatting.
* ``reason`` for the Reason syntax and enabled in `.re`/`.rei` files. ``refmt``
is used for formatting.
A third dialect, ``rescript``, is added when Melange support (see :doc:`/melange`)
is enabled in the project.

View file

@ -0,0 +1,11 @@
documentation
-------------
.. describe:: (documentation <url>)
.. versionadded:: 1.10
Where the documentation is hosted.
Valid for all packages in the current Dune project. May be overriden by the
per-package field (see :doc:`package`).

View file

@ -0,0 +1,25 @@
executables_implicit_empty_intf
-------------------------------
.. describe:: (executables_implicit_empty_intf ...)
.. versionadded:: 2.9
Automatically generate empty interface files for executables and tests that
do not already have them.
By default, executables defined via ``(executables(s) ...)`` or ``(test(s)
...)`` stanzas are compiled with the interface file provided (e.g., ``.mli``
or ``rei``). Since these modules cannot be used as library dependencies,
it is common to give them empty interface files to strengthen the compiler's
ability to detect unused values in these modules.
This option, when enabled, will generate an empty `*.mli` file.
Example:
.. code:: dune
(executables_implicit_empty_intf true)
This option is enabled by default starting with Dune lang 3.0.

View file

@ -0,0 +1,21 @@
expand_aliases_in_sandbox
-------------------------
.. describe:: (expand_aliases_in_sandbox ...)
When a sandboxed action depends on an alias, copy the expansion of the alias
inside the sandbox. For instance, in the following example:
.. code:: dune
(alias
(name foo)
(deps ../x))
(cram
(deps (alias foo)))
File `x` will be visible inside the Cram test if and only if this option is
enabled. This option is a better default in general; however, it currently
causes Cram tests to run noticeably slower. So it is disabled by default
until the performance issue with Cram test is fixed.

View file

@ -0,0 +1,24 @@
explicit_js_mode
----------------
.. describe:: (explicit_js_mode ...)
Do not implicitly add ``js`` to the ``(modes ...)`` field of executables.
In projects that use dune lang 1.x, JavaScript targets are defined for every
bytecode executable. This is not very precise and does not interact well
with the :doc:`/reference/aliases/all` alias.
It is possible to opt out of this behavior by using:
.. code:: dune
(explicit_js_mode)
When this is enabled, an explicit ``js`` mode needs to be added to the
``(modes ...)`` field of executables in order to trigger the JavaScript
compilation. Explicit JS targets declared like this will be attached to the
:doc:`/reference/aliases/all` alias.
Starting with Dune 2.0, this behavior is the default, and there is no way to
disable it.

View file

@ -0,0 +1,27 @@
formatting
----------
.. describe:: (formatting ...)
.. versionadded:: 2.0
Control automatic formatting. Several forms are accepted:
- To disable automatic formatting completely (equivalent to the behavior in
language 1.x):
.. code:: dune
(formatting disabled)
- To restrict the languages that are considered for formatting:
.. code:: dune
(formatting
(enabled_for <languages>))
The list of `<languages>` can be either ``dune`` (formatting of ``dune``
files) or a :term:`dialect` name.
.. seealso:: :doc:`/howto/formatting`

View file

@ -0,0 +1,22 @@
generate_opam_files
-------------------
.. describe:: (generate_opam_files ...)
.. versionadded:: 1.10
Use metadata specified in the ``dune-project`` file to generate ``.opam``
files.
To enable this integration, add the following field to the ``dune-project``
file:
.. code:: dune
(generate_opam_files)
.. seealso:: :doc:`/howto/opam-file-generation`
With this field, every time one calls Dune to execute some rules (either via
``dune build``, ``dune runtest``, or something else), the opam files get
generated.

View file

@ -0,0 +1,19 @@
homepage
--------
.. describe:: (homepage <url>)
.. versionadded:: 1.10
The homepage of the project.
If a hosting service is used in ``(source)``, a default value is provided.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(bug_reports https://example.com/)

View file

@ -0,0 +1,47 @@
implicit_transitive_deps
------------------------
.. describe:: (implicit_transitive_deps <setting>)
Control whether transitive dependencies are made implicitly visible during
compilation.
``<setting>`` is one of:
- ``true`` makes transitive dependencies implicitly visible. This is the
default.
- ``false`` only listed dependencies are visible. If the ``-H`` flag is
supported by the compiler (OCaml version >= 5.2) and Dune language version
is >= 1.17, Dune will pass the flag to the compiler, which avoids some
corner cases (see below).
- ``false-if-hidden-includes-supported`` only listed dependencies are visible
if the compiler supports the ``-H`` flag. Otherwise (OCaml version < 5.2),
the setting is ignored and all transitive dependencies are made visible.
Introduced in Dune 3.20.
.. code:: dune
(implicit_transitive_deps false)
Then all dependencies directly used by a library or an executable must be
added in the ``libraries`` field.
We recommend users experiment with this mode and report any problems.
Note that if ``-H`` flag is not being used, you must use ``threads.posix``
instead of ``threads`` when using this mode. This isn't an important
limitation, as ``threads.vm`` is deprecated anyway.
In some situations, it can be desirable to selectively preserve the behavior
of transitive dependencies' availability a library's users. For example, if
we define a library ``foo_more`` that extends ``foo``, we might want
``foo_more`` users to immediately have ``foo`` available as well. To do
this, we must define the dependency on ``foo`` as re-exported:
.. code:: dune
(library
(name foo_more)
(libraries (re_export foo)))

View file

@ -0,0 +1,47 @@
dune-project
============
Each ``dune-project`` file marks the root of a Dune projects within the current
Dune workspace (see :doc:`/explanation/scopes`). It can also specify project-wide
parameters.
The first line of ``dune-project`` must be a ``lang`` stanza with no extra
whitespace or comments. The ``lang`` stanza controls the names and contents of
all configuration files read by Dune and looks like:
.. code:: dune
(lang dune 3.14)
Additionally, they can contains the following stanzas.
.. toctree::
accept_alternative_dune_file_name
authors
bug_reports
cram
dialect
documentation
executables_implicit_empty_intf
expand_aliases_in_sandbox
explicit_js_mode
formatting
generate_opam_files
homepage
implicit_transitive_deps
license
maintainers
maintenance_intent
map_workspace_root
name
opam_file_location
package
pin
source
subst
use_standard_c_and_cxx_flags
using
version
warnings
wrapped_executables

View file

@ -0,0 +1,20 @@
license
-------
.. describe:: (license <strings>)
.. versionadded:: 1.9
Specify the license of the project, ideally as an identifier from the `SPDX
License List <https://spdx.org/licenses/>`__.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(license MIT)
Multiple licenses may be specified.

View file

@ -0,0 +1,19 @@
maintainers
-----------
.. describe:: (maintainers <strings>)
.. versionadded:: 1.10
Specify maintainers.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(maintainers
"Jane Doe <jane.doe@example.com>"
"John Doe <john.doe@example.com>")

View file

@ -0,0 +1,18 @@
maintenance_intent
------------------
.. _maintenance_intent:
.. describe:: (maintenance_intent <strings>)
.. versionadded:: 3.18
Specify the `opam maintenance intent <https://github.com/ocaml/opam-repository/blob/master/governance/policies/archiving.md#specification-of-the-x--fields-used-in-the-archiving-process>`__.
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
Example:
.. code:: dune
(maintenance_intent "(latest)")

View file

@ -0,0 +1,21 @@
map_workspace_root
-------------------
.. describe:: (map_workspace_root <bool>)
Control references to the file system locations where the project has been
built.
- with ``(map_workspace_root true)``, dune rewrites references to the
workspace root to ``/workspace_root``. Note that when this mapping is
enabled, the debug information produced by the bytecode compiler is
incorrect, as the location information is lost.
- with ``(map_workspace_root false)``, the references are not rewritten.
The default is ``(map_workspace_root true)``.
.. versionadded:: 3.0
Initial version with the mapping always enabled.
.. versionchanged:: 3.7
Add a way to disable the mapping.

View file

@ -0,0 +1,8 @@
name
----
.. describe:: (name <string>)
Set the name of the project.
It is used by :ref:`dune subst <dune-subst>` and error messages.

View file

@ -0,0 +1,17 @@
opam_file_location
------------------
.. describe:: (opam_file_location <location>)
.. versionadded:: 3.8
Configure where generated ``.opam`` files are located. `<location>` can
be one of the following:
- ``relative_to_project``: the ``.opam`` files are generated in the project
root directory. This is the default.
- ``inside_opam_directory``: the ``.opam`` files are generated in a directory
named ``opam`` in the project root directory.
.. seealso:: :doc:`/howto/opam-file-generation`

View file

@ -0,0 +1,135 @@
package
-------
This stanza is used to specify package metadata. In particular, this information
is used when generating OPAM files (see :doc:`generate_opam_files`).
.. describe:: (package ...)
Define package-specific metadata.
.. describe:: (name <string>)
The name of the package.
This must be specified.
.. describe:: (synopsis <string>)
A short package description.
.. describe:: (description <string>)
A longer package description.
.. describe:: (depends <dep-specification>)
Package dependencies, as :token:`~pkg-dep:dep_specification`.
.. describe:: (conflicts <dep-specification>)
Package conflicts, as :token:`~pkg-dep:dep_specification`.
.. describe:: (depopts <dep-specification>)
Optional package dependencies, as :token:`~pkg-dep:dep_specification`.
.. describe:: (tags <tags>)
A list of tags.
.. describe:: (deprecated_package_names <name list>)
A list of names that can be used with the
:doc:`../dune/deprecated_library_name` stanza to migrate legacy libraries
from other build systems that do not follow Dune's convention of
prefixing the library's public name with the package name.
.. describe:: (license ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`license`).
.. describe:: (authors ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`authors`).
.. describe:: (maintainers ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`maintainers`).
.. describe:: (maintenance_intent ...)
.. versionadded:: 3.18
The same as (and takes precedences over) the corresponding global field
(see :doc:`maintenance_intent`).
.. describe:: (source ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`source`).
.. describe:: (bug_reports ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`bug_reports`).
.. describe:: (homepage ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`homepage`).
.. describe:: (documentation ...)
.. versionadded:: 2.0
The same as (and takes precedences over) the corresponding global field
(see :doc:`documentation`).
.. describe:: (sites ...)
Define a site.
``(sites (<section> <name>) ...)`` defines a site named ``<name>`` in the
section ``<section>``.
Adding libraries to different packages is done via the ``public_name`` and
``package`` fields. See :doc:`../dune/library` section for details.
The list of dependencies :token:`~pkg-dep:dep_specification` is modelled after
opam's own language. The syntax is a list of the following elements:
.. productionlist:: pkg-dep
op : '=' | '<' | '>' | '<>' | '>=' | '<='
filter : :dev | :build | :with-test | :with-doc | :with-dev-setup | :post
constr : (<op> <version>)
logop : or | and
dep : <name>
: (<name> <filter>)
: (<name> <constr>)
: (<name> (<logop> (<filter> | <constr>))*)
dep_specification : <dep>+
Filters will expand to any opam variable name if prefixed by ``:``, not just the
ones listed in :token:`~pkg-dep:filter`. This also applies to version numbers.
For example, to generate ``depends: [ pkg { = version } ]``, use ``(depends
(pkg (= :version)))``.
Note that the use of a ``using`` stanza (see :doc:`using`) doesn't
automatically add the associated library or tool as a dependency. They have to
be added explicitly.

View file

@ -0,0 +1,50 @@
pin
---
.. warning::
:doc:`Dune Package Management </explanation/package-management>` is not
final yet and the configuration options are subject to change.
Pins are package overrides used in the context of package management. They
allow to fix a package at a specific version which is not affected by the
package repositories selected.
.. describe:: (pin ...)
.. versionadded:: 3.14
Define a package override.
.. describe:: (url <string>)
The URL of the package source.
This can be a path to a directory on the local file system or remote Git
repository. Local paths can be absolute or relative, and may optionally
begin with ``file://`` though this is not necessary. Remote Git
repository URLs must begin with ``git+``, for example
``git+https://github.com/user/repo`` or
``git+git@github.com:user/repo.git``.
This must be specified.
.. describe:: (package ...)
Defines which package is to be pinned.
This must be specified.
.. describe:: (name <string>)
The name of the package.
This must be specified.
.. describe:: (version <string>)
The version that the package should be assumed to be. Defaults to
``dev`` if unspecified.
.. seealso:: :doc:`pin stanza in dune-workspace </reference/dune-workspace/pin>` for
workspace-wide pinning.

View file

@ -0,0 +1,42 @@
source
------
.. describe:: (source ...)
.. versionadded:: 1.7
Specify where the source for the package can be found.
It can be specified as ``(uri <uri>)`` or using shortcuts for some
hosting services:
Valid for all packages defined in the current Dune project. May be overriden
by the per-package field (see :doc:`package`).
.. list-table::
* - Service
- Syntax
* - `Github <https://github.com>`_
- ``(github user/repo)``
* - `Bitbucket <https://bitbucket.org>`_
- ``(bitbucket user/repo)``
* - `Gitlab <https://gitlab.com>`_
- | ``(gitlab user/repo)``
| ``(gitlab organization/project/repo)`` *(New in 3.17)*
* - `Sourcehut <https://sr.ht>`_
- ``(sourcehut user/repo)``
* - `Codeberg <https://codeberg.org>`_
- ``(codeberg user/repo)`` *(New in 3.17)*
Examples:
.. code:: dune
(source
(github ocaml/dune))
.. code:: dune
(source
(uri https://dev.example.com/project.git))

View file

@ -0,0 +1,13 @@
subst
-----
.. describe:: (subst <bool>)
.. versionadded:: 3.0
Control whether :ref:`dune-subst` is enabled for this project.
- ``(subst disabled)``, means that any call of ``dune subst`` in this
project is forbidden and will result in an error. This line will be
omitted from the build instructions when generating opam files.
- ``(subst enabled)`` allows substitutions explicitly. This is the default.

View file

@ -0,0 +1,26 @@
use_standard_c_and_cxx_flags
----------------------------
.. describe:: (use_standard_c_and_cxx_flags ...)
.. versionadded:: 2.8
Control how flags coming from ``ocamlc -config`` are passed to the C
compiler command line.
Historically, they have been systematically prepended without a way to
override them.
If the following is passed, the mechanism is slightly altered:
.. code:: dune
(use_standard_c_and_cxx_flags)
In this mode, Dune will populate the ``:standard`` set of C flags with the
content of ``ocamlc_cflags`` and ``ocamlc_cppflags``. These flags can be
completed or overridden using the :doc:`/reference/ordered-set-language`.
This is the default in the language version 3.0.
.. seealso:: :doc:`/reference/foreign-flags`

View file

@ -0,0 +1,21 @@
using
-----
.. describe:: (using <plugin> <version>)
Enable a dune language extension.
The language of configuration files read by Dune can be extended to support
additional stanzas (e.g., ``menhir``, ``coq.theory``, ``mdx``).
`<plugin>` is the name of the plugin that defines this stanza and
`<version>` describes the configuration language's version. Note that this
version has nothing to do with the version of the associated tool or
library. In particular, adding a ``using`` stanza will not result in a build
dependency in the generated ``.opam`` file. See :doc:`generate_opam_files`.
Example:
.. code:: dune
(using mdx 0.3)

View file

@ -0,0 +1,12 @@
version
-------
.. describe:: (version <version>)
Set the version of the project.
Example:
.. code:: dune
(version 1.2.3)

View file

@ -0,0 +1,12 @@
warnings
--------
.. describe:: (warnings ...)
.. versionadded:: 3.11
Configure Dune warnings for the project.
.. describe:: (<name> <enabled | disabled>)
Enable or disable the warning <name> for the current project.

View file

@ -0,0 +1,19 @@
wrapped_executables
-------------------
.. describe:: (wrapped_executables <bool>)
.. versionadded:: 1.11
Control wrapping of modules in executables.
Executables are made of compilation units whose names may collide with
libraries' compilation units. To avoid this possibility, Dune prefixes
these compilation unit names with ``Dune__exe__``. This is entirely
transparent to users except when such executables are debugged. In which
case, the mangled names will be visible in the debugger.
- with ``(wrapped_executables false)``, the original names are used.
- with ``(wrapped_executables true)``, the names are mangled.
Starting in language version 2.0, the default value is ``true``.