Skip to content

Commit

Permalink
mdx: add --verbosity=info flag if Dune is in verbose mode
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MisterDA committed Nov 14, 2022
1 parent 9a1d311 commit bc2b8fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dune_rules/mdx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ let color_always =
[ Command.Args.A "--color=always" ]
else [])

let verbosity =
lazy (if !Log.verbose then [ Command.Args.A "--verbosity=info" ] else [])

module Files = struct
type t =
{ src : Path.Build.t
Expand Down Expand Up @@ -72,7 +75,7 @@ module Deps = struct
let rule ~dir ~mdx_prog files =
let open Command.Args in
Command.run ~dir:(Path.build dir) mdx_prog
([ A "deps" ] @ Lazy.force color_always
([ A "deps" ] @ Lazy.force color_always @ Lazy.force verbosity
@ [ Dep (Path.build files.Files.src) ])
~stdout_to:files.Files.deps

Expand Down Expand Up @@ -324,6 +327,7 @@ let gen_rules_for_single_file stanza ~sctx ~dir ~expander ~mdx_prog
in
( mdx_prog
, [ A "test" ] @ prelude_args @ Lazy.force color_always
@ Lazy.force verbosity
@ [ A "-o"; Target files.corrected; Dep (Path.build files.src) ] )
in
let deps, sandbox =
Expand Down Expand Up @@ -379,7 +383,7 @@ let mdx_prog_gen t ~sctx ~dir ~scope ~expander ~mdx_prog =
let action =
Command.run ~dir:(Path.build dir) mdx_prog ~stdout_to:file
([ A "dune-gen"; prelude_args; Resolve.Memo.args directory_args ]
@ Lazy.force color_always)
@ Lazy.force color_always @ Lazy.force verbosity)
in
let open Memo.O in
let* () = Super_context.add_rule sctx ~loc ~dir action in
Expand Down

0 comments on commit bc2b8fb

Please sign in to comment.