summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-06-07 05:35:03 +0000
committerMichi Henning <michi@zeroc.com>2004-06-07 05:35:03 +0000
commitdd5f0732236493306c97a701dec357353b450dbc (patch)
treefa874eefeaf5c997a76b1f6439624b055c3d0aea /cpp/src
parentFix (diff)
downloadice-dd5f0732236493306c97a701dec357353b450dbc.tar.bz2
ice-dd5f0732236493306c97a701dec357353b450dbc.tar.xz
ice-dd5f0732236493306c97a701dec357353b450dbc.zip
Removed --depend option from slice2java (because it was meaningless) and
changed preprocessor to be able to generate dependecies for C# makefiles.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp42
-rw-r--r--cpp/src/slice2cs/Main.cpp2
-rw-r--r--cpp/src/slice2java/Main.cpp81
3 files changed, 62 insertions, 63 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 7c736eb13df..822a8b24ba0 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -85,7 +85,7 @@ Slice::Preprocessor::preprocess(bool keepComments)
}
void
-Slice::Preprocessor::printMakefileDependencies()
+Slice::Preprocessor::printMakefileDependencies(const string& suffix)
{
if(!checkInputFile())
{
@@ -99,18 +99,36 @@ Slice::Preprocessor::printMakefileDependencies()
return;
}
- cmd += " -M " + _args + " " +_fileName;
+ cmd += " -M " + _args + " " + _fileName;
- //
- // Open a pipe for writing to redirect icecpp output to the standard output.
- //
-#ifndef _WIN32
- FILE* cppHandle = popen(cmd.c_str(), "w");
- pclose(cppHandle);
-#else
- FILE* cppHandle = _popen(cmd.c_str(), "w");
- _pclose(cppHandle);
-#endif
+ const char* cSuffix = suffix.c_str();
+
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
+
+ char buf[1024];
+ while(fgets(buf, sizeof(buf), cppHandle) != NULL)
+ {
+ char* dot;
+ char* colon = strchr(buf, ':');
+ if(colon != NULL)
+ {
+ *colon = '\0';
+ dot = strrchr(buf, '.');
+ *colon = ':';
+ if(dot != NULL)
+ {
+ if(strncmp(dot, ".cpp:", 5) == 0)
+ {
+ *dot = '\0';
+ fputs(buf, stdout);
+ fputs(cSuffix, stdout);
+ fputs(colon, stdout);
+ continue;
+ }
+ }
+ }
+ fputs(buf, stdout);
+ }
}
bool
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 36f999429bf..d96525324a5 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -209,7 +209,7 @@ main(int argc, char* argv[])
if(depend)
{
Preprocessor icecpp(argv[0], argv[idx], cppArgs);
- icecpp.printMakefileDependencies();
+ icecpp.printMakefileDependencies(".cs");
}
else
{
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 1e5d888b23e..4c52aa01f3c 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -29,7 +29,6 @@ usage(const char* n)
"--tie Generate TIE classes.\n"
"--impl Generate sample implementations.\n"
"--impl-tie Generate sample TIE implementations.\n"
- "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
;
@@ -48,7 +47,6 @@ main(int argc, char* argv[])
bool debug = false;
bool ice = false;
bool caseSensitive = false;
- bool depend = false;
int idx = 1;
while(idx < argc)
@@ -166,15 +164,6 @@ 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] << "'"
@@ -206,58 +195,50 @@ main(int argc, char* argv[])
for(idx = 1 ; idx < argc ; ++idx)
{
- if(depend)
+ Preprocessor icecpp(argv[0], argv[idx], cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = p->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
{
- Preprocessor icecpp(argv[0], argv[idx], cppArgs);
- icecpp.printMakefileDependencies();
+ status = EXIT_FAILURE;
}
else
{
- Preprocessor icecpp(argv[0], argv[idx], cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
+ if(!gen)
{
+ p->destroy();
return EXIT_FAILURE;
}
-
- UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = p->parse(cppHandle, debug);
-
- if(!icecpp.close())
+ gen.generate(p);
+ if(tie)
{
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
+ gen.generateTie(p);
+ }
+ if(impl)
{
- status = EXIT_FAILURE;
+ gen.generateImpl(p);
}
- else
+ if(implTie)
{
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
- {
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
+ gen.generateImplTie(p);
}
-
- p->destroy();
}
+
+ p->destroy();
}
return status;