From cb4e8b4de20da571ae53c44826cec1a4bff77828 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 21 Sep 2023 18:58:44 +0100 Subject: [PATCH] Revert "fix: make ignored rules fallback (#8706)" This reverts commit b326c30331b5fdb039e06b02b88bdff96bf17da3. Signed-off-by: Rudi Grinberg --- doc/changes/8518.md | 5 ++- src/dune_rules/super_context.ml | 36 ++++++++++--------- .../test-cases/missing-opam-generated-file.t | 3 ++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/doc/changes/8518.md b/doc/changes/8518.md index 0d7c4820d276..42978c2b9ff9 100644 --- a/doc/changes/8518.md +++ b/doc/changes/8518.md @@ -1,3 +1,2 @@ -- Turn internal promote rules into fallback rules when - `--ignore-promoted-rules` is set (#8518, #...., fix #8417, fix #8703, - @rgrinberg, @emillon) +- Ignore internal promote rules when `--ignore-promoted-rules` is set (#8518, + fix #8417, @rgrinberg) diff --git a/src/dune_rules/super_context.ml b/src/dune_rules/super_context.ml index 5fcd152df5fb..a67684a5946d 100644 --- a/src/dune_rules/super_context.ml +++ b/src/dune_rules/super_context.ml @@ -259,29 +259,31 @@ let extend_action t ~dir action = ;; let make_rule t ?mode ?loc ~dir { Action_builder.With_targets.build; targets } = - let (mode : Rule.Mode.t option) = - match mode with - | Some mode when Rule_mode_decoder.is_ignored mode ~until_clean:`Keep -> Some Fallback - | _ -> mode - in - let build = extend_action t build ~dir in - Rule.make - ?mode - ~info:(Rule.Info.of_loc_opt loc) - ~context:(Some (Context.build_context (Env_tree.context t))) - ~targets - build + match mode with + | Some mode when Rule_mode_decoder.is_ignored mode ~until_clean:`Keep -> None + | _ -> + let build = extend_action t build ~dir in + Some + (Rule.make + ?mode + ~info:(Rule.Info.of_loc_opt loc) + ~context:(Some (Context.build_context (Env_tree.context t))) + ~targets + build) ;; let add_rule t ?mode ?loc ~dir build = - let rule = make_rule t ?mode ?loc ~dir build in - Rules.Produce.rule rule + match make_rule t ?mode ?loc ~dir build with + | None -> Memo.return () + | Some rule -> Rules.Produce.rule rule ;; let add_rule_get_targets t ?mode ?loc ~dir build = - let rule = make_rule t ?mode ?loc ~dir build in - let+ () = Rules.Produce.rule rule in - Some rule.targets + match make_rule t ?mode ?loc ~dir build with + | None -> Memo.return None + | Some rule -> + let+ () = Rules.Produce.rule rule in + Some rule.targets ;; let add_rules t ?loc ~dir builds = Memo.parallel_iter builds ~f:(add_rule ?loc t ~dir) diff --git a/test/blackbox-tests/test-cases/missing-opam-generated-file.t b/test/blackbox-tests/test-cases/missing-opam-generated-file.t index c37605c60269..b532150a5b0b 100644 --- a/test/blackbox-tests/test-cases/missing-opam-generated-file.t +++ b/test/blackbox-tests/test-cases/missing-opam-generated-file.t @@ -16,3 +16,6 @@ will overwrite `pkg.opam`. Now it does not update the file. $ touch opam $ dune build -p pkg @install + Error: No rule found for pkg.opam + -> required by alias install + [1]