summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Ruby.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-04-13 14:58:28 +0200
committerJose <jose@zeroc.com>2015-04-13 14:58:28 +0200
commit8cff2a828400acb3769b7b05452ac267725086eb (patch)
tree3735ea75f8890fcec71909b0ce4cc616bd14d30a /cpp/src/Slice/Ruby.cpp
parentICE-6445 Remove .NET CF support (diff)
downloadice-8cff2a828400acb3769b7b05452ac267725086eb.tar.bz2
ice-8cff2a828400acb3769b7b05452ac267725086eb.tar.xz
ice-8cff2a828400acb3769b7b05452ac267725086eb.zip
Add --depend-file/--depend-xml optinos to all Slice compilers
Diffstat (limited to 'cpp/src/Slice/Ruby.cpp')
-rw-r--r--cpp/src/Slice/Ruby.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp
index a8d43563c5c..e452451f868 100644
--- a/cpp/src/Slice/Ruby.cpp
+++ b/cpp/src/Slice/Ruby.cpp
@@ -70,6 +70,8 @@ usage(const char* n)
"-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--depend Generate Makefile dependencies.\n"
+ "--depend-xml Generate dependencies in XML format.\n"
+ "--depend-file FILE Write dependencies to FILE instead of standard output.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only).\n"
"--underscore Permit underscores in Slice identifiers.\n"
@@ -92,6 +94,8 @@ Slice::Ruby::compile(int argc, char* argv[])
opts.addOpt("E");
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "depend");
+ opts.addOpt("", "depend-xml");
+ opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, "");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
@@ -147,6 +151,10 @@ Slice::Ruby::compile(int argc, char* argv[])
bool depend = opts.isSet("depend");
+ bool dependxml = opts.isSet("depend-xml");
+
+ string dependFile = opts.optArg("depend-file");
+
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
@@ -164,11 +172,24 @@ Slice::Ruby::compile(int argc, char* argv[])
return EXIT_FAILURE;
}
+ if(depend && dependxml)
+ {
+ getErrorStream() << argv[0] << ": error: cannot specify both --depend and --dependxml" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
+ DependOutputUtil out(dependFile);
+ if(dependxml)
+ {
+ out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
+ }
+
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
@@ -180,13 +201,14 @@ Slice::Ruby::compile(int argc, char* argv[])
continue;
}
- if(depend)
+ if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__");
if(cppHandle == 0)
{
+ out.cleanup();
return EXIT_FAILURE;
}
@@ -196,17 +218,20 @@ Slice::Ruby::compile(int argc, char* argv[])
if(parseStatus == EXIT_FAILURE)
{
+ out.cleanup();
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths,
+ if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Ruby : Preprocessor::SliceXML, includePaths,
"-D__SLICE2RB__"))
{
+ out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
+ out.cleanup();
return EXIT_FAILURE;
}
}
@@ -307,11 +332,17 @@ Slice::Ruby::compile(int argc, char* argv[])
if(interrupted)
{
+ out.cleanup();
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
}
}
+ if(dependxml)
+ {
+ out.os() << "</dependencies>\n";
+ }
+
return status;
}