diff options
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r-- | cpp/src/slice2cpp/.depend | 6 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 11 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 1 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Main.cpp | 20 |
4 files changed, 33 insertions, 5 deletions
diff --git a/cpp/src/slice2cpp/.depend b/cpp/src/slice2cpp/.depend index 53b14f49c16..e0fdaed0133 100644 --- a/cpp/src/slice2cpp/.depend +++ b/cpp/src/slice2cpp/.depend @@ -1,3 +1,3 @@ -Gen.o: Gen.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Config.h Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/Slice/OutputUtil.h GenUtil.h -GenUtil.o: GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h -Main.o: Main.cpp Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/Slice/OutputUtil.h +Gen.o: Gen.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/Slice/OutputUtil.h GenUtil.h +GenUtil.o: GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h +Main.o: Main.cpp Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 8ac993b9233..28f0f1dbc2f 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -32,7 +32,7 @@ struct ToIfdef }; Slice::Gen::Gen(const string& name, const string& base, const string& include, const vector<string>& includePaths, - const string& dllExport) : + const string& dllExport, const string& dir) : _base(base), _include(include), _includePaths(includePaths), @@ -59,6 +59,11 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c string fileH = _base + ".h"; string fileC = _base + ".cpp"; + if (!dir.empty()) + { + fileH = dir + '/' + fileH; + fileC = dir + '/' + fileC; + } H.open(fileH.c_str()); if (!H) @@ -78,6 +83,10 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c printHeader(C); string s = fileH; + if (_include.size()) + { + s = _include + '/' + s; + } transform(s.begin(), s.end(), s.begin(), ToIfdef()); H << "\n#ifndef __" << s << "__"; H << "\n#define __" << s << "__"; diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 693f064df50..8972d2f60f9 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -25,6 +25,7 @@ public: const std::string&, const std::string&, const std::vector<std::string>&, + const std::string&, const std::string&); ~Gen(); diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index b277edeadfa..5ae2b4b44ee 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -27,6 +27,7 @@ usage(const char* n) "-UNAME Remove any definition for NAME.\n" "-IDIR Put DIR in the include file search path.\n" "--include-dir DIR Use DIR as the header include directory.\n" + "--output-dir DIR Create files in the directory DIR.\n" "--dll-export SYMBOL Use SYMBOL for DLL exports.\n" "-d, --debug Print debug messages.\n" ; @@ -38,6 +39,7 @@ main(int argc, char* argv[]) string cpp("cpp"); vector<string> includePaths; string include; + string output; string dllExport; bool debug = false; @@ -107,6 +109,22 @@ main(int argc, char* argv[]) } argc -= 2; } + else if (strcmp(argv[idx], "--output-dir") == 0) + { + if (idx + 1 >= argc) + { + cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + output = argv[idx + 1]; + for (int i = idx ; i + 2 < argc ; ++i) + { + argv[i] = argv[i + 2]; + } + argc -= 2; + } else if (strcmp(argv[idx], "--dll-export") == 0) { if (idx + 1 >= argc) @@ -196,7 +214,7 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], base, include, includePaths, dllExport); + Gen gen(argv[0], base, include, includePaths, dllExport, output); if (!gen) { unit->destroy(); |