summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Main.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2002-08-26 21:13:03 +0000
committerBenoit Foucher <benoit@zeroc.com>2002-08-26 21:13:03 +0000
commitafb824731409fee7eb5c2d99c9a7108cc1db1308 (patch)
tree7e8288dbe27ca4a8c15b2a39436d4005c000dee2 /cpp/src/slice2java/Main.cpp
parentRemoved redundant tests for include level from parser.cpp. Added (diff)
downloadice-afb824731409fee7eb5c2d99c9a7108cc1db1308.tar.bz2
ice-afb824731409fee7eb5c2d99c9a7108cc1db1308.tar.xz
ice-afb824731409fee7eb5c2d99c9a7108cc1db1308.zip
Added generation of dependencies between slice files.
Diffstat (limited to 'cpp/src/slice2java/Main.cpp')
-rw-r--r--cpp/src/slice2java/Main.cpp114
1 files changed, 72 insertions, 42 deletions
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index fd39fe0d277..6d234428ec1 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -50,6 +50,7 @@ main(int argc, char* argv[])
bool clone = false;
bool debug = false;
bool ice = false;
+ bool depend = false;
int idx = 1;
while(idx < argc)
@@ -184,6 +185,15 @@ main(int argc, char* argv[])
}
--argc;
}
+ else if(strcmp(argv[idx], "--depend") == 0)
+ {
+ depend = true;
+ for(int i = idx ; i + 1 < argc ; ++i)
+ {
+ argv[i] = argv[i + 1];
+ }
+ --argc;
+ }
else if(argv[idx][0] == '-')
{
cerr << argv[0] << ": unknown option `" << argv[idx] << "'"
@@ -233,62 +243,82 @@ main(int argc, char* argv[])
ifstream test(argv[idx]);
if(!test)
{
- cerr << argv[0] << ": can't open `" << argv[idx]
- << "' for reading: " << strerror(errno) << endl;
+ cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl;
return EXIT_FAILURE;
}
test.close();
- string cmd = cpp + " " + argv[idx];
+ if(depend)
+ {
+ string::size_type pos = base.rfind('/');
+ if(pos != string::npos)
+ {
+ base.erase(0, pos + 1);
+ }
+
+ string cmd = cpp + " -M -MT " + base + ".java " + argv[idx];
+
#ifdef _WIN32
- FILE* cppHandle = _popen(cmd.c_str(), "r");
+ FILE* cppHandle = _popen(cmd.c_str(), "w");
+ _pclose(cppHandle);
#else
- FILE* cppHandle = popen(cmd.c_str(), "r");
+ FILE* cppHandle = popen(cmd.c_str(), "w");
+ pclose(cppHandle);
#endif
- if(cppHandle == 0)
- {
- cerr << argv[0] << ": can't run C++ preprocessor: "
- << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
+ }
+ else
+ {
+ string cmd = cpp + " " + argv[idx];
+#ifdef _WIN32
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
+#else
+ FILE* cppHandle = popen(cmd.c_str(), "r");
+#endif
+ if(cppHandle == 0)
+ {
+ cerr << argv[0] << ": can't run C++ preprocessor: "
+ << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
- UnitPtr unit = Unit::createUnit(false, false, ice);
- int parseStatus = unit->parse(cppHandle, debug);
+ UnitPtr unit = Unit::createUnit(false, false, ice);
+ int parseStatus = unit->parse(cppHandle, debug);
#ifdef _WIN32
- _pclose(cppHandle);
+ _pclose(cppHandle);
#else
- pclose(cppHandle);
+ pclose(cppHandle);
#endif
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], base, includePaths, package, output, clone);
- if(!gen)
- {
- unit->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(unit);
- if(tie)
- {
- gen.generateTie(unit);
- }
- if(impl)
- {
- gen.generateImpl(unit);
- }
- if(implTie)
- {
- gen.generateImplTie(unit);
- }
- }
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], base, includePaths, package, output, clone);
+ if(!gen)
+ {
+ unit->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(unit);
+ if(tie)
+ {
+ gen.generateTie(unit);
+ }
+ if(impl)
+ {
+ gen.generateImpl(unit);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(unit);
+ }
+ }
- unit->destroy();
+ unit->destroy();
+ }
}
return status;