From 5ca901cfa6c78365cf829d1c6b4e9efa75a0781b Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: May 03 2014 21:21:58 +0000 Subject: ocamlbuild: only show backtrace in verbose mode Building foo.cmo in an empty directory (so with in particular no foo.ml) currently returns the following output: > Solver failed: > Ocamlbuild cannot find or build foo.ml. A file with such a name > would usually be a source file. I suspect you have given a wrong > target name to Ocamlbuild. > Backtrace: > - Failed to build the target foo.cmo > - Building foo.cmo: > - Failed to build all of these: > - Building foo.ml: > - Failed to build all of these: > - Building foo.mly > - Building foo.mll > - Building foo.mli: > - Building foo.mly > - Building foo.mlpack > - Building foo.mli: > - Building foo.mly > Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00. While the "Solver failed" part is nice and reasonably easy to understand, users report that the "Backtrace" part is confusing (it talks about files they don't know about) -- and it can be so large that the explanation above is completely hidden. This patch disables backtrace-printing by default; it is now only shown when some "-verbose N" (N starting at 1) argument is passed. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14732 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- diff --git a/ocamlbuild/main.ml b/ocamlbuild/main.ml index 5f86f79..f3aef9e 100644 --- a/ocamlbuild/main.ml +++ b/ocamlbuild/main.ml @@ -282,8 +282,10 @@ let main () = Log.finish ~how:`Quiet (); Pervasives.exit rc | Solver.Failed backtrace -> - Log.raw_dprintf (-1) "@[@[<2>Solver failed:@ %a@]@\n@[Backtrace:%a@]@]@." - Report.print_backtrace_analyze backtrace Report.print_backtrace backtrace; + Log.raw_dprintf (-1) "@[@[<2>Solver failed:@ %a@]@." + Report.print_backtrace_analyze backtrace; + Log.raw_dprintf 1 "@[Backtrace:%a@]@]@." + Report.print_backtrace backtrace; exit rc_solver_failed | Failure s -> Log.eprintf "Failure:@ %s." s;