summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-07-11 15:40:07 +0200
committerQt by Nokia <qt-info@nokia.com>2011-12-13 19:39:18 +0100
commit44f28b79e09e0cd56944f438a3e4ed704a40edc9 (patch)
treee8cae7c7504a18d8a8ae06b541279e7aeacd5063 /src
parentb5c9a10959e6e665601565ed960910d1c105ec94 (diff)
downloadqttools-44f28b79e09e0cd56944f438a3e4ed704a40edc9.tar.gz
implement qt5 $$sort_depends() and $$resolve_depends()
Task-number: QTCREATORBUG-5289 Change-Id: I15e08005c13d12afd5791796d676b30c726fadc3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com> Reviewed-by: Daniel Teske <daniel.teske@nokia.com> (cherry picked from commit 330e118424f67d7e9de764b2d1fb1dad8000974e) (cherry picked from commit 7cd17f3f41dfbcf6c7cb791dd4db890815f8468c) Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/linguist/shared/profileevaluator.cpp57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/linguist/shared/profileevaluator.cpp b/src/linguist/shared/profileevaluator.cpp
index 0539efa4b..e0e4a2b10 100644
--- a/src/linguist/shared/profileevaluator.cpp
+++ b/src/linguist/shared/profileevaluator.cpp
@@ -307,6 +307,12 @@ public:
QStringList qmakeMkspecPaths() const;
QStringList qmakeFeaturePaths() const;
+ void populateDeps(
+ const ProStringList &deps, const ProString &prefix,
+ QHash<ProString, QSet<ProString> > &dependencies,
+ QHash<ProString, ProStringList> &dependees,
+ ProStringList &rootSet) const;
+
QString expandEnvVars(const QString &str) const;
QString fixPathToLocalOS(const QString &str) const;
QString sysrootify(const QString &path, const QString &baseDir) const;
@@ -351,7 +357,7 @@ public:
E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE,
- E_REPLACE
+ E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS
};
enum TestFunc {
@@ -452,7 +458,9 @@ void ProFileEvaluator::Private::initStatics()
{ "re_escape", E_RE_ESCAPE },
{ "files", E_FILES },
{ "prompt", E_PROMPT }, // interactive, so cannot be implemented
- { "replace", E_REPLACE }
+ { "replace", E_REPLACE },
+ { "sort_depends", E_SORT_DEPENDS },
+ { "resolve_depends", E_RESOLVE_DEPENDS }
};
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
statics.expands.insert(ProString(expandInits[i].name), expandInits[i].func);
@@ -2038,6 +2046,27 @@ ProStringList ProFileEvaluator::Private::expandVariableReferences(
}
}
+void ProFileEvaluator::Private::populateDeps(
+ const ProStringList &deps, const ProString &prefix,
+ QHash<ProString, QSet<ProString> > &dependencies, QHash<ProString, ProStringList> &dependees,
+ ProStringList &rootSet) const
+{
+ foreach (const ProString &item, deps)
+ if (!dependencies.contains(item)) {
+ QSet<ProString> &dset = dependencies[item]; // Always create entry
+ ProStringList depends = valuesDirect(ProString(prefix + item + QString::fromLatin1(".depends")));
+ if (depends.isEmpty()) {
+ rootSet << item;
+ } else {
+ foreach (const ProString &dep, depends) {
+ dset.insert(dep);
+ dependees[dep] << item;
+ }
+ populateDeps(depends, prefix, dependencies, dependees, rootSet);
+ }
+ }
+}
+
QList<ProStringList> ProFileEvaluator::Private::prepareFunctionArgs(const ushort *&tokPtr)
{
QList<ProStringList> args_list;
@@ -2541,6 +2570,30 @@ ProStringList ProFileEvaluator::Private::evaluateExpandFunction(
}
}
break;
+ case E_SORT_DEPENDS:
+ case E_RESOLVE_DEPENDS:
+ if (args.count() < 1 || args.count() > 2) {
+ evalError(fL1S("%1(var, prefix) requires one or two arguments").arg(func.toQString(m_tmp1)));
+ } else {
+ QHash<ProString, QSet<ProString> > dependencies;
+ QHash<ProString, ProStringList> dependees;
+ ProStringList rootSet;
+ ProStringList orgList = valuesDirect(args.at(0));
+ populateDeps(orgList, (args.count() < 2 ? ProString() : args.at(1)),
+ dependencies, dependees, rootSet);
+ for (int i = 0; i < rootSet.size(); ++i) {
+ const ProString &item = rootSet.at(i);
+ if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
+ ret.prepend(item);
+ foreach (const ProString &dep, dependees[item]) {
+ QSet<ProString> &dset = dependencies[dep];
+ dset.remove(rootSet.at(i)); // *Don't* use 'item' - rootSet may have changed!
+ if (dset.isEmpty())
+ rootSet << dep;
+ }
+ }
+ }
+ break;
case E_INVALID:
evalError(fL1S("'%1' is not a recognized replace function")
.arg(func.toQString(m_tmp1)));