summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Ruby.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Slice/Ruby.cpp')
-rw-r--r--cpp/src/Slice/Ruby.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp
index fe0a05ad0e2..d53fc353b5a 100644
--- a/cpp/src/Slice/Ruby.cpp
+++ b/cpp/src/Slice/Ruby.cpp
@@ -12,6 +12,7 @@
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
+#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/RubyUtil.h>
@@ -22,6 +23,7 @@
using namespace std;
using namespace Slice;
using namespace Slice::Ruby;
+using namespace IceUtilInternal;
namespace
{
@@ -58,8 +60,8 @@ interruptedCallback(int /*signal*/)
void
usage(const string& n)
{
- getErrorStream() << "Usage: " << n << " [options] slice-files...\n";
- getErrorStream() <<
+ consoleErr << "Usage: " << n << " [options] slice-files...\n";
+ consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
@@ -111,7 +113,7 @@ Slice::Ruby::compile(const vector<string>& argv)
}
catch(const IceUtilInternal::BadOptException& e)
{
- getErrorStream() << argv[0] << ": error: " << e.reason << endl;
+ consoleErr << argv[0] << ": error: " << e.reason << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
@@ -124,7 +126,7 @@ Slice::Ruby::compile(const vector<string>& argv)
if(opts.isSet("version"))
{
- getErrorStream() << ICE_STRING_VERSION << endl;
+ consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -169,14 +171,14 @@ Slice::Ruby::compile(const vector<string>& argv)
if(args.empty())
{
- getErrorStream() << argv[0] << ": error: no input file" << endl;
+ consoleErr << argv[0] << ": error: no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if(depend && dependxml)
{
- getErrorStream() << argv[0] << ": error: cannot specify both --depend and --dependxml" << endl;
+ consoleErr << argv[0] << ": error: cannot specify both --depend and --dependxml" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
@@ -186,10 +188,10 @@ Slice::Ruby::compile(const vector<string>& argv)
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
- DependOutputUtil out(dependFile);
+ ostringstream os;
if(dependxml)
{
- out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
+ os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
@@ -210,7 +212,6 @@ Slice::Ruby::compile(const vector<string>& argv)
if(cppHandle == 0)
{
- out.cleanup();
return EXIT_FAILURE;
}
@@ -220,20 +221,17 @@ Slice::Ruby::compile(const vector<string>& argv)
if(parseStatus == EXIT_FAILURE)
{
- out.cleanup();
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Ruby : Preprocessor::SliceXML, includePaths,
+ if(!icecpp->printMakefileDependencies(os, depend ? Preprocessor::Ruby : Preprocessor::SliceXML, includePaths,
"-D__SLICE2RB__"))
{
- out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
- out.cleanup();
return EXIT_FAILURE;
}
}
@@ -323,7 +321,7 @@ Slice::Ruby::compile(const vector<string>& argv)
// any created files.
FileTracker::instance()->cleanup();
u->destroy();
- getErrorStream() << argv[0] << ": error: " << ex.reason() << endl;
+ consoleErr << argv[0] << ": error: " << ex.reason() << endl;
return EXIT_FAILURE;
}
}
@@ -337,7 +335,6 @@ Slice::Ruby::compile(const vector<string>& argv)
if(interrupted)
{
- out.cleanup();
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
@@ -346,7 +343,12 @@ Slice::Ruby::compile(const vector<string>& argv)
if(dependxml)
{
- out.os() << "</dependencies>\n";
+ os << "</dependencies>\n";
+ }
+
+ if(depend || dependxml)
+ {
+ writeDependencies(os.str(), dependFile);
}
return status;