diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-12-29 09:58:51 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-01-10 19:08:46 +0100 |
commit | ec14a51bff1d11382c5c879942fb335f177fdd44 (patch) | |
tree | 83e11d0fc56b0eec3516ad2a2bb454efb215cdcb | |
parent | 39792d65f528389f5bdef86588d066c8e7b10fe3 (diff) |
support globbing in dependency lines
Task-number: QTCREATORBUG-10439
Change-Id: I7d12a20441d9f5c6554e8832a14b0233a57da898
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r-- | changelog.txt | 1 | ||||
-rw-r--r-- | src/jomlib/parser.cpp | 26 | ||||
-rw-r--r-- | tests/makefiles/wildcardsInDependencies.mk | 1 | ||||
-rw-r--r-- | tests/tests.cpp | 17 | ||||
-rw-r--r-- | tests/tests.h | 1 |
5 files changed, 46 insertions, 0 deletions
diff --git a/changelog.txt b/changelog.txt index e015b41..0056215 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Changes since jom 1.0.13 - Fix error line numbers for inline files. (QTCREATORBUG-8451) - Ignore macro assignments in inline files. (QTCREATORBUG-8452) - Yield error on unexpected !ENDIF directive. +- Support wildcards in dependency lines. (QTCREATORBUG-10439) Changes since jom 1.0.12 - Fix spurious "Can't start command" error. diff --git a/src/jomlib/parser.cpp b/src/jomlib/parser.cpp index 7822a8a..662255f 100644 --- a/src/jomlib/parser.cpp +++ b/src/jomlib/parser.cpp @@ -25,6 +25,7 @@ #include <QDebug> #include <QDir> +#include <QDirIterator> namespace NMakeFile { @@ -314,6 +315,30 @@ static QStringList splitTargetNames(const QString& str) return lst; } +static QStringList expandWildcards(const QString &dirPath, const QStringList &lst) +{ + QStringList result; + result.reserve(lst.count()); + const QRegExp rex(QLatin1String("[*?]")); + foreach (const QString &str, lst) { + if (str.contains(rex)) { + QDirIterator dit(dirPath, QStringList(str)); + while (dit.hasNext()) { + QString filePath = dit.next(); + if (filePath.startsWith(dirPath, Qt::CaseInsensitive)) { + filePath.remove(0, dirPath.length()); + if (filePath.startsWith(QLatin1Char('/'))) + filePath.remove(0, 1); + } + result.append(filePath); + } + } else { + result.append(str); + } + } + return result; +} + void Parser::parseDescriptionBlock(int separatorPos, int separatorLength, int commandSeparatorPos) { QString target = m_line.left(separatorPos).trimmed(); @@ -345,6 +370,7 @@ void Parser::parseDescriptionBlock(int separatorPos, int separatorLength, int co const QStringList targets = splitTargetNames(target); QStringList dependents = splitTargetNames(value); + dependents = expandWildcards(m_makefile->dirPath(), dependents); // handle the special .SYNC dependents { diff --git a/tests/makefiles/wildcardsInDependencies.mk b/tests/makefiles/wildcardsInDependencies.mk new file mode 100644 index 0000000..1226ce4 --- /dev/null +++ b/tests/makefiles/wildcardsInDependencies.mk @@ -0,0 +1 @@ +all: *.txt foo?.cpp diff --git a/tests/tests.cpp b/tests/tests.cpp index ff96b3c..94f3382 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -856,6 +856,23 @@ void Tests::fileNameMacrosInDependents() QCOMPARE(target->m_dependents.takeFirst(), QLatin1String("C:\\MyProject\\tmp\\foo")); // $(*R) } +void Tests::wildcardsInDependencies() +{ + QVERIFY( openMakefile(QLatin1String("wildcardsInDependencies.mk")) ); + QScopedPointer<Makefile> mkfile(m_makefileFactory->makefile()); + QVERIFY(mkfile); + + DescriptionBlock *target = mkfile->firstTarget(); + QVERIFY(target); + QCOMPARE(target->targetName(), QLatin1String("all")); + + QCOMPARE(target->m_dependents.count(), 4); + QCOMPARE(target->m_dependents.at(0), QLatin1String("file#99.txt")); + QCOMPARE(target->m_dependents.at(1), QLatin1String("foo1.cpp")); + QCOMPARE(target->m_dependents.at(2), QLatin1String("foo3.cpp")); + QCOMPARE(target->m_dependents.at(3), QLatin1String("foo4.cpp")); +} + void Tests::windowsPathsInTargetName() { QVERIFY( openMakefile(QLatin1String("windowspaths.mk")) ); diff --git a/tests/tests.h b/tests/tests.h index 62b0603..ec265a5 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -61,6 +61,7 @@ private slots: void comments(); void fileNameMacros(); void fileNameMacrosInDependents(); + void wildcardsInDependencies(); void windowsPathsInTargetName(); // black-box tests |