diff options
Diffstat (limited to 'cpp/src/Slice/Python.cpp')
-rw-r--r-- | cpp/src/Slice/Python.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp index 25210f33759..33490740e8b 100644 --- a/cpp/src/Slice/Python.cpp +++ b/cpp/src/Slice/Python.cpp @@ -402,6 +402,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" @@ -425,6 +427,8 @@ Slice::Python::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"); @@ -482,6 +486,10 @@ Slice::Python::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"); @@ -503,6 +511,13 @@ Slice::Python::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; @@ -510,6 +525,12 @@ Slice::Python::compile(int argc, char* argv[]) bool keepComments = true; + 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) { // @@ -521,13 +542,14 @@ Slice::Python::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__SLICE2PY__"); if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -537,17 +559,20 @@ Slice::Python::compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths, + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Python : Preprocessor::SliceXML, includePaths, "-D__SLICE2PY__", "", prefix)) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -667,11 +692,17 @@ Slice::Python::compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } } + if(dependxml) + { + out.os() << "</dependencies>\n"; + } + return status; } |