Skip to content

Commit

Permalink
fix: Allow package in any location in rule (#7445)
Browse files Browse the repository at this point in the history
While fixing the package associations in ocaml/opam#5496 I realized that the package stanza is only accepted when it is at the end of the rule stanza.

* Add test that `packages` needs to be last, or it will be rejected

    File "dune", line 12, characters 3-10:
    12 |   (package a)
            ^^^^^^^
    Error: Unknown action or rule field.
    [1]

Signed-off-by: Marek Kubica <[email protected]>
Co-authored-by: Etienne Millon <[email protected]>
  • Loading branch information
Leonidas-from-XIV and emillon authored Mar 30, 2023
1 parent ad088a5 commit 026413c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ Unreleased
- Support `(link_flags ...)` in `(cinaps ...)` stanza. (#7423, fixes #7416,
@nojb)

- Allow `(package ...)` in any position within `(rule ...)` stanza (#7445,
@Leonidas-from-XIV)

3.7.0 (2023-02-17)
------------------

Expand Down
1 change: 1 addition & 0 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ module Rule = struct
; ("aliases", Field)
; ("alias", Field)
; ("enabled_if", Field)
; ("package", Field)
]

let short_form =
Expand Down
Empty file.
12 changes: 12 additions & 0 deletions test/blackbox-tests/test-cases/package-rule.t/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(test
(name test)
(modules test test_a test_b)
(package a))

(rule
(action (copy test_temp.ml test_a.ml))
(package a))

(rule
(package a)
(action (copy test_temp.ml test_b.ml)))
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/package-rule.t/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 2.0)
5 changes: 5 additions & 0 deletions test/blackbox-tests/test-cases/package-rule.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
When --only-packages is passed, it runs

$ dune build --only-packages a @runtest
A
A
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/package-rule.t/test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module _ = Test_a
module _ = Test_b
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/package-rule.t/test_temp.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline "A"

0 comments on commit 026413c

Please sign in to comment.