[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
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent b8bd639ad8
commit 26a34bc33c

@ -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 <file>] write generated LLAIR to <file>
[-output-modules <file>] write list of bitcode files to <file>
[-output-modules <file>] write list of bitcode files to <file>, or to
standard output if <file> is `-`
[-skip-throw] do not explore past throwing an exception
[-trace <spec>] 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 <file>] write list of bitcode files to <file>
[-output-modules <file>] write list of bitcode files to <file>, or to
standard output if <file> is `-`
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)

@ -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:"<file> write list of bitcode files to <file>"
~doc:
"<file> write list of bitcode files to <file>, or to standard \
output if <file> 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 =

Loading…
Cancel
Save