Skip to content

Commit e4734f3

Browse files
committed
mdx: add --verbosity=info flag if Dune is in verbose mode
This hack usually doesn't add much to the output and can greatly help debugging mdx scripts with Dune. Signed-off-by: Antonin Décimo <antonin@tarides.com>
1 parent 1343c97 commit e4734f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/dune_rules/mdx.ml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ let color_always =
88
[ Command.Args.A "--color=always" ]
99
else [])
1010

11+
let verbosity =
12+
lazy (if !Log.verbose then [ Command.Args.A "--verbosity=info" ] else [])
13+
1114
module Files = struct
1215
type t =
1316
{ src : Path.Build.t
@@ -72,7 +75,7 @@ module Deps = struct
7275
let rule ~dir ~mdx_prog files =
7376
let open Command.Args in
7477
Command.run ~dir:(Path.build dir) mdx_prog
75-
([ A "deps" ] @ Lazy.force color_always
78+
([ A "deps" ] @ Lazy.force color_always @ Lazy.force verbosity
7679
@ [ Dep (Path.build files.Files.src) ])
7780
~stdout_to:files.Files.deps
7881

@@ -324,6 +327,7 @@ let gen_rules_for_single_file stanza ~sctx ~dir ~expander ~mdx_prog
324327
in
325328
( mdx_prog
326329
, [ A "test" ] @ prelude_args @ Lazy.force color_always
330+
@ Lazy.force verbosity
327331
@ [ A "-o"; Target files.corrected; Dep (Path.build files.src) ] )
328332
in
329333
let deps, sandbox =
@@ -379,7 +383,7 @@ let mdx_prog_gen t ~sctx ~dir ~scope ~expander ~mdx_prog =
379383
let action =
380384
Command.run ~dir:(Path.build dir) mdx_prog ~stdout_to:file
381385
([ A "dune-gen"; prelude_args; Resolve.Memo.args directory_args ]
382-
@ Lazy.force color_always)
386+
@ Lazy.force color_always @ Lazy.force verbosity)
383387
in
384388
let open Memo.O in
385389
let* () = Super_context.add_rule sctx ~loc ~dir action in

0 commit comments

Comments
 (0)