summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-11-01 14:10:36 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-11-11 09:39:06 +0100
commitb314fe164427b931f2c226512b0603047f8e3103 (patch)
tree6b6fda11a2fe6e4a4b33b1b20539056367f2515c
parent7e2df73a397743777e4119e3646af17b5561b1a3 (diff)
downloadqbs-b314fe164427b931f2c226512b0603047f8e3103.tar.gz
Allow lists of patterns in the FileTagger item.
Rationale: It is not uncommon that the same tag is associated with more than one file pattern; more common, in fact, than the other way around. It therefore seems silly to force module authors to create one FileTagger item per file extension. For semantic consistency, the "pattern" property gets renamed to "patterns". The old name is still supported in this minor version. Change-Id: Ia7f744b0903462517582fcb549e2dab004c81dd5 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--doc/qbs.qdoc4
-rw-r--r--doc/reference/items/filetagger.qdoc9
-rw-r--r--share/qbs/modules/Qt/core/core.qbs10
-rw-r--r--share/qbs/modules/Qt/gui/gui.qbs2
-rw-r--r--share/qbs/modules/cpp/CppModule.qbs50
-rw-r--r--share/qbs/modules/cpp/windows-mingw.qbs2
-rw-r--r--share/qbs/modules/cpp/windows-msvc.qbs2
-rw-r--r--share/qbs/modules/ib/IBModule.qbs7
-rw-r--r--src/lib/language/builtindeclarations.cpp6
-rw-r--r--src/lib/language/language.cpp28
-rw-r--r--src/lib/language/language.h17
-rw-r--r--src/lib/language/projectresolver.cpp30
-rw-r--r--src/lib/language/testdata/filetags.qbs4
-rw-r--r--src/lib/tools/persistence.cpp2
-rw-r--r--tests/auto/blackbox/testdata/explicitlyDependsOn/project.qbs2
-rw-r--r--tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs2
16 files changed, 84 insertions, 93 deletions
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc
index 91ff72578..d633434a9 100644
--- a/doc/qbs.qdoc
+++ b/doc/qbs.qdoc
@@ -417,7 +417,7 @@
property path precompiledHeader
// ...
FileTagger {
- pattern: "*.cpp"
+ patterns: "*.cpp"
fileTags: ["cpp"]
}
Rule {...} // compiler
@@ -603,7 +603,7 @@
When you load the \a cpp module, you also load the following item:
\code
FileTagger {
- pattern: "*.cpp"
+ patterns: "*.cpp"
fileTags: ["cpp"]
}
\endcode
diff --git a/doc/reference/items/filetagger.qdoc b/doc/reference/items/filetagger.qdoc
index 4aa66603d..367612fef 100644
--- a/doc/reference/items/filetagger.qdoc
+++ b/doc/reference/items/filetagger.qdoc
@@ -42,7 +42,7 @@
the following file tagger:
\code
FileTagger {
- pattern: "*.cpp"
+ patterns: "*.cpp"
fileTags: ["cpp"]
}
\endcode
@@ -73,10 +73,11 @@
\li Default
\li Description
\row
- \li pattern
- \li string
+ \li patterns
+ \li stringList
\li none
- \li The pattern to match against. Supports the usual wildcards '*', '?' and '[]'.
+ \li The patterns to match against. Supports the usual wildcards '*', '?' and '[]'.
+ Neither the list itself nor any of its elements may be empty.
\row
\li fileTags
\li list
diff --git a/share/qbs/modules/Qt/core/core.qbs b/share/qbs/modules/Qt/core/core.qbs
index 64742406e..c940a1bfe 100644
--- a/share/qbs/modules/Qt/core/core.qbs
+++ b/share/qbs/modules/Qt/core/core.qbs
@@ -178,27 +178,27 @@ Module {
}
FileTagger {
- pattern: "*.qrc"
+ patterns: ["*.qrc"]
fileTags: ["qrc"]
}
FileTagger {
- pattern: "*.ts"
+ patterns: ["*.ts"]
fileTags: ["ts"]
}
FileTagger {
- pattern: "*.qdoc"
+ patterns: ["*.qdoc"]
fileTags: ["qdoc"]
}
FileTagger {
- pattern: "*.qdocconf"
+ patterns: ["*.qdocconf"]
fileTags: ["qdocconf"]
}
FileTagger {
- pattern: "*.qhp"
+ patterns: ["*.qhp"]
fileTags: ["qhp"]
}
diff --git a/share/qbs/modules/Qt/gui/gui.qbs b/share/qbs/modules/Qt/gui/gui.qbs
index 319f07008..a87d59cdc 100644
--- a/share/qbs/modules/Qt/gui/gui.qbs
+++ b/share/qbs/modules/Qt/gui/gui.qbs
@@ -9,7 +9,7 @@ QtModule {
property string uicName: "uic"
FileTagger {
- pattern: "*.ui"
+ patterns: ["*.ui"]
fileTags: ["ui"]
}
diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs
index e6841e499..f6c339d14 100644
--- a/share/qbs/modules/cpp/CppModule.qbs
+++ b/share/qbs/modules/cpp/CppModule.qbs
@@ -179,67 +179,27 @@ Module {
property string provisionFile
FileTagger {
- pattern: "*.c"
+ patterns: ["*.c"]
fileTags: ["c"]
}
FileTagger {
- pattern: "*.C"
+ patterns: ["*.C", "*.cpp", "*.cxx", "*.c++", "*.cc"]
fileTags: ["cpp"]
}
FileTagger {
- pattern: "*.cpp"
- fileTags: ["cpp"]
- }
-
- FileTagger {
- pattern: "*.cxx"
- fileTags: ["cpp"]
- }
-
- FileTagger {
- pattern: "*.c++"
- fileTags: ["cpp"]
- }
-
- FileTagger {
- pattern: "*.cc"
- fileTags: ["cpp"]
- }
-
- FileTagger {
- pattern: "*.m"
+ patterns: ["*.m"]
fileTags: ["objc"]
}
FileTagger {
- pattern: "*.mm"
+ patterns: ["*.mm"]
fileTags: ["objcpp"]
}
FileTagger {
- pattern: "*.h"
- fileTags: ["hpp"]
- }
-
- FileTagger {
- pattern: "*.H"
- fileTags: ["hpp"]
- }
-
- FileTagger {
- pattern: "*.hpp"
- fileTags: ["hpp"]
- }
-
- FileTagger {
- pattern: "*.hxx"
- fileTags: ["hpp"]
- }
-
- FileTagger {
- pattern: "*.h++"
+ patterns: ["*.h", "*.H", "*.hpp", "*.hxx", "*.h++"]
fileTags: ["hpp"]
}
}
diff --git a/share/qbs/modules/cpp/windows-mingw.qbs b/share/qbs/modules/cpp/windows-mingw.qbs
index 2cb80ca6b..c46a7432c 100644
--- a/share/qbs/modules/cpp/windows-mingw.qbs
+++ b/share/qbs/modules/cpp/windows-mingw.qbs
@@ -32,7 +32,7 @@ GenericGCC {
}
FileTagger {
- pattern: "*.rc"
+ patterns: ["*.rc"]
fileTags: ["rc"]
}
diff --git a/share/qbs/modules/cpp/windows-msvc.qbs b/share/qbs/modules/cpp/windows-msvc.qbs
index d3fd7c2a5..944a9e1fc 100644
--- a/share/qbs/modules/cpp/windows-msvc.qbs
+++ b/share/qbs/modules/cpp/windows-msvc.qbs
@@ -232,7 +232,7 @@ CppModule {
}
FileTagger {
- pattern: "*.rc"
+ patterns: ["*.rc"]
fileTags: ["rc"]
}
diff --git a/share/qbs/modules/ib/IBModule.qbs b/share/qbs/modules/ib/IBModule.qbs
index 3e470e4ff..32f212c02 100644
--- a/share/qbs/modules/ib/IBModule.qbs
+++ b/share/qbs/modules/ib/IBModule.qbs
@@ -18,12 +18,7 @@ Module {
property stringList flags
FileTagger {
- pattern: "*.nib"
- fileTags: ["nib"]
- }
-
- FileTagger {
- pattern: "*.xib"
+ patterns: ["*.nib", "*.xib"]
fileTags: ["nib"]
}
diff --git a/src/lib/language/builtindeclarations.cpp b/src/lib/language/builtindeclarations.cpp
index 7b38e7179..87beda2fd 100644
--- a/src/lib/language/builtindeclarations.cpp
+++ b/src/lib/language/builtindeclarations.cpp
@@ -198,7 +198,11 @@ void BuiltinDeclarations::addExportItem()
void BuiltinDeclarations::addFileTaggerItem()
{
QList<PropertyDeclaration> properties;
- properties += PropertyDeclaration(QLatin1String("pattern"), PropertyDeclaration::String);
+
+ // TODO: Remove in 1.3
+ properties += PropertyDeclaration(QLatin1String("pattern"), PropertyDeclaration::StringList);
+
+ properties += PropertyDeclaration(QLatin1String("patterns"), PropertyDeclaration::StringList);
properties += PropertyDeclaration(QLatin1String("fileTags"), PropertyDeclaration::Variant);
m_builtins[QLatin1String("FileTagger")] = properties;
}
diff --git a/src/lib/language/language.cpp b/src/lib/language/language.cpp
index 2d0448abf..131b5e4b4 100644
--- a/src/lib/language/language.cpp
+++ b/src/lib/language/language.cpp
@@ -69,19 +69,37 @@ QT_END_NAMESPACE
namespace qbs {
namespace Internal {
+FileTagger::FileTagger(const QStringList &patterns, const FileTags &fileTags)
+ : m_fileTags(fileTags)
+{
+ setPatterns(patterns);
+}
+
+void FileTagger::setPatterns(const QStringList &patterns)
+{
+ m_patterns.clear();
+ foreach (const QString &pattern, patterns) {
+ QBS_CHECK(!pattern.isEmpty());
+ m_patterns << QRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+ }
+}
+
/*!
* \class FileTagger
* \brief The \c FileTagger class maps 1:1 to the respective item in a qbs source file.
*/
void FileTagger::load(PersistentPool &pool)
{
- m_artifactExpression.setPattern(pool.idLoadString());
+ setPatterns(pool.idLoadStringList());
pool.stream() >> m_fileTags;
}
void FileTagger::store(PersistentPool &pool) const
{
- pool.storeString(m_artifactExpression.pattern());
+ QStringList patterns;
+ foreach (const QRegExp &regExp, m_patterns)
+ patterns << regExp.pattern();
+ pool.storeStringList(patterns);
pool.stream() << m_fileTags;
}
@@ -405,8 +423,10 @@ FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const
{
FileTags result;
foreach (FileTaggerConstPtr tagger, fileTaggers) {
- if (FileInfo::globMatches(tagger->artifactExpression(), fileName)) {
- result.unite(tagger->fileTags());
+ foreach (const QRegExp &pattern, tagger->patterns())
+ if (FileInfo::globMatches(pattern, fileName)) {
+ result.unite(tagger->fileTags());
+ break;
}
}
return result;
diff --git a/src/lib/language/language.h b/src/lib/language/language.h
index a467adc4d..98bf2f7f1 100644
--- a/src/lib/language/language.h
+++ b/src/lib/language/language.h
@@ -66,26 +66,23 @@ class FileTagger : public PersistentObject
{
public:
static FileTaggerPtr create() { return FileTaggerPtr(new FileTagger); }
- static FileTaggerPtr create(const QRegExp &artifactExpression, const FileTags &fileTags) {
- return FileTaggerPtr(new FileTagger(artifactExpression, fileTags));
+ static FileTaggerPtr create(const QStringList &patterns, const FileTags &fileTags) {
+ return FileTaggerPtr(new FileTagger(patterns, fileTags));
}
- const QRegExp &artifactExpression() const { return m_artifactExpression; }
+ const QList<QRegExp> &patterns() const { return m_patterns; }
const FileTags &fileTags() const { return m_fileTags; }
private:
- FileTagger(const QRegExp &artifactExpression, const FileTags &fileTags)
- : m_artifactExpression(artifactExpression), m_fileTags(fileTags)
- { }
+ FileTagger(const QStringList &patterns, const FileTags &fileTags);
+ FileTagger() {}
- FileTagger()
- : m_artifactExpression(QString(), Qt::CaseSensitive, QRegExp::Wildcard)
- {}
+ void setPatterns(const QStringList &patterns);
void load(PersistentPool &);
void store(PersistentPool &) const;
- QRegExp m_artifactExpression;
+ QList<QRegExp> m_patterns;
FileTags m_fileTags;
};
diff --git a/src/lib/language/projectresolver.cpp b/src/lib/language/projectresolver.cpp
index ef6ecc94b..af6f0a164 100644
--- a/src/lib/language/projectresolver.cpp
+++ b/src/lib/language/projectresolver.cpp
@@ -662,15 +662,29 @@ void ProjectResolver::resolveFileTagger(Item *item, ProjectContext *projectConte
checkCancelation();
QList<FileTaggerConstPtr> &fileTaggers = m_productContext
? m_productContext->product->fileTaggers : projectContext->fileTaggers;
- FileTaggerPtr tagger = FileTagger::create(
- QRegExp(m_evaluator->stringValue(item, QLatin1String("pattern")), Qt::CaseSensitive,
- QRegExp::Wildcard),
- m_evaluator->fileTagsValue(item, "fileTags"));
- if (tagger->artifactExpression().isEmpty())
- throw ErrorInfo(Tr::tr("FileTagger.pattern must not be empty."), item->location());
- if (tagger->fileTags().isEmpty())
+ QStringList patterns = m_evaluator->stringListValue(item, QLatin1String("patterns"));
+ const FileTags fileTags = m_evaluator->fileTagsValue(item, "fileTags");
+ if (fileTags.isEmpty())
throw ErrorInfo(Tr::tr("FileTagger.fileTags must not be empty."), item->location());
- fileTaggers += tagger;
+
+ // TODO: Remove in 1.3.
+ bool patternWasSet;
+ const QStringList oldPatterns = m_evaluator->stringListValue(item, QLatin1String("pattern"),
+ &patternWasSet);
+ if (patternWasSet) {
+ m_logger.printWarning(ErrorInfo(Tr::tr("The 'pattern' property is deprecated. Please "
+ "use 'patterns' instead."), item->location()));
+ patterns << oldPatterns;
+ }
+
+ if (patterns.isEmpty())
+ throw ErrorInfo(Tr::tr("FileTagger.patterns must be a non-empty list."), item->location());
+
+ foreach (const QString &pattern, patterns) {
+ if (pattern.isEmpty())
+ throw ErrorInfo(Tr::tr("A FileTagger pattern must not be empty."), item->location());
+ }
+ fileTaggers += FileTagger::create(patterns, fileTags);
}
void ProjectResolver::resolveTransformer(Item *item, ProjectContext *projectContext)
diff --git a/src/lib/language/testdata/filetags.qbs b/src/lib/language/testdata/filetags.qbs
index 894fe9298..97cccd510 100644
--- a/src/lib/language/testdata/filetags.qbs
+++ b/src/lib/language/testdata/filetags.qbs
@@ -2,7 +2,7 @@ import qbs 1.0
Project {
FileTagger {
- pattern: "*.cpp"
+ patterns: "*.cpp"
fileTags: ["cpp"]
}
@@ -15,7 +15,7 @@ Project {
name: "filetagger_product_scope"
files: ["drawline.asm"]
FileTagger {
- pattern: "*.asm"
+ patterns: "*.asm"
fileTags: ["asm"]
}
}
diff --git a/src/lib/tools/persistence.cpp b/src/lib/tools/persistence.cpp
index c6585012e..c40fa8470 100644
--- a/src/lib/tools/persistence.cpp
+++ b/src/lib/tools/persistence.cpp
@@ -40,7 +40,7 @@
namespace qbs {
namespace Internal {
-static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-53";
+static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-54";
PersistentPool::PersistentPool(const Logger &logger) : m_logger(logger)
{
diff --git a/tests/auto/blackbox/testdata/explicitlyDependsOn/project.qbs b/tests/auto/blackbox/testdata/explicitlyDependsOn/project.qbs
index ab98740c6..12ae1bd7e 100644
--- a/tests/auto/blackbox/testdata/explicitlyDependsOn/project.qbs
+++ b/tests/auto/blackbox/testdata/explicitlyDependsOn/project.qbs
@@ -5,7 +5,7 @@ Product {
type: "mytype"
files: "dependency.txt"
FileTagger {
- pattern: "*.txt"
+ patterns: "*.txt"
fileTags: ["txt"]
}
Transformer {
diff --git a/tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs b/tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs
index 62d7f8fe1..988c6657e 100644
--- a/tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs
+++ b/tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs
@@ -4,7 +4,7 @@ import qbs.TextFile
Module {
property bool buildZort: true
FileTagger {
- pattern: "*.narf"
+ patterns: "*.narf"
fileTags: ["narf"]
}
Rule {