Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2061 and allow to promote a subset of the targets #2068

Merged
15 commits merged into from Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ unreleased
- [coq] Add `coq.pp` stanza to help with pre-processing of grammar
files (#2054, @ejgallego, review by @rgrinberg)

- Add a new more generic form for the *promote* mode: `(promote
(until-clean) (into <dir>))` (#2068, @diml)

- Allow to promote only a subset of the targets via `(promote (only
<pred>))`. For instance: `(promote (only *.mli))` (#2068, @diml)

- Improve the behavior when a strict subset of the targets of a rule
is already in the source tree for projects using the dune language < 1.10
(#2068, fixes #2061, @diml)

- With lang dune >= 1.10, rules in standard mode are no longer allowed
to produce targets that are present in the source tree. This has
been a warning for long enough (#2068, @diml)

1.9.1 (11/04/2019)
------------------

Expand Down
13 changes: 7 additions & 6 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ let term =
~doc:"Instead of terminating build after completion, wait continuously
for file changes.")
and+ root,
only_packages,
ignore_promoted_rules,
config_file,
profile,
default_target =
only_packages,
ignore_promoted_rules,
config_file,
profile,
default_target =
let default_target_default =
match Wp.t with
| Dune -> "@@default"
Expand Down Expand Up @@ -230,7 +230,8 @@ let term =
Arg.(value
& flag
& info ["ignore-promoted-rules"] ~docs
~doc:"Ignore rules with (mode promote)")
~doc:"Ignore rules with (mode promote),
except ones with (only ...)")
and+ (config_file_opt, config_file) =
Term.ret @@
let+ config_file =
Expand Down
45 changes: 29 additions & 16 deletions doc/dune-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,27 +450,40 @@ field. The following modes are available:
of fallback rules is to generate default configuration files that
may be generated by a configure script.

- ``promote``, in this mode, the files in the source tree will be
ignored. Once the rule has been executed, the targets will be copied
back to the source tree

- ``promote-until-clean`` is the same as ``promote`` except than
``dune clean`` will remove the promoted files from the source
tree

- ``(promote-into <dir>)`` (resp. ``(promote-until-clean-into
<dir>)``) is the same as ``promote`` (resp. ``promote-until-clean``)
except that the files are promoted in ``<dir>`` instead of the
current directory. This feature is available since Dune 1.8.
- ``promote`` or ``(promote <options>)``, in this mode, the files
in the source tree will be ignored. Once the rule has been executed,
the targets will be copied back to the source tree

The following options are available:
- ``(until-clean)`` means that ``dune clean`` will remove the
promoted files from the source tree
- ``(into <dir>)`` means that the files are promoted in ``<dir>``
instead of the current directory. This feature is available since
Dune 1.8
- ``(only <predicate>)`` means that only a subset of the targets
should be promoted. The argument is a predicate in a syntax
similar to the argument of :ref:`(dirs ...) <dune-subdirs>`. This
feature is available since dune 1.10

- ``promote-until-clean`` is the same as ``(promote (until-clean))``
- ``(promote-into <dir>)`` is the same as ``(promote (into <dir>))``
- ``(promote-until-clean-into <dir>)`` is the same as ``(promote
(until-clean) (into <dir>))``

The ``(promote <options>)`` form is only available since Dune
1.10. Before Dune 1.10, you need to use one of the ``promote-...``
forms. The ``promote-...`` forms should disappear in Dune 2.0, so
using the more generic ``(promote <options>)`` form should be prefered
in new projects.

There are two use cases for promote rules. The first one is when the
generated code is easier to review than the generator, so it's easier
to commit the generated code and review it. The second is to cut down
dependencies during releases: by passing ``--ignore-promoted-rules``
to dune, rules will ``(mode promote)`` will be ignored and the
source files will be used instead. The
``-p/--for-release-of-packages`` flag implies
``--ignore-promote-rules``.
to dune, rules will ``(mode promote)`` will be ignored and the source
files will be used instead. The ``-p/--for-release-of-packages`` flag
implies ``--ignore-promote-rules``. However, rules that promotes only
a subset of their targets via ``(only ...)`` are never ignored.

inferred rules
~~~~~~~~~~~~~~
Expand Down
Loading