From 8cff2a828400acb3769b7b05452ac267725086eb Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 13 Apr 2015 14:58:28 +0200 Subject: Add --depend-file/--depend-xml optinos to all Slice compilers --- cpp/src/Slice/Python.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'cpp/src/Slice/Python.cpp') 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() << "\n" << endl; + } + for(vector::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() << "\n"; + } + return status; } -- cgit v1.2.3