add priority sorting to $$resolve_depends()
all else being equal, items with a higher numerical priority will appear first in the result. Change-Id: I4ee37ff404a53c4152a1e4fc2fc3c23ef525234d Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
parent
1c23e51dbd
commit
26bbc40db9
@ -437,8 +437,9 @@ QByteArray QMakeEvaluator::getCommandOutput(const QString &args) const
|
||||
|
||||
void QMakeEvaluator::populateDeps(
|
||||
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,
|
||||
const ProString &priosfx,
|
||||
QHash<ProKey, QSet<ProKey> > &dependencies, ProValueMap &dependees,
|
||||
ProStringList &rootSet) const
|
||||
QMultiMap<int, ProString> &rootSet) const
|
||||
{
|
||||
foreach (const ProString &item, deps)
|
||||
if (!dependencies.contains(item.toKey())) {
|
||||
@ -447,13 +448,13 @@ void QMakeEvaluator::populateDeps(
|
||||
foreach (const ProString &suffix, suffixes)
|
||||
depends += values(ProKey(prefix + item + suffix));
|
||||
if (depends.isEmpty()) {
|
||||
rootSet << item;
|
||||
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
|
||||
} else {
|
||||
foreach (const ProString &dep, depends) {
|
||||
dset.insert(dep.toKey());
|
||||
dependees[dep.toKey()] << item;
|
||||
}
|
||||
populateDeps(depends, prefix, suffixes, dependencies, dependees, rootSet);
|
||||
populateDeps(depends, prefix, suffixes, priosfx, dependencies, dependees, rootSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -974,27 +975,31 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
||||
break;
|
||||
case E_SORT_DEPENDS:
|
||||
case E_RESOLVE_DEPENDS:
|
||||
if (args.count() < 1 || args.count() > 3) {
|
||||
evalError(fL1S("%1(var, [prefix, [suffixes]]) requires one to three arguments.")
|
||||
if (args.count() < 1 || args.count() > 4) {
|
||||
evalError(fL1S("%1(var, [prefix, [suffixes, [prio-suffix]]]) requires one to four arguments.")
|
||||
.arg(func.toQString(m_tmp1)));
|
||||
} else {
|
||||
QHash<ProKey, QSet<ProKey> > dependencies;
|
||||
ProValueMap dependees;
|
||||
ProStringList rootSet;
|
||||
QMultiMap<int, ProString> rootSet;
|
||||
ProStringList orgList = values(args.at(0).toKey());
|
||||
populateDeps(orgList, (args.count() < 2 ? ProString() : args.at(1)),
|
||||
ProString prefix = args.count() < 2 ? ProString() : args.at(1);
|
||||
ProString priosfx = args.count() < 4 ? ProString(".priority") : args.at(3);
|
||||
populateDeps(orgList, prefix,
|
||||
args.count() < 3 ? ProStringList(ProString(".depends"))
|
||||
: split_value_list(args.at(2).toQString(m_tmp2)),
|
||||
dependencies, dependees, rootSet);
|
||||
for (int i = 0; i < rootSet.size(); ++i) {
|
||||
const ProString &item = rootSet.at(i);
|
||||
priosfx, dependencies, dependees, rootSet);
|
||||
while (!rootSet.isEmpty()) {
|
||||
QMultiMap<int, ProString>::iterator it = rootSet.begin();
|
||||
const ProString item = *it;
|
||||
rootSet.erase(it);
|
||||
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
|
||||
ret.prepend(item);
|
||||
foreach (const ProString &dep, dependees[item.toKey()]) {
|
||||
QSet<ProKey> &dset = dependencies[dep.toKey()];
|
||||
dset.remove(rootSet.at(i).toKey()); // *Don't* use 'item' - rootSet may have changed!
|
||||
dset.remove(item.toKey());
|
||||
if (dset.isEmpty())
|
||||
rootSet << dep;
|
||||
rootSet.insert(first(ProKey(prefix + dep + priosfx)).toInt(), dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qlinkedlist.h>
|
||||
#include <qmap.h>
|
||||
#include <qset.h>
|
||||
#include <qstack.h>
|
||||
#include <qstring.h>
|
||||
@ -238,8 +239,9 @@ public:
|
||||
|
||||
void populateDeps(
|
||||
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,
|
||||
QHash<ProKey, QSet<ProKey> > &dependencies,
|
||||
ProValueMap &dependees, ProStringList &rootSet) const;
|
||||
const ProString &priosfx,
|
||||
QHash<ProKey, QSet<ProKey> > &dependencies, ProValueMap &dependees,
|
||||
QMultiMap<int, ProString> &rootSet) const;
|
||||
|
||||
VisitReturn writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode,
|
||||
const QString &contents);
|
||||
|
@ -173,3 +173,12 @@ testReplace($$shell_quote($$in), $$out, "shell_quote")
|
||||
testReplace($$reverse($$list(one two three)), three two one, "reverse")
|
||||
|
||||
testReplace($$cat(textfile), hi '"holla he"' 'hu!')
|
||||
|
||||
MOD.a.depends =
|
||||
MOD.b.depends =
|
||||
MOD.b.priority = 1
|
||||
MOD.c.depends = a b
|
||||
testReplace($$resolve_depends($$list(c), "MOD."), c b a)
|
||||
MOD.a.priority = 1
|
||||
MOD.b.priority = 0
|
||||
testReplace($$resolve_depends($$list(c), "MOD."), c a b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user