diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-08-26 21:13:03 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-08-26 21:13:03 +0000 |
commit | afb824731409fee7eb5c2d99c9a7108cc1db1308 (patch) | |
tree | 7e8288dbe27ca4a8c15b2a39436d4005c000dee2 /cpp/src/slice2cpp/Main.cpp | |
parent | Removed redundant tests for include level from parser.cpp. Added (diff) | |
download | ice-afb824731409fee7eb5c2d99c9a7108cc1db1308.tar.bz2 ice-afb824731409fee7eb5c2d99c9a7108cc1db1308.tar.xz ice-afb824731409fee7eb5c2d99c9a7108cc1db1308.zip |
Added generation of dependencies between slice files.
Diffstat (limited to 'cpp/src/slice2cpp/Main.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Main.cpp | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index db69a5f8396..f20dacd6ce3 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -46,6 +46,7 @@ main(int argc, char* argv[]) bool impl = false; bool debug = false; bool ice = false; + bool depend = false; int idx = 1; while(idx < argc) @@ -163,6 +164,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] << "'" << endl; @@ -209,43 +219,65 @@ main(int argc, char* argv[]) } 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 + ".cpp " + 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, include, includePaths, dllExport, output, impl); - if(!gen) + + if(parseStatus == EXIT_FAILURE) { - unit->destroy(); - return EXIT_FAILURE; + status = EXIT_FAILURE; + } + else + { + Gen gen(argv[0], base, include, includePaths, dllExport, output, impl); + if(!gen) + { + unit->destroy(); + return EXIT_FAILURE; + } + gen.generate(unit); } - gen.generate(unit); - } - unit->destroy(); + unit->destroy(); + } } return status; |