summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorKeno Fischer <kenof@stanford.edu>2011-09-07 18:58:39 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-07 19:03:55 +0200
commitf41c900f0c72c1e1b08b9c64b0e3bf2b08ac50f9 (patch)
treedc59aa059fd4dc5f028e80658d9c9b7eab8e7297 /src/tools
parenta2b95242be5e71991a82f10ec94956ccbc4d5e60 (diff)
added -b<file> option to moc to support additional include files
Merge-request: 41 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Change-Id: I11a532b6ffe5f1c3e08aef8bc564e93f965b9e7c Reviewed-on: http://codereview.qt-project.org/4374 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/main.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index eaafd0a9fd..bf7e22c0b9 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -83,7 +83,8 @@ void error(const char *msg = "Invalid argument")
" -U<macro> undefine macro\n"
" -i do not generate an #include statement\n"
" -p<path> path prefix for included file\n"
- " -f[<file>] force #include, optional file name\n"
+ " -f[<file>] force #include, optional file name (overwrite default)\n"
+ " -b<file> prepend #include <file> (preserve default include)\n"
" -nn do not display notes\n"
" -nw do not display warnings\n"
" @<file> read additional options from file\n"
@@ -156,6 +157,7 @@ QByteArray composePreprocessorOutput(const Symbols &symbols) {
int runMoc(int _argc, char **_argv)
{
bool autoInclude = true;
+ bool defaultInclude = true;
Preprocessor pp;
Moc moc;
pp.macros["Q_MOC_RUN"];
@@ -226,8 +228,21 @@ int runMoc(int _argc, char **_argv)
break;
moc.noInclude = false;
autoInclude = false;
- if (opt[1]) // -fsomething.h
+ if (opt[1]) { // -fsomething.h
moc.includeFiles.append(opt.mid(1));
+ defaultInclude = false;
+ }
+ break;
+ case 'b':
+ if (ignoreConflictingOptions)
+ break;
+ if (!more) {
+ if (!(n < argc-1))
+ error("Missing file name for the -b option.");
+ moc.includeFiles.prepend(argv[++n]);
+ } else if (opt[1]) {
+ moc.includeFiles.prepend(opt.mid(1));
+ }
break;
case 'p': // include file path
if (ignoreConflictingOptions)
@@ -341,7 +356,7 @@ int runMoc(int _argc, char **_argv)
// spos >= -1 && ppos > spos => ppos >= 0
moc.noInclude = (ppos > spos && tolower(filename[ppos + 1]) != 'h');
}
- if (moc.includeFiles.isEmpty()) {
+ if (defaultInclude) {
if (moc.includePath.isEmpty()) {
if (filename.size()) {
if (output.size())