diff options
author | Michi Henning <michi@zeroc.com> | 2004-06-07 05:35:03 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-06-07 05:35:03 +0000 |
commit | dd5f0732236493306c97a701dec357353b450dbc (patch) | |
tree | fa874eefeaf5c997a76b1f6439624b055c3d0aea /cpp/src/Slice/Preprocessor.cpp | |
parent | Fix (diff) | |
download | ice-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/Slice/Preprocessor.cpp')
-rw-r--r-- | cpp/src/Slice/Preprocessor.cpp | 42 |
1 files changed, 30 insertions, 12 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 |