aboutsummaryrefslogtreecommitdiff
path: root/tools/pnacl-thaw
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-05-06 13:03:45 -0700
committerKarl Schimpf <kschimpf@google.com>2013-05-06 13:03:45 -0700
commite8e05695a8e511ad8512fc8696497702dc1a1aff (patch)
treeedf672ddfd48054273c0d7870ff3203b7cec6b65 /tools/pnacl-thaw
parent7b64d98c72e1b453934519b1033d3e60679a4197 (diff)
Allow pnacl-freeze/thaw to redirect to stdin/stdout.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14642019
Diffstat (limited to 'tools/pnacl-thaw')
-rw-r--r--tools/pnacl-thaw/pnacl-thaw.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/pnacl-thaw/pnacl-thaw.cpp b/tools/pnacl-thaw/pnacl-thaw.cpp
index b28c357165..3060e7c073 100644
--- a/tools/pnacl-thaw/pnacl-thaw.cpp
+++ b/tools/pnacl-thaw/pnacl-thaw.cpp
@@ -30,19 +30,16 @@ using namespace llvm;
static cl::opt<std::string>
OutputFilename("o", cl::desc("Specify thawed pexe filename"),
- cl::value_desc("filename"));
+ cl::value_desc("filename"), cl::init("-"));
static cl::opt<std::string>
-InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::Required);
+InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::init("-"));
static void WriteOutputFile(const Module *M) {
- std::string ThawedFilename =
- (OutputFilename.size() == 0 ? (InputFilename + ".thawed") : OutputFilename);
-
std::string ErrorInfo;
OwningPtr<tool_output_file> Out
- (new tool_output_file(ThawedFilename.c_str(), ErrorInfo,
+ (new tool_output_file(OutputFilename.c_str(), ErrorInfo,
raw_fd_ostream::F_Binary));
if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n';
@@ -72,7 +69,11 @@ int main(int argc, char **argv) {
// Use the bitcode streaming interface
DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
if (streamer) {
- std::string DisplayFilename = InputFilename;
+ std::string DisplayFilename;
+ if (InputFilename == "-")
+ DisplayFilename = "<stdin>";
+ else
+ DisplayFilename = InputFilename;
M.reset(getNaClStreamedBitcodeModule(DisplayFilename, streamer, Context,
&ErrorMessage));
if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) {