From 9cb0cc349a4bd9d8fc28ef5ca405e8133b7b8643 Mon Sep 17 00:00:00 2001 From: Arseniy Alekseyev Date: Wed, 15 Apr 2020 10:14:47 +0100 Subject: [PATCH] Fix locks in rules without targets (#3366) * Fix the bug where [locks] had no effect for rules with no targets Signed-off-by: Arseniy Alekseyev --- CHANGES.md | 3 +++ src/dune/simple_rules.ml | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9287aec2f9d..c7e7d46d429 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,9 @@ - [coq] Fix install path for theory names with level greater than 1 (#3358 , @ejgallego) +- Fix a bug introduced in 2.0.0 where the [locks] field in rules with no targets had + no effect. (@aalekseyev, report by @craigfe) + 2.5.0 (09/04/2020) ------------------ diff --git a/src/dune/simple_rules.ml b/src/dune/simple_rules.ml index 8752e86ad9f..20600241728 100644 --- a/src/dune/simple_rules.ml +++ b/src/dune/simple_rules.ml @@ -11,13 +11,13 @@ module Alias_rules = struct , Option.map ~f:Action_unexpanded.remove_locs action , Option.map extra_bindings ~f:Pform.Map.to_stamp ) - let add sctx ~alias ~stamp ~loc ?(locks = []) build = + let add sctx ~alias ~stamp ~loc ~locks build = let dir = Alias.dir alias in SC.add_alias_action sctx alias ~dir ~loc ~locks ~stamp build let add_empty sctx ~loc ~alias ~stamp = let action = Build.With_targets.return Action.empty in - add sctx ~loc ~alias ~stamp action + add sctx ~loc ~alias ~stamp action ~locks:[] end let interpret_locks ~expander = List.map ~f:(Expander.expand_path expander) @@ -124,7 +124,8 @@ let user_rule sctx ?extra_bindings ~dir ~expander (rule : Rule.t) = let action = Some (snd rule.action) in Alias_rules.stamp ~deps:rule.deps ~extra_bindings ~action in - Alias_rules.add sctx ~alias ~stamp ~loc:(Some rule.loc) action; + let locks = interpret_locks ~expander rule.locks in + Alias_rules.add sctx ~alias ~stamp ~loc:(Some rule.loc) action ~locks; Path.Build.Set.empty ) let copy_files sctx ~dir ~expander ~src_dir (def : Copy_files.t) =