Skip to content

Commit 767faf0

Browse files
Alizterrgrinberg
authored andcommitted
fix: user rules with multiple aliases generate single action
Signed-off-by: Ali Caglayan <[email protected]>
1 parent d4c767a commit 767faf0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/dune_rules/simple_rules.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,16 @@ let user_rule sctx ?extra_bindings ~dir ~expander (rule : Rule_conf.t) =
131131
Some targets
132132
| Aliases_only aliases ->
133133
let+ () =
134-
let action = interpret_and_add_locks ~expander rule.locks action.build in
135-
Memo.parallel_iter aliases ~f:(fun alias ->
136-
let alias = Alias.make ~dir alias in
137-
Alias_rules.add sctx ~alias ~loc:rule.loc action)
134+
match List.map ~f:(Alias.make ~dir) aliases with
135+
| [] -> Code_error.raise "empty list of aliases" []
136+
| alias :: extra_aliases ->
137+
let loc = rule.loc in
138+
interpret_and_add_locks ~expander rule.locks action.build
139+
|> Alias_rules.add sctx ~alias ~loc
140+
>>> Memo.parallel_iter extra_aliases ~f:(fun extra_alias ->
141+
Dep.alias alias
142+
|> Action_builder.dep
143+
|> Rules.Produce.Alias.add_deps ~loc extra_alias)
138144
in
139145
None)
140146
;;

test/blackbox-tests/test-cases/alias-multiple.t

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Updating the dune-project file to use dune 3.5 allows the build to succeed:
6464
$ dune build @a
6565
I have run
6666
$ dune build @b
67-
I have run
6867

6968
Also note having both the alias and aliases fields in the same rule stanza is
7069
not allowed
@@ -112,7 +111,6 @@ Building both aliases at the same time should only run the action once
112111
$ dune clean
113112
$ dune build @a @b
114113
I have run
115-
I have run
116114

117115
A similar test with a rule that produces a target
118116
$ cat > dune << EOF

0 commit comments

Comments
 (0)