summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js
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/slice2js
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/slice2js')
-rw-r--r--cpp/src/slice2js/Main.cpp59
-rw-r--r--cpp/src/slice2js/Makefile2
-rw-r--r--cpp/src/slice2js/Makefile.mak2
3 files changed, 54 insertions, 9 deletions
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() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
//
@@ -189,13 +223,14 @@ compile(int argc, char* argv[])
for(vector<string>::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() << "</dependencies>\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)