Skip to content

Commit

Permalink
refactor: simplify alias handling in format rules (#11085)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored Nov 3, 2024
1 parent a5306e3 commit af29910
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/dune_rules/format_rules.ml
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down Expand Up @@ -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
Expand All @@ -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 ())
;;
Expand Down

0 comments on commit af29910

Please sign in to comment.