From 0dc9c8eb8535b1a678360e4d3183f0b1b5e79db3 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 8 Apr 2011 12:10:42 +0200 Subject: Add support for -unset option to qmake. Merge-request: 1175 Reviewed-by: Oswald Buddenhagen --- qmake/main.cpp | 4 +++- qmake/option.cpp | 6 +++++- qmake/option.h | 5 +++-- qmake/property.cpp | 14 ++++++++++++++ qmake/property.h | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/qmake/main.cpp b/qmake/main.cpp index 7dab23d..7d4d458 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -126,7 +126,9 @@ int runQMake(int argc, char **argv) } QMakeProperty prop; - if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY) + if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || + Option::qmake_mode == Option::QMAKE_SET_PROPERTY || + Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) return prop.exec() ? 0 : 101; QMakeProject project(&prop); diff --git a/qmake/option.cpp b/qmake/option.cpp index 1354281..c1b43e8 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -192,6 +192,7 @@ bool usage(const char *a0) " -norecursive Don't do a recursive search\n" " -recursive Do a recursive search\n" " -set Set persistent property\n" + " -unset Unset persistent property\n" " -query Query persistent property. Show all if is empty.\n" " -cache file Use file as cache [makefile mode only]\n" " -spec spec Use spec as QMAKESPEC [makefile mode only]\n" @@ -226,6 +227,8 @@ Option::parseCommandLine(int argc, char **argv, int skip) Option::qmake_mode = Option::QMAKE_GENERATE_PRL; } else if(opt == "set") { Option::qmake_mode = Option::QMAKE_SET_PROPERTY; + } else if(opt == "unset") { + Option::qmake_mode = Option::QMAKE_UNSET_PROPERTY; } else if(opt == "query") { Option::qmake_mode = Option::QMAKE_QUERY_PROPERTY; } else if(opt == "makefile") { @@ -336,7 +339,8 @@ Option::parseCommandLine(int argc, char **argv, int skip) } else { bool handled = true; if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || - Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { + Option::qmake_mode == Option::QMAKE_SET_PROPERTY || + Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { Option::prop::properties.append(arg); } else { QFileInfo fi(arg); diff --git a/qmake/option.h b/qmake/option.h index bc87343..e17ce5a 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -148,8 +148,9 @@ struct Option } //global qmake mode, can only be in one mode per invocation! - enum QMAKE_MODE { QMAKE_GENERATE_NOTHING, QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, - QMAKE_GENERATE_PRL, QMAKE_SET_PROPERTY, QMAKE_QUERY_PROPERTY }; + enum QMAKE_MODE { QMAKE_GENERATE_NOTHING, + QMAKE_GENERATE_PROJECT, QMAKE_GENERATE_MAKEFILE, QMAKE_GENERATE_PRL, + QMAKE_SET_PROPERTY, QMAKE_UNSET_PROPERTY, QMAKE_QUERY_PROPERTY }; static QMAKE_MODE qmake_mode; //all modes diff --git a/qmake/property.cpp b/qmake/property.cpp index d84f8e1..0c36c1c 100644 --- a/qmake/property.cpp +++ b/qmake/property.cpp @@ -160,6 +160,13 @@ QMakeProperty::setValue(QString var, const QString &val) settings->setValue(keyBase() + var, val); } +void +QMakeProperty::remove(const QString &var) +{ + initSettings(); + settings->remove(keyBase() + var); +} + bool QMakeProperty::exec() { @@ -230,6 +237,13 @@ QMakeProperty::exec() if(!var.startsWith(".")) setValue(var, (*it)); } + } else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { + for(QStringList::ConstIterator it = Option::prop::properties.begin(); + it != Option::prop::properties.end(); it++) { + QString var = (*it); + if(!var.startsWith(".")) + remove(var); + } } return ret; } diff --git a/qmake/property.h b/qmake/property.h index 43b7529..5e8379e 100644 --- a/qmake/property.h +++ b/qmake/property.h @@ -62,6 +62,7 @@ public: bool hasValue(QString); QString value(QString v) { return value(v, false); } void setValue(QString, const QString &); + void remove(const QString &); bool exec(); }; -- cgit v0.12