From 26a34bc33c3c1aa51bb9a1fd975958cec066b0af Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Sun, 30 Jun 2019 11:30:09 -0700 Subject: [PATCH] [sledge] Do not always output list of bitcode inputs Summary: Outputting the list of bitcode inputs when no output flag is ok for `sledge buck bitcode` but does not make sense when it is composed as part of other commands. So only output to stdout if `-` is given as the output file name. Reviewed By: kren1 Differential Revision: D16059782 fbshipit-source-id: abac9c36f --- sledge/sledge-help.txt | 6 ++++-- sledge/src/sledge_buck.ml | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sledge/sledge-help.txt b/sledge/sledge-help.txt index 4c9ca6d88..ae600a9a0 100644 --- a/sledge/sledge-help.txt +++ b/sledge/sledge-help.txt @@ -49,7 +49,8 @@ Analyze code in a buck target. This is a convenience wrapper for the sequence `s [-function-summaries] use function summaries (in development) [-lib-fuzzer] add a harness for lib fuzzer binaries [-output-llair ] write generated LLAIR to - [-output-modules ] write list of bitcode files to + [-output-modules ] write list of bitcode files to , or to + standard output if is `-` [-skip-throw] do not explore past throwing an exception [-trace ] enable debug tracing [-help] print this help text and exit @@ -66,7 +67,8 @@ Build a buck target and report the included bitcode files. === flags === - [-output-modules ] write list of bitcode files to + [-output-modules ] write list of bitcode files to , or to + standard output if is `-` [-trace ] enable debug tracing [-help] print this help text and exit (alias: -?) diff --git a/sledge/src/sledge_buck.ml b/sledge/src/sledge_buck.ml index 3ec2cff86..d54153e53 100644 --- a/sledge/src/sledge_buck.ml +++ b/sledge/src/sledge_buck.ml @@ -176,15 +176,18 @@ let main ~(command : unit Command.basic_command) ~analyze = let%map_open target = target_flag and output = flag "output-modules" (optional string) - ~doc:" write list of bitcode files to " + ~doc: + " write list of bitcode files to , or to standard \ + output if is `-`" in let bitcode_files = bitcode_files_of ~target in ( match output with - | Some file -> Out_channel.write_lines file bitcode_files - | None -> + | Some "-" -> Format.printf "%a" (List.pp " " Format.pp_print_string) - bitcode_files ) ; + bitcode_files + | Some file -> Out_channel.write_lines file bitcode_files + | None -> () ) ; bitcode_files in let bitcode_cmd =