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/JavaUtil.cpp | 2 +- cpp/src/Slice/Preprocessor.cpp | 14 ++++----- cpp/src/Slice/Python.cpp | 35 ++++++++++++++++++++-- cpp/src/Slice/Ruby.cpp | 35 ++++++++++++++++++++-- cpp/src/Slice/Util.cpp | 35 ++++++++++++++++++++++ cpp/src/slice2cpp/Main.cpp | 42 ++++++++++++++++++++++++--- cpp/src/slice2cpp/Makefile | 2 +- cpp/src/slice2cpp/Makefile.mak | 2 +- cpp/src/slice2cs/Main.cpp | 35 ++++++++++++++++++++-- cpp/src/slice2cs/Makefile | 2 +- cpp/src/slice2cs/Makefile.mak | 2 +- cpp/src/slice2freeze/Makefile | 2 +- cpp/src/slice2freeze/Makefile.mak | 2 +- cpp/src/slice2freezej/Main.cpp | 15 ++++++++-- cpp/src/slice2freezej/Makefile | 2 +- cpp/src/slice2freezej/Makefile.mak | 2 +- cpp/src/slice2html/Makefile | 2 +- cpp/src/slice2html/Makefile.mak | 2 +- cpp/src/slice2java/Main.cpp | 18 ++++++++---- cpp/src/slice2java/Makefile | 2 +- cpp/src/slice2java/Makefile.mak | 2 +- cpp/src/slice2js/Main.cpp | 59 +++++++++++++++++++++++++++++++++----- cpp/src/slice2js/Makefile | 2 +- cpp/src/slice2js/Makefile.mak | 2 +- cpp/src/slice2objc/Main.cpp | 22 ++++++++++++-- cpp/src/slice2objc/Makefile | 2 +- cpp/src/slice2php/Main.cpp | 29 +++++++++++++++++-- cpp/src/slice2php/Makefile | 2 +- cpp/src/slice2php/Makefile.mak | 2 +- cpp/src/slice2py/Makefile | 2 +- cpp/src/slice2py/Makefile.mak | 2 +- cpp/src/slice2rb/Makefile | 2 +- cpp/src/slice2rb/Makefile.mak | 2 +- 33 files changed, 324 insertions(+), 59 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index e42490a0e4c..adfb6ed9f39 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -232,7 +232,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri #ifdef _WIN32 result = _mkdir(path.c_str()); #else - result = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); + result = ::mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif if(result != 0) { diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 09cdf23d0cc..e3764d747cf 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -287,8 +287,8 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs) } bool -Slice::Preprocessor::printMakefileDependencies(Language lang, const vector& includePaths, - const std::string& extraArgs, const string& cppSourceExt, +Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, const vector& includePaths, + const string& extraArgs, const string& cppSourceExt, const string& optValue) { if(!checkInputFile()) @@ -384,7 +384,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector\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; } 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() << "\n" << endl; + } + for(vector::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() << "\n"; + } + return status; } diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 5ddd8c6c8b9..cacad7217f0 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -395,3 +395,38 @@ Slice::printGeneratedHeader(IceUtilInternal::Output& out, const string& path, co out << comment << " \n"; out << comment << "\n"; } + +Slice::DependOutputUtil::DependOutputUtil(string& file) : _file(file) +{ + if(!_file.empty()) + { + _os.open(file, ios::out); + } +} + +Slice::DependOutputUtil::~DependOutputUtil() +{ + if(!_file.empty() && _os.is_open()) + { + _os.close(); + } +} + +void +Slice::DependOutputUtil::cleanup() +{ + if(!_file.empty()) + { + if(_os.is_open()) + { + _os.close(); + } + IceUtilInternal::unlink(_file); + } +} + +ostream& +Slice::DependOutputUtil::os() +{ + return _file.empty() ? cout : _os; +} diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 5fa6d6d247d..ec4cf798797 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -11,11 +11,15 @@ #include #include #include +#include #include #include #include #include "Gen.h" +#include +#include + using namespace std; using namespace Slice; @@ -74,6 +78,8 @@ usage(const char* n) "--dll-export SYMBOL Use SYMBOL for DLL exports.\n" "--impl Generate sample implementations.\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" @@ -100,7 +106,8 @@ compile(int argc, char* argv[]) opts.addOpt("", "dll-export", IceUtilInternal::Options::NeedArg); opts.addOpt("", "impl"); opts.addOpt("", "depend"); - opts.addOpt("", "depend-header"); + opts.addOpt("", "depend-xml"); + opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, ""); opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "underscore"); @@ -168,6 +175,10 @@ 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"); @@ -185,11 +196,24 @@ 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() << "\n" << endl; + } + for(vector::const_iterator i = args.begin(); i != args.end(); ++i) { // @@ -201,13 +225,14 @@ 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__SLICE2CPP__"); if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -217,17 +242,20 @@ compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(Preprocessor::CPlusPlus, includePaths, - "-D__SLICE2CPP__", sourceExtension, headerExtension)) + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::CPlusPlus : Preprocessor::SliceXML, + includePaths, "-D__SLICE2CPP__", sourceExtension, headerExtension)) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -299,12 +327,18 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } } + if(dependxml) + { + out.os() << "\n"; + } + return status; } diff --git a/cpp/src/slice2cpp/Makefile b/cpp/src/slice2cpp/Makefile index 531ab86d408..c774b2ab70e 100644 --- a/cpp/src/slice2cpp/Makefile +++ b/cpp/src/slice2cpp/Makefile @@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2cpp/Makefile.mak b/cpp/src/slice2cpp/Makefile.mak index 94610b26905..91f7c77e160 100644 --- a/cpp/src/slice2cpp/Makefile.mak +++ b/cpp/src/slice2cpp/Makefile.mak @@ -18,7 +18,7 @@ OBJS = .\Gen.obj \ !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 7e1ce36a25f..cf0365fdeca 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -71,6 +71,8 @@ usage(const char* n) "--impl Generate sample implementations.\n" "--impl-tie Generate sample TIE implementations.\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" @@ -94,6 +96,8 @@ compile(int argc, char* argv[]) opts.addOpt("", "impl"); opts.addOpt("", "impl-tie"); opts.addOpt("", "depend"); + opts.addOpt("", "depend-xml"); + opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, ""); opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "underscore"); @@ -155,6 +159,10 @@ 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"); @@ -179,11 +187,24 @@ 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() << "\n" << endl; + } + for(vector::const_iterator i = args.begin(); i != args.end(); ++i) { // @@ -195,13 +216,14 @@ 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__SLICE2CS__"); if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -211,17 +233,20 @@ compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(Preprocessor::CSharp, includePaths, + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::CSharp : Preprocessor::SliceXML, includePaths, "-D__SLICE2CS__")) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -307,12 +332,18 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } } + if(dependxml) + { + out.os() << "\n"; + } + return status; } diff --git a/cpp/src/slice2cs/Makefile b/cpp/src/slice2cs/Makefile index ccde4cf4c10..6d59b55654c 100644 --- a/cpp/src/slice2cs/Makefile +++ b/cpp/src/slice2cs/Makefile @@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2cs/Makefile.mak b/cpp/src/slice2cs/Makefile.mak index e42a7e8d1ce..5dd2a1c0e63 100644 --- a/cpp/src/slice2cs/Makefile.mak +++ b/cpp/src/slice2cs/Makefile.mak @@ -18,7 +18,7 @@ OBJS = .\Gen.obj \ !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2freeze/Makefile b/cpp/src/slice2freeze/Makefile index 1b63be66a7e..5bc2f797773 100644 --- a/cpp/src/slice2freeze/Makefile +++ b/cpp/src/slice2freeze/Makefile @@ -19,7 +19,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2freeze/Makefile.mak b/cpp/src/slice2freeze/Makefile.mak index 6c5c59750ca..563c1b4889d 100644 --- a/cpp/src/slice2freeze/Makefile.mak +++ b/cpp/src/slice2freeze/Makefile.mak @@ -17,7 +17,7 @@ OBJS = .\Main.obj !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index ae6b1beaf87..06302a5d51d 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1445,6 +1445,7 @@ usage(const char* 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" @@ -1725,6 +1726,8 @@ 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"); @@ -1749,9 +1752,10 @@ compile(int argc, char* argv[]) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + DependOutputUtil out(dependFile); if(dependxml) { - cout << "\n" << endl; + out.os() << "\n" << endl; } for(vector::size_type idx = 0; idx < args.size(); ++idx) @@ -1763,6 +1767,7 @@ compile(int argc, char* argv[]) if(cppHandle == 0) { + out.cleanup(); u->destroy(); return EXIT_FAILURE; } @@ -1771,19 +1776,22 @@ compile(int argc, char* argv[]) if(status == EXIT_FAILURE) { + out.cleanup(); u->destroy(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths, + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Java : Preprocessor::SliceXML, includePaths, "-D__SLICE2FREEZEJ__")) { + out.cleanup(); u->destroy(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); u->destroy(); return EXIT_FAILURE; } @@ -1828,6 +1836,7 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); return EXIT_FAILURE; } } @@ -1835,7 +1844,7 @@ compile(int argc, char* argv[]) if(dependxml) { - cout << "\n"; + out.os() << "\n"; } if(depend || dependxml) diff --git a/cpp/src/slice2freezej/Makefile b/cpp/src/slice2freezej/Makefile index b244066aeb5..33cf5c3e931 100644 --- a/cpp/src/slice2freezej/Makefile +++ b/cpp/src/slice2freezej/Makefile @@ -19,7 +19,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2freezej/Makefile.mak b/cpp/src/slice2freezej/Makefile.mak index 97bac1bd5e5..e7f1a81b13d 100644 --- a/cpp/src/slice2freezej/Makefile.mak +++ b/cpp/src/slice2freezej/Makefile.mak @@ -17,7 +17,7 @@ OBJS = .\Main.obj !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2html/Makefile b/cpp/src/slice2html/Makefile index 47f2177d6f0..e0f0f78fd85 100644 --- a/cpp/src/slice2html/Makefile +++ b/cpp/src/slice2html/Makefile @@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2html/Makefile.mak b/cpp/src/slice2html/Makefile.mak index e3e52678e4c..1210ad26d4a 100644 --- a/cpp/src/slice2html/Makefile.mak +++ b/cpp/src/slice2html/Makefile.mak @@ -18,7 +18,7 @@ OBJS = .\Gen.obj \ !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index a334113a7af..fe93c7d59a3 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -73,6 +73,7 @@ usage(const char* n) "--impl-tie Generate sample TIE implementations.\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" "--list-generated Emit list of generated files in XML format.\n" "-d, --debug Print debug messages.\n" "--ice Permit `Ice' prefix (for building Ice source code only).\n" @@ -99,6 +100,7 @@ compile(int argc, char* argv[]) opts.addOpt("", "impl-tie"); opts.addOpt("", "depend"); opts.addOpt("", "depend-xml"); + opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, ""); opts.addOpt("", "list-generated"); opts.addOpt("d", "debug"); opts.addOpt("", "ice"); @@ -162,6 +164,7 @@ 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"); @@ -200,9 +203,10 @@ compile(int argc, char* argv[]) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + DependOutputUtil out(dependFile); if(dependxml) { - cout << "\n" << endl; + out.os() << "\n" << endl; } for(vector::const_iterator i = args.begin(); i != args.end(); ++i) @@ -223,6 +227,7 @@ compile(int argc, char* argv[]) if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -232,18 +237,20 @@ compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths, - "-D__SLICE2JAVA__" - )) + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::Java : Preprocessor::SliceXML, includePaths, + "-D__SLICE2JAVA__")) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -361,6 +368,7 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); // // If the translator was interrupted then cleanup any files we've already created. // @@ -372,7 +380,7 @@ compile(int argc, char* argv[]) if(dependxml) { - cout << "\n"; + out.os() << "\n"; } if(status == EXIT_SUCCESS && !checksumClass.empty() && !dependxml) diff --git a/cpp/src/slice2java/Makefile b/cpp/src/slice2java/Makefile index 0d6c152f9f7..5b6afcbc512 100644 --- a/cpp/src/slice2java/Makefile +++ b/cpp/src/slice2java/Makefile @@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2java/Makefile.mak b/cpp/src/slice2java/Makefile.mak index fa1eafda57b..7e1b2b88a58 100644 --- a/cpp/src/slice2java/Makefile.mak +++ b/cpp/src/slice2java/Makefile.mak @@ -18,7 +18,7 @@ OBJS = .\Gen.obj \ !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index 328b8997f60..35aca5463d4 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -70,6 +70,8 @@ usage(const char* n) "--output-dir DIR Create files in the directory DIR.\n" "--depend Generate Makefile dependencies.\n" "--depend-json Generate Makefile dependencies in JSON format.\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" @@ -91,6 +93,8 @@ compile(int argc, char* argv[]) opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg); opts.addOpt("", "depend"); opts.addOpt("", "depend-json"); + opts.addOpt("", "depend-xml"); + opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, ""); opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "underscore"); @@ -149,6 +153,10 @@ compile(int argc, char* argv[]) bool dependJSON = opts.isSet("depend-json"); + bool dependxml = opts.isSet("depend-xml"); + + string dependFile = opts.optArg("depend-file"); + bool debug = opts.isSet("debug"); bool ice = opts.isSet("ice"); @@ -164,14 +172,40 @@ compile(int argc, char* argv[]) return EXIT_FAILURE; } + if(depend && dependJSON) + { + getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-json" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + if(depend && dependxml) + { + getErrorStream() << argv[0] << ": error: cannot specify both --depend and --dependxml" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + if(dependxml && dependJSON) + { + getErrorStream() << argv[0] << ": error: cannot specify both --dependxml and --depend-json" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + int status = EXIT_SUCCESS; IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + DependOutputUtil out(dependFile); if(dependJSON) { - cout << "{" << endl; + out.os() << "{" << endl; + } + else if(dependxml) + { + out.os() << "\n" << endl; } // @@ -189,13 +223,14 @@ compile(int argc, char* argv[]) for(vector::const_iterator i = sources.begin(); i != sources.end();) { - if(depend || dependJSON) + if(depend || dependJSON || dependxml) { PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2JS__"); if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -205,19 +240,24 @@ compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } bool last = (++i == sources.end()); - if(!icecpp->printMakefileDependencies(depend ? Preprocessor::JavaScript : Preprocessor::JavaScriptJSON, includePaths, - "-D__SLICE2JS__")) + if(!icecpp->printMakefileDependencies(out.os(), + depend ? Preprocessor::JavaScript : (dependJSON ? Preprocessor::JavaScriptJSON : Preprocessor::SliceXML), + includePaths, + "-D__SLICE2JS__")) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } @@ -225,9 +265,9 @@ compile(int argc, char* argv[]) { if(!last) { - cout << ","; + out.os() << ","; } - cout << "\n"; + out.os() << "\n"; } } else @@ -306,6 +346,7 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } @@ -314,7 +355,11 @@ compile(int argc, char* argv[]) if(dependJSON) { - cout << "}" << endl; + out.os() << "}" << endl; + } + else if(dependxml) + { + out.os() << "\n"; } return status; diff --git a/cpp/src/slice2js/Makefile b/cpp/src/slice2js/Makefile index 4d0bf3d7fa3..ffe0fa99b17 100644 --- a/cpp/src/slice2js/Makefile +++ b/cpp/src/slice2js/Makefile @@ -21,7 +21,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2js/Makefile.mak b/cpp/src/slice2js/Makefile.mak index 8652531204c..9e48db8e884 100644 --- a/cpp/src/slice2js/Makefile.mak +++ b/cpp/src/slice2js/Makefile.mak @@ -19,7 +19,7 @@ OBJS = .\Gen.obj \ !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2objc/Main.cpp b/cpp/src/slice2objc/Main.cpp index fe9189514a1..92da5f2a617 100644 --- a/cpp/src/slice2objc/Main.cpp +++ b/cpp/src/slice2objc/Main.cpp @@ -70,6 +70,7 @@ usage(const char* n) "--dll-export SYMBOL Use SYMBOL for DLL exports.\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 +93,7 @@ main(int argc, char* argv[]) opts.addOpt("", "dll-export", 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"); @@ -151,6 +153,7 @@ main(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"); @@ -165,11 +168,19 @@ main(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; + DependOutputUtil out(dependFile); if(dependxml) { - cout << "\n" << endl; + out.os() << "\n" << endl; } IceUtil::CtrlCHandler ctrlCHandler; @@ -184,6 +195,7 @@ main(int argc, char* argv[]) if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -193,17 +205,20 @@ main(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(depend ? Preprocessor::ObjC : Preprocessor::JavaXML, + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::ObjC : Preprocessor::SliceXML, includePaths, "-D__SLICE2OBJC__")) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -279,6 +294,7 @@ main(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } @@ -287,7 +303,7 @@ main(int argc, char* argv[]) if(dependxml) { - cout << "\n"; + out.os() << "\n"; } return status; diff --git a/cpp/src/slice2objc/Makefile b/cpp/src/slice2objc/Makefile index 244fd0a5c82..e95af7fd610 100644 --- a/cpp/src/slice2objc/Makefile +++ b/cpp/src/slice2objc/Makefile @@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index bb992c77a96..39f5ecceedc 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -1584,6 +1584,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" @@ -1605,6 +1607,8 @@ 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"); @@ -1661,6 +1665,10 @@ 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"); @@ -1685,6 +1693,12 @@ compile(int argc, char* argv[]) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + DependOutputUtil out(dependFile); + if(dependxml) + { + out.os() << "\n" << endl; + } + for(vector::const_iterator i = args.begin(); i != args.end(); ++i) { // @@ -1696,13 +1710,14 @@ 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__SLICE2PHP__"); if(cppHandle == 0) { + out.cleanup(); return EXIT_FAILURE; } @@ -1712,16 +1727,20 @@ compile(int argc, char* argv[]) if(parseStatus == EXIT_FAILURE) { + out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths, "-D__SLICE2PHP__")) + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::PHP : Preprocessor::SliceXML, + includePaths, "-D__SLICE2PHP__")) { + out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { + out.cleanup(); return EXIT_FAILURE; } } @@ -1830,12 +1849,18 @@ compile(int argc, char* argv[]) if(interrupted) { + out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } } + if(dependxml) + { + out.os() << "\n"; + } + return status; } diff --git a/cpp/src/slice2php/Makefile b/cpp/src/slice2php/Makefile index 9436e6f9f0c..e4e2fca71d3 100644 --- a/cpp/src/slice2php/Makefile +++ b/cpp/src/slice2php/Makefile @@ -19,7 +19,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2php/Makefile.mak b/cpp/src/slice2php/Makefile.mak index 38a49a283c0..2eb06feb889 100644 --- a/cpp/src/slice2php/Makefile.mak +++ b/cpp/src/slice2php/Makefile.mak @@ -17,7 +17,7 @@ OBJS = .\Main.obj !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2py/Makefile b/cpp/src/slice2py/Makefile index fdd58cf87c6..aa8a5932067 100644 --- a/cpp/src/slice2py/Makefile +++ b/cpp/src/slice2py/Makefile @@ -19,7 +19,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2py/Makefile.mak b/cpp/src/slice2py/Makefile.mak index 26f0247f146..f8313e86836 100644 --- a/cpp/src/slice2py/Makefile.mak +++ b/cpp/src/slice2py/Makefile.mak @@ -17,7 +17,7 @@ OBJS = .\Main.obj !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) diff --git a/cpp/src/slice2rb/Makefile b/cpp/src/slice2rb/Makefile index 7728f3889e0..f44a3c35d06 100644 --- a/cpp/src/slice2rb/Makefile +++ b/cpp/src/slice2rb/Makefile @@ -19,7 +19,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. $(CPPFLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/slice2rb/Makefile.mak b/cpp/src/slice2rb/Makefile.mak index 1742e069e22..abc55490e88 100644 --- a/cpp/src/slice2rb/Makefile.mak +++ b/cpp/src/slice2rb/Makefile.mak @@ -17,7 +17,7 @@ OBJS = .\Main.obj !include $(top_srcdir)/config/Make.rules.mak -CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" PDBFLAGS = /pdb:$(NAME:.exe=.pdb) -- cgit v1.2.3