Skip to content

Commit 7e9639b

Browse files
authored
Merge pull request #12733 from rlepigre/fix-12638
Coq/Rocq: fix handling of (modules_flags ...).
2 parents 7bfd201 + 6b1f6b8 commit 7e9639b

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

doc/changes/fixed/12733.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Allow multiple modules in `(modules_flags ...)`, in `coq.theory` (#12733, @rlepigre)

doc/coq.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,11 @@ The Coq lang can be modified by adding the following to a
378378
The supported Coq language versions (not the version of Coq) are:
379379

380380
- ``0.11``: Support for the ``(coqdoc_header ...)`` and ``(coqdoc_footer ...)``
381-
fields, and for ``_CoqProject`` file generation.
381+
fields, for ``_CoqProject`` file generation, and multiple modules in
382+
``(modules_flags ...)``.
382383
- ``0.10``: Support for the ``(coqdep_flags ...)`` field.
383-
- ``0.9``: Support for per-module flags with the ``(modules_flags ...)``` field.
384+
- ``0.9``: Support for per-module flags with the ``(modules_flags ...)`` field,
385+
limited to a single module due to a bug.
384386
- ``0.8``: Support for composition with installed Coq theories;
385387
support for ``vos`` builds.
386388

src/dune_rules/coq/coq_stanza.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ module Theory = struct
250250
mod_, flags
251251
;;
252252

253-
let decode = enter (repeat decode_pair)
253+
let decode = repeat (enter decode_pair)
254+
let broken_decode = enter (repeat decode_pair)
254255
end
255256

256257
let decode =
@@ -268,9 +269,13 @@ module Theory = struct
268269
~check:(Dune_lang.Syntax.since coq_syntax (0, 11))
269270
and+ modules = Ordered_set_lang.field "modules"
270271
and+ modules_flags =
271-
field_o
272-
"modules_flags"
273-
(Dune_lang.Syntax.since coq_syntax (0, 9) >>> Per_file.decode)
272+
let* version = Dune_lang.Syntax.get_exn coq_syntax in
273+
if version >= (0, 11)
274+
then field_o "modules_flags" Per_file.decode
275+
else
276+
field_o
277+
"modules_flags"
278+
(Dune_lang.Syntax.since coq_syntax (0, 9) >>> Per_file.broken_decode)
274279
and+ enabled_if = Enabled_if.decode ~allowed_vars:Any ~since:None ()
275280
and+ buildable = Buildable.decode
276281
and+ coqdep_flags =
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Reproducing test case for https://github.com/ocaml/dune/issues/12638.
2+
3+
$ cat > dune-project <<EOF
4+
> (lang dune 3.21)
5+
> (using coq 0.11)
6+
> EOF
7+
8+
$ touch foo.v bar.v
9+
10+
$ cat > dune <<EOF
11+
> (coq.theory
12+
> (name a)
13+
> (modules_flags
14+
> (foo (-w -deprecated-since-8.15))
15+
> (bar (-w -deprecated-since-8.16))))
16+
> EOF
17+
18+
$ dune build foo.vo && tail -n 1 _build/log | ./scrub_coq_args.sh | grep deprecated-since
19+
-w -deprecated-since-8.15
20+
$ dune build bar.vo && tail -n 1 _build/log | ./scrub_coq_args.sh | grep deprecated-since
21+
-w -deprecated-since-8.16
22+
$ dune clean
23+
24+
$ cat > dune-project <<EOF
25+
> (lang dune 3.21)
26+
> (using coq 0.10)
27+
> EOF
28+
$ dune build
29+
File "dune", line 5, characters 2-35:
30+
5 | (bar (-w -deprecated-since-8.16))))
31+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
Error: Too many arguments for "modules_flags"
33+
[1]
34+
$ dune clean
35+
36+
$ cat > dune <<EOF
37+
> (coq.theory
38+
> (name a)
39+
> (modules_flags
40+
> (bar (-w -deprecated-since-8.16))))
41+
> EOF
42+
43+
$ dune build foo.vo && tail -n 1 _build/log | ./scrub_coq_args.sh | grep deprecated-since
44+
[1]
45+
$ dune build bar.vo && tail -n 1 _build/log | ./scrub_coq_args.sh | grep deprecated-since
46+
-w -deprecated-since-8.16

0 commit comments

Comments
 (0)