@@ -176,6 +176,7 @@ type t =
176
176
| Substitute of String_with_vars .t * String_with_vars .t
177
177
| Withenv of String_with_vars .t Env_update .t list * t
178
178
| When of Slang .blang * t
179
+ | Format_dune_file of String_with_vars .t * String_with_vars .t
179
180
180
181
let is_dev_null t = String_with_vars. is_pform t (Var Dev_null )
181
182
@@ -350,6 +351,11 @@ let cstrs_dune_file t =
350
351
, Syntax. since Stanza. syntax (2 , 7 )
351
352
>>> let + script = sw in
352
353
Cram script )
354
+ ; ( " format-dune-file"
355
+ , Syntax. since Stanza. syntax (3 , 18 )
356
+ >>> let + src = sw
357
+ and + dst = sw in
358
+ Format_dune_file (src, dst) )
353
359
]
354
360
;;
355
361
@@ -458,6 +464,7 @@ let rec encode =
458
464
List [ atom " withenv" ; List (List. map ~f: Env_update. encode ops); encode t ]
459
465
| When (condition , action ) ->
460
466
List [ atom " when" ; Slang. encode_blang condition; encode action ]
467
+ | Format_dune_file (src , dst ) -> List [ atom " format-dune-file" ; sw src; sw dst ]
461
468
;;
462
469
463
470
(* In [Action_exec] we rely on one-to-one mapping between the cwd-relative paths
@@ -495,7 +502,8 @@ let ensure_at_most_one_dynamic_run ~loc action =
495
502
| Diff _
496
503
| Substitute _
497
504
| Patch _
498
- | Cram _ -> false
505
+ | Cram _
506
+ | Format_dune_file _ -> false
499
507
| Pipe (_ , ts ) | Progn ts | Concurrent ts ->
500
508
List. fold_left ts ~init: false ~f: (fun acc t ->
501
509
let have_dyn = loop t in
@@ -597,6 +605,7 @@ let rec map_string_with_vars t ~f =
597
605
When
598
606
( blang_map_string_with_vars condition ~f: (slang_map_string_with_vars ~f )
599
607
, map_string_with_vars t ~f )
608
+ | Format_dune_file (src , dst ) -> Format_dune_file (f src, f dst)
600
609
;;
601
610
602
611
let remove_locs = map_string_with_vars ~f: String_with_vars. remove_locs
0 commit comments