From af2991084e29f7593d194ecc416f8e6218382cbd Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 3 Nov 2024 14:31:15 +0000 Subject: [PATCH] refactor: simplify alias handling in format rules (#11085) Signed-off-by: Rudi Grinberg --- src/dune_rules/format_rules.ml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dune_rules/format_rules.ml b/src/dune_rules/format_rules.ml index 9a8ce5bd0a1..0695fe51ba0 100644 --- a/src/dune_rules/format_rules.ml +++ b/src/dune_rules/format_rules.ml @@ -1,15 +1,15 @@ open Import -let add_diff sctx loc alias ~dir ~input ~output = +let add_diff sctx loc alias ~input ~output = let open Action_builder.O in - let action = Action.Chdir (Path.build dir, Promote.Diff_action.diff input output) in - Super_context.add_alias_action - sctx - alias - ~dir - ~loc - (Action_builder.paths [ input; Path.build output ] - >>> Action_builder.return (Action.Full.make action)) + let dir = Alias.dir alias in + let action = + let dir = Path.Build.parent_exn dir in + Action.Chdir (Path.build dir, Promote.Diff_action.diff input output) + in + Action_builder.paths [ input; Path.build output ] + >>> Action_builder.return (Action.Full.make action) + |> Super_context.add_alias_action sctx alias ~dir ~loc ;; let rec subdirs_until_root dir = @@ -178,7 +178,7 @@ let gen_rules_output in format_action format ~input ~output ~expander kind |> Memo.bind ~f:(Super_context.add_rule sctx ~mode:Standard ~loc ~dir) - >>> add_diff sctx loc alias_formatted ~dir ~input:(Path.build input) ~output) + >>> add_diff sctx loc alias_formatted ~input:(Path.build input) ~output) |> Memo.Option.iter ~f:Fun.id in let* source_dir = Source_tree.find_dir (Path.Build.drop_build_context_exn dir) in @@ -205,7 +205,7 @@ let gen_rules_output Action.Full.make (action ~version input output)) |> Action_builder.with_file_targets ~file_targets:[ output ] |> Super_context.add_rule sctx ~mode:Standard ~loc ~dir - >>> add_diff sctx loc alias_formatted ~dir ~input ~output))) + >>> add_diff sctx loc alias_formatted ~input ~output))) in Rules.Produce.Alias.add_deps alias_formatted (Action_builder.return ()) ;;