summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-02-19 16:59:14 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2013-02-20 15:32:23 +0100
commitb723fb1247019b9b22b520bfcae217399bfee1b2 (patch)
treefa2173cd39f61f20bcd29a3282ad3a75be6c8fa6 /src
parent6e94ec0a1181949838d5b5f5c2049afd1521e04a (diff)
downloadqbs-b723fb1247019b9b22b520bfcae217399bfee1b2.tar.gz
introduce classes FileTag and FileTags
Stop inconsistent usage of QSet<QString> and QList<QString> to hold file tags. This is now unified by using a FileTags container class. The FileTag class is an alias for Id. Task-number: QBS-170 Change-Id: I8917942c4327a45d3d3604f4dc39bdee12801fdb Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/api/internaljobs.cpp2
-rw-r--r--src/lib/api/project.cpp6
-rw-r--r--src/lib/buildgraph/artifact.cpp4
-rw-r--r--src/lib/buildgraph/artifact.h4
-rw-r--r--src/lib/buildgraph/automoc.cpp65
-rw-r--r--src/lib/buildgraph/automoc.h5
-rw-r--r--src/lib/buildgraph/buildproduct.cpp10
-rw-r--r--src/lib/buildgraph/buildproject.cpp17
-rw-r--r--src/lib/buildgraph/inputartifactscanner.cpp2
-rw-r--r--src/lib/buildgraph/rulegraph.cpp14
-rw-r--r--src/lib/buildgraph/rulegraph.h5
-rw-r--r--src/lib/buildgraph/rulesapplicator.cpp25
-rw-r--r--src/lib/buildgraph/rulesapplicator.h3
-rw-r--r--src/lib/buildgraph/transformer.cpp15
-rw-r--r--src/lib/language/artifactproperties.h6
-rw-r--r--src/lib/language/filetags.cpp95
-rw-r--r--src/lib/language/filetags.h78
-rw-r--r--src/lib/language/language.cpp23
-rw-r--r--src/lib/language/language.h27
-rw-r--r--src/lib/language/language.pri2
-rw-r--r--src/lib/language/loader.cpp63
-rw-r--r--src/lib/language/tst_language.cpp2
-rw-r--r--src/lib/tools/id.cpp14
-rw-r--r--src/lib/tools/id.h2
-rw-r--r--src/lib/tools/persistence.cpp2
-rw-r--r--src/lib/tools/scannerpluginmanager.cpp4
-rw-r--r--src/lib/tools/scannerpluginmanager.h7
27 files changed, 343 insertions, 159 deletions
diff --git a/src/lib/api/internaljobs.cpp b/src/lib/api/internaljobs.cpp
index 31486e520..cad5399db 100644
--- a/src/lib/api/internaljobs.cpp
+++ b/src/lib/api/internaljobs.cpp
@@ -196,7 +196,7 @@ void InternalSetupProjectJob::execute()
logger().qbsDebug() << QString::fromLocal8Bit("for %1:").arg(rProject->id());
foreach (const ResolvedProductConstPtr &p, rProject->products) {
logger().qbsDebug() << QString::fromLocal8Bit(" - [%1] %2 as %3")
- .arg(p->fileTags.join(QLatin1String(", ")))
+ .arg(p->fileTags.toStringList().join(QLatin1String(", ")))
.arg(p->name).arg(p->project->id());
}
logger().qbsDebug() << '\n';
diff --git a/src/lib/api/project.cpp b/src/lib/api/project.cpp
index 69f3abff7..afbdd72ef 100644
--- a/src/lib/api/project.cpp
+++ b/src/lib/api/project.cpp
@@ -194,7 +194,7 @@ void ProjectPrivate::retrieveProjectData()
ProductData product;
product.m_name = resolvedProduct->name;
product.m_location = resolvedProduct->location;
- product.m_fileTags = resolvedProduct->fileTags;
+ product.m_fileTags = resolvedProduct->fileTags.toStringList();
product.m_properties = resolvedProduct->properties->value();
product.m_isEnabled = resolvedProduct->enabled;
foreach (const GroupPtr &resolvedGroup, resolvedProduct->groups) {
@@ -357,11 +357,11 @@ QString Project::targetExecutable(const ProductData &product, const QString &_in
if (!product.isEnabled())
return QString();
const BuildProductConstPtr buildProduct = d->internalProduct(product);
- if (!buildProduct->rProduct->fileTags.contains(QLatin1String("application")))
+ if (!buildProduct->rProduct->fileTags.contains("application"))
return QString();
foreach (const Artifact * const artifact, buildProduct->targetArtifacts) {
- if (artifact->fileTags.contains(QLatin1String("application"))) {
+ if (artifact->fileTags.contains("application")) {
if (!artifact->properties->qbsPropertyValue(QLatin1String("install")).toBool())
return artifact->filePath();
const QString fileName = FileInfo::fileName(artifact->filePath());
diff --git a/src/lib/buildgraph/artifact.cpp b/src/lib/buildgraph/artifact.cpp
index f5df0d261..b85219701 100644
--- a/src/lib/buildgraph/artifact.cpp
+++ b/src/lib/buildgraph/artifact.cpp
@@ -81,11 +81,11 @@ void Artifact::setFilePath(const QString &filePath)
void Artifact::load(PersistentPool &pool)
{
setFilePath(pool.idLoadString());
- fileTags = pool.idLoadStringSet();
properties = pool.idLoadS<PropertyMap>();
transformer = pool.idLoadS<Transformer>();
unsigned char c;
pool.stream()
+ >> fileTags
>> artifactType
>> timestamp
>> autoMocTimestamp
@@ -96,10 +96,10 @@ void Artifact::load(PersistentPool &pool)
void Artifact::store(PersistentPool &pool) const
{
pool.storeString(m_filePath);
- pool.storeStringSet(fileTags);
pool.store(properties);
pool.store(transformer);
pool.stream()
+ << fileTags
<< artifactType
<< timestamp
<< autoMocTimestamp
diff --git a/src/lib/buildgraph/artifact.h b/src/lib/buildgraph/artifact.h
index 0485f876f..b6e88d93a 100644
--- a/src/lib/buildgraph/artifact.h
+++ b/src/lib/buildgraph/artifact.h
@@ -32,11 +32,11 @@
#include "artifactlist.h"
#include "forward_decls.h"
+#include <language/filetags.h>
#include <language/forward_decls.h>
#include <tools/filetime.h>
#include <tools/persistentobject.h>
-#include <QSet>
#include <QString>
namespace qbs {
@@ -63,7 +63,7 @@ public:
ArtifactList parents;
ArtifactList children;
ArtifactList fileDependencies;
- QSet<QString> fileTags;
+ FileTags fileTags;
BuildProject *project;
BuildProduct *product; // Note: file dependency artifacts don't belong to a product.
TransformerPtr transformer;
diff --git a/src/lib/buildgraph/automoc.cpp b/src/lib/buildgraph/automoc.cpp
index 88f65597a..e3b85c068 100644
--- a/src/lib/buildgraph/automoc.cpp
+++ b/src/lib/buildgraph/automoc.cpp
@@ -45,15 +45,15 @@
namespace qbs {
namespace Internal {
-static char **createCFileTags(const QSet<QString> &fileTags)
+static char **createCFileTags(const FileTags &fileTags)
{
if (fileTags.isEmpty())
return 0;
char **buf = new char*[fileTags.count()];
size_t i = 0;
- foreach (const QString &fileTag, fileTags) {
- buf[i] = qstrdup(fileTag.toLocal8Bit().data());
+ foreach (const FileTag &fileTag, fileTags) {
+ buf[i] = qstrdup(fileTag.toString().toLocal8Bit().data());
++i;
}
return buf;
@@ -94,15 +94,15 @@ void AutoMoc::apply(const BuildProductPtr &product)
for (; it != product->artifacts.end(); ++it) {
Artifact *artifact = *it;
if (!pchFile || !pluginMetaDataFile) {
- foreach (const QString &fileTag, artifact->fileTags) {
- if (fileTag == QLatin1String("c++_pch"))
+ foreach (const FileTag &fileTag, artifact->fileTags) {
+ if (fileTag == "c++_pch")
pchFile = artifact;
- else if (fileTag == QLatin1String("qt_plugin_metadata"))
+ else if (fileTag == "qt_plugin_metadata")
pluginMetaDataFile = artifact;
}
}
- if (!pluginMetaDataFile && artifact->fileTags.contains(QLatin1String("qt_plugin_metadata"))) {
+ if (!pluginMetaDataFile && artifact->fileTags.contains("qt_plugin_metadata")) {
if (m_logger.debugEnabled()) {
m_logger.qbsDebug() << "[AUTOMOC] found Qt plugin metadata file "
<< artifact->filePath();
@@ -117,7 +117,7 @@ void AutoMoc::apply(const BuildProductPtr &product)
const FileType fileType = AutoMoc::fileType(artifact);
if (fileType == UnknownFileType)
continue;
- QString mocFileTag;
+ FileTag mocFileTag;
bool alreadyMocced = isVictimOfMoc(artifact, fileType, mocFileTag);
bool hasQObjectMacro;
scan(artifact, hasQObjectMacro, includedMocCppFiles);
@@ -134,22 +134,22 @@ void AutoMoc::apply(const BuildProductPtr &product)
const QPair<Artifact *, FileType> &p = artifactsToMoc.at(i);
Artifact * const artifact = p.first;
FileType fileType = p.second;
- foreach (const QString &fileTag, artifact->fileTags) {
- if (fileTag == QLatin1String("moc_hpp")) {
+ foreach (const FileTag &fileTag, artifact->fileTags) {
+ if (fileTag == "moc_hpp") {
const QString mocFileName = generateMocFileName(artifact, fileType);
if (includedMocCppFiles.contains(mocFileName)) {
- QString newFileTag = QLatin1String("moc_hpp_inc");
+ FileTag newFileTag = "moc_hpp_inc";
artifact->fileTags -= fileTag;
artifact->fileTags += newFileTag;
artifactsPerFileTag[newFileTag].insert(artifact);
continue;
}
- } else if (fileTag == QLatin1String("moc_plugin_hpp")) {
+ } else if (fileTag == "moc_plugin_hpp") {
if (m_logger.debugEnabled()) {
m_logger.qbsDebug() << "[AUTOMOC] found Qt plugin header file "
<< artifact->filePath();
}
- QString newFileTag = QLatin1String("moc_hpp");
+ FileTag newFileTag = "moc_hpp";
artifact->fileTags -= fileTag;
artifact->fileTags += newFileTag;
artifactsPerFileTag[newFileTag].insert(artifact);
@@ -160,7 +160,7 @@ void AutoMoc::apply(const BuildProductPtr &product)
}
if (pchFile)
- artifactsPerFileTag[QLatin1String("c++_pch")] += pchFile;
+ artifactsPerFileTag["c++_pch"] += pchFile;
if (!artifactsPerFileTag.isEmpty()) {
emit reportCommandDescription(QLatin1String("automoc"),
Tr::tr("Applying moc rules for '%1'.")
@@ -195,10 +195,10 @@ QString AutoMoc::generateMocFileName(Artifact *artifact, FileType fileType)
AutoMoc::FileType AutoMoc::fileType(Artifact *artifact)
{
- foreach (const QString &fileTag, artifact->fileTags)
- if (fileTag == QLatin1String("hpp"))
+ foreach (const FileTag &fileTag, artifact->fileTags)
+ if (fileTag == "hpp")
return HppFileType;
- else if (fileTag == QLatin1String("cpp"))
+ else if (fileTag == "cpp")
return CppFileType;
return UnknownFileType;
}
@@ -222,10 +222,12 @@ void AutoMoc::scan(Artifact *artifact, bool &hasQObjectMacro, QSet<QString> &inc
const char **szFileTagsFromScanner = scanner->additionalFileTags(opaq, &length);
if (szFileTagsFromScanner && length > 0) {
for (int i=length; --i >= 0;) {
- const QString fileTagFromScanner = QString::fromLocal8Bit(szFileTagsFromScanner[i]);
- artifact->fileTags.insert(fileTagFromScanner);
+ artifact->fileTags.insert(szFileTagsFromScanner[i]);
if (m_logger.traceEnabled())
m_logger.qbsTrace() << "[AUTOMOC] finds Q_OBJECT macro";
+ const QByteArray fileTagFromScanner
+ = QByteArray::fromRawData(szFileTagsFromScanner[i],
+ strlen(szFileTagsFromScanner[i]));
if (fileTagFromScanner.startsWith("moc"))
hasQObjectMacro = true;
}
@@ -272,18 +274,23 @@ void AutoMoc::scan(Artifact *artifact, bool &hasQObjectMacro, QSet<QString> &inc
freeCFileTags(cFileTags, numFileTags);
}
-bool AutoMoc::isVictimOfMoc(Artifact *artifact, FileType fileType, QString &foundMocFileTag)
+static FileTags provideMocHeaderFileTags()
{
- static const QSet<QString> mocHeaderFileTags = QSet<QString>() << QLatin1String("moc_hpp")
- << QLatin1String("moc_hpp_inc")
- << QLatin1String("moc_plugin_hpp");
- static const QString mocCppFileTag = QLatin1String("moc_cpp");
+ FileTags fileTags;
+ fileTags << "moc_hpp" << "moc_hpp_inc" << "moc_plugin_hpp";
+ return fileTags;
+}
+
+bool AutoMoc::isVictimOfMoc(Artifact *artifact, FileType fileType, FileTag &foundMocFileTag)
+{
+ static const FileTags mocHeaderFileTags = provideMocHeaderFileTags();
+ static const FileTag mocCppFileTag = "moc_cpp";
foundMocFileTag.clear();
switch (fileType) {
case UnknownFileType:
break;
case HppFileType:
- foreach (const QString &fileTag, artifact->fileTags) {
+ foreach (const FileTag &fileTag, artifact->fileTags) {
if (mocHeaderFileTags.contains(fileTag)) {
foundMocFileTag = fileTag;
break;
@@ -295,10 +302,10 @@ bool AutoMoc::isVictimOfMoc(Artifact *artifact, FileType fileType, QString &foun
foundMocFileTag = mocCppFileTag;
break;
}
- return !foundMocFileTag.isEmpty();
+ return foundMocFileTag.isValid();
}
-void AutoMoc::unmoc(Artifact *artifact, const QString &mocFileTag)
+void AutoMoc::unmoc(Artifact *artifact, const FileTag &mocFileTag)
{
if (m_logger.traceEnabled())
m_logger.qbsTrace() << "[AUTOMOC] unmoc'ing " << relativeArtifactFileName(artifact);
@@ -307,7 +314,7 @@ void AutoMoc::unmoc(Artifact *artifact, const QString &mocFileTag)
Artifact *generatedMocArtifact = 0;
foreach (Artifact *parent, artifact->parents) {
- foreach (const QString &fileTag, parent->fileTags) {
+ foreach (const FileTag &fileTag, parent->fileTags) {
if (fileTag == "hpp" || fileTag == "cpp") {
generatedMocArtifact = parent;
break;
@@ -323,7 +330,7 @@ void AutoMoc::unmoc(Artifact *artifact, const QString &mocFileTag)
if (mocFileTag == "moc_hpp") {
Artifact *mocObjArtifact = 0;
foreach (Artifact *parent, generatedMocArtifact->parents) {
- foreach (const QString &fileTag, parent->fileTags) {
+ foreach (const FileTag &fileTag, parent->fileTags) {
if (fileTag == "obj" || fileTag == "fpicobj") {
mocObjArtifact = parent;
break;
diff --git a/src/lib/buildgraph/automoc.h b/src/lib/buildgraph/automoc.h
index 524155858..6d6b7c510 100644
--- a/src/lib/buildgraph/automoc.h
+++ b/src/lib/buildgraph/automoc.h
@@ -40,6 +40,7 @@ struct ScannerPlugin;
namespace qbs {
namespace Internal {
+class FileTag;
class ScanResultCache;
/**
@@ -75,8 +76,8 @@ private:
static QString generateMocFileName(Artifact *artifact, FileType fileType);
static FileType fileType(Artifact *artifact);
void scan(Artifact *artifact, bool &hasQObjectMacro, QSet<QString> &includedMocCppFiles);
- bool isVictimOfMoc(Artifact *artifact, FileType fileType, QString &foundMocFileTag);
- void unmoc(Artifact *artifact, const QString &mocFileTag);
+ bool isVictimOfMoc(Artifact *artifact, FileType fileType, FileTag &foundMocFileTag);
+ void unmoc(Artifact *artifact, const FileTag &mocFileTag);
QList<ScannerPlugin *> scanners() const;
mutable QList<ScannerPlugin *> m_scanners;
diff --git a/src/lib/buildgraph/buildproduct.cpp b/src/lib/buildgraph/buildproduct.cpp
index 1459a6168..2cfed960b 100644
--- a/src/lib/buildgraph/buildproduct.cpp
+++ b/src/lib/buildgraph/buildproduct.cpp
@@ -65,7 +65,7 @@ static void internalDump(const BuildProduct *product, Artifact *artifact, QByteA
qPrintable(QString(toString(artifact->buildState).at(0))),
artifactInProduct ? "" : " SBS", // SBS == side-by-side artifact from other product
qPrintable(artifact->filePath()),
- qPrintable(QStringList(artifact->fileTags.toList()).join(",")));
+ qPrintable(artifact->fileTags.toStringList().join(QLatin1String(", "))));
printf("\n");
indent.append(" ");
foreach (Artifact *child, artifact->children) {
@@ -83,12 +83,10 @@ void BuildProduct::dump() const
const QList<RuleConstPtr> &BuildProduct::topSortedRules() const
{
if (m_topSortedRules.isEmpty()) {
- QStringList fileTags;
- fileTags << rProduct->fileTags << rProduct->additionalFileTags;
- fileTags.sort();
- std::unique(fileTags.begin(), fileTags.end());
+ FileTags productFileTags = rProduct->fileTags;
+ productFileTags += rProduct->additionalFileTags;
RuleGraph ruleGraph;
- ruleGraph.build(rProduct->rules, fileTags);
+ ruleGraph.build(rProduct->rules, productFileTags);
// ruleGraph.dump();
m_topSortedRules = ruleGraph.topSorted();
// int i=0;
diff --git a/src/lib/buildgraph/buildproject.cpp b/src/lib/buildgraph/buildproject.cpp
index e4b8d15ef..84f58c70e 100644
--- a/src/lib/buildgraph/buildproject.cpp
+++ b/src/lib/buildgraph/buildproject.cpp
@@ -246,7 +246,7 @@ void BuildProject::updateNodeThatMustGetNewTransformer(Artifact *artifact)
ArtifactsPerFileTagMap artifactsPerFileTag;
foreach (Artifact *input, artifact->children) {
- foreach (const QString &fileTag, input->fileTags)
+ foreach (const FileTag &fileTag, input->fileTags)
artifactsPerFileTag[fileTag] += input;
}
RulesApplicator rulesApplier(artifact->product, artifactsPerFileTag, m_logger);
@@ -313,7 +313,7 @@ BuildProjectPtr BuildProjectResolver::resolveProject(const ResolvedProjectPtr &r
static void addTargetArtifacts(const BuildProductPtr &product,
ArtifactsPerFileTagMap &artifactsPerFileTag, const Logger &logger)
{
- foreach (const QString &fileTag, product->rProduct->fileTags) {
+ foreach (const FileTag &fileTag, product->rProduct->fileTags) {
foreach (Artifact * const artifact, artifactsPerFileTag.value(fileTag)) {
if (artifact->artifactType == Artifact::Generated)
product->targetArtifacts += artifact;
@@ -369,7 +369,7 @@ BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &r
continue; // ignore duplicate artifacts
Artifact *artifact = product->createArtifact(sourceArtifact, m_logger);
- foreach (const QString &fileTag, artifact->fileTags)
+ foreach (const FileTag &fileTag, artifact->fileTags)
artifactsPerFileTag[fileTag].insert(artifact);
}
@@ -385,7 +385,6 @@ BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &r
TransformerPtr transformer = Transformer::create();
transformer->inputs = inputArtifacts;
const RulePtr rule = Rule::create();
- rule->inputs = rtrafo->inputs;
rule->jsImports = rtrafo->jsImports;
ResolvedModulePtr module = ResolvedModule::create();
module->name = rtrafo->module->name;
@@ -399,12 +398,12 @@ BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &r
product->targetArtifacts += outputArtifact;
foreach (Artifact *inputArtifact, inputArtifacts)
safeConnect(outputArtifact, inputArtifact, m_logger);
- foreach (const QString &fileTag, outputArtifact->fileTags)
+ foreach (const FileTag &fileTag, outputArtifact->fileTags)
artifactsPerFileTag[fileTag].insert(outputArtifact);
RuleArtifactPtr ruleArtifact = RuleArtifact::create();
ruleArtifact->fileName = outputArtifact->filePath();
- ruleArtifact->fileTags = outputArtifact->fileTags.toList();
+ ruleArtifact->fileTags = outputArtifact->fileTags;
rule->artifacts += ruleArtifact;
}
transformer->rule = rule;
@@ -654,11 +653,11 @@ void BuildProjectLoader::onProductChanged(const BuildProductPtr &product,
QBS_CHECK(artifact);
// handle added filetags
- foreach (const QString &addedFileTag, changedArtifact->fileTags - a->fileTags)
+ foreach (const FileTag &addedFileTag, changedArtifact->fileTags - a->fileTags)
artifactsPerFileTag[addedFileTag] += artifact;
// handle removed filetags
- foreach (const QString &removedFileTag, a->fileTags - changedArtifact->fileTags) {
+ foreach (const FileTag &removedFileTag, a->fileTags - changedArtifact->fileTags) {
artifact->fileTags -= removedFileTag;
foreach (Artifact *parent, artifact->parents) {
if (parent->transformer && parent->transformer->rule->inputs.contains(removedFileTag)) {
@@ -676,7 +675,7 @@ void BuildProjectLoader::onProductChanged(const BuildProductPtr &product,
// apply rules for new artifacts
foreach (Artifact *artifact, addedArtifacts)
- foreach (const QString &ft, artifact->fileTags)
+ foreach (const FileTag &ft, artifact->fileTags)
artifactsPerFileTag[ft] += artifact;
RulesApplicator(product.data(), artifactsPerFileTag, m_logger).applyAllRules();
diff --git a/src/lib/buildgraph/inputartifactscanner.cpp b/src/lib/buildgraph/inputartifactscanner.cpp
index 0d5c98e70..4085e5a58 100644
--- a/src/lib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/buildgraph/inputartifactscanner.cpp
@@ -173,7 +173,7 @@ void InputArtifactScanner::scan()
bool mustCollectIncludePaths = false;
QSet<ScannerPlugin *> scanners;
- foreach (const QString &fileTag, inputArtifact->fileTags) {
+ foreach (const FileTag &fileTag, inputArtifact->fileTags) {
foreach (ScannerPlugin *scanner, ScannerPluginManager::scannersForFileTag(fileTag)) {
scanners += scanner;
if (scanner->flags & ScannerUsesCppIncludePaths)
diff --git a/src/lib/buildgraph/rulegraph.cpp b/src/lib/buildgraph/rulegraph.cpp
index 73779ebac..fa922dfb9 100644
--- a/src/lib/buildgraph/rulegraph.cpp
+++ b/src/lib/buildgraph/rulegraph.cpp
@@ -38,12 +38,12 @@ RuleGraph::RuleGraph()
{
}
-void RuleGraph::build(const QSet<RulePtr> &rules, const QStringList &productFileTags)
+void RuleGraph::build(const QSet<RulePtr> &rules, const FileTags &productFileTags)
{
- QMap<QString, QList<const Rule *> > inputFileTagToRule;
+ QMap<FileTag, QList<const Rule *> > inputFileTagToRule;
m_artifacts.reserve(rules.count());
foreach (const RulePtr &rule, rules) {
- foreach (const QString &fileTag, rule->outputFileTags())
+ foreach (const FileTag &fileTag, rule->outputFileTags())
m_outputFileTagToRule[fileTag].append(rule.data());
insert(rule);
}
@@ -52,9 +52,9 @@ void RuleGraph::build(const QSet<RulePtr> &rules, const QStringList &productFile
m_children.resize(rules.count());
foreach (const RuleConstPtr &rule, m_artifacts) {
- QStringList inFileTags = rule->inputs;
+ FileTags inFileTags = rule->inputs;
inFileTags += rule->explicitlyDependsOn;
- foreach (const QString &fileTag, inFileTags) {
+ foreach (const FileTag &fileTag, inFileTags) {
inputFileTagToRule[fileTag].append(rule.data());
foreach (const Rule * const consumingRule, m_outputFileTagToRule.value(fileTag)) {
connect(rule.data(), consumingRule);
@@ -63,8 +63,8 @@ void RuleGraph::build(const QSet<RulePtr> &rules, const QStringList &productFile
}
QList<const Rule *> productRules;
- for (int i=0; i < productFileTags.count(); ++i) {
- QList<const Rule *> rules = m_outputFileTagToRule.value(productFileTags.at(i));
+ foreach (const FileTag &productFileTag, productFileTags) {
+ QList<const Rule *> rules = m_outputFileTagToRule.value(productFileTag);
productRules += rules;
//### check: the rule graph must be a in valid shape!
}
diff --git a/src/lib/buildgraph/rulegraph.h b/src/lib/buildgraph/rulegraph.h
index d56bc298d..e1a511751 100644
--- a/src/lib/buildgraph/rulegraph.h
+++ b/src/lib/buildgraph/rulegraph.h
@@ -30,6 +30,7 @@
#ifndef QBS_RULEGRAPH_H
#define QBS_RULEGRAPH_H
+#include <language/filetags.h>
#include <language/forward_decls.h>
#include <QList>
@@ -46,7 +47,7 @@ class RuleGraph
public:
RuleGraph();
- void build(const QSet<RulePtr> &rules, const QStringList &productFileTag);
+ void build(const QSet<RulePtr> &rules, const FileTags &productFileTag);
QList<RuleConstPtr> topSorted();
void dump() const;
@@ -61,7 +62,7 @@ private:
QList<RuleConstPtr> topSort(const RuleConstPtr &rule);
private:
- QMap<QString, QList<const Rule*> > m_outputFileTagToRule;
+ QMap<FileTag, QList<const Rule*> > m_outputFileTagToRule;
QVector<RulePtr> m_artifacts;
QVector< QVector<int> > m_parents;
QVector< QVector<int> > m_children;
diff --git a/src/lib/buildgraph/rulesapplicator.cpp b/src/lib/buildgraph/rulesapplicator.cpp
index dd089f11e..ee38933c6 100644
--- a/src/lib/buildgraph/rulesapplicator.cpp
+++ b/src/lib/buildgraph/rulesapplicator.cpp
@@ -70,7 +70,7 @@ void RulesApplicator::applyRule(const RuleConstPtr &rule)
"BG", "Product object is not in current scope.");
ArtifactList inputArtifacts;
- foreach (const QString &fileTag, m_rule->inputs)
+ foreach (const FileTag &fileTag, m_rule->inputs)
inputArtifacts.unite(m_artifactsPerFileTag.value(fileTag));
if (m_rule->multiplex) { // apply the rule once for a set of inputs
if (!inputArtifacts.isEmpty())
@@ -100,13 +100,13 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts)
ArtifactList usingArtifacts;
if (!m_rule->usings.isEmpty()) {
- const QSet<QString> usingsFileTags = m_rule->usings.toSet();
+ const FileTags usingsFileTags = m_rule->usings;
foreach (const BuildProductPtr &dep, m_buildProduct->dependencies) {
ArtifactList artifactsToCheck;
foreach (Artifact *targetArtifact, dep->targetArtifacts)
artifactsToCheck.unite(targetArtifact->transformer->outputs);
foreach (Artifact *artifact, artifactsToCheck) {
- QSet<QString> matchingFileTags = artifact->fileTags;
+ FileTags matchingFileTags = artifact->fileTags;
matchingFileTags.intersect(usingsFileTags);
if (!matchingFileTags.isEmpty())
usingArtifacts.insert(artifact);
@@ -124,11 +124,11 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts)
foreach (Artifact *outputArtifact, outputArtifacts) {
// insert the output artifacts into the pool of artifacts
- foreach (const QString &fileTag, outputArtifact->fileTags)
+ foreach (const FileTag &fileTag, outputArtifact->fileTags)
m_artifactsPerFileTag[fileTag].insert(outputArtifact);
// connect artifacts that match the file tags in explicitlyDependsOn
- foreach (const QString &fileTag, m_rule->explicitlyDependsOn)
+ foreach (const FileTag &fileTag, m_rule->explicitlyDependsOn)
foreach (Artifact *dependency, m_artifactsPerFileTag.value(fileTag))
loggedConnect(outputArtifact, dependency, m_logger);
@@ -159,7 +159,8 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts)
outputArtifact->properties = outputArtifact->properties->clone();
scope().setProperty("fileName", engine()->toScriptValue(outputArtifact->filePath()));
- scope().setProperty("fileTags", toScriptValue(engine(), outputArtifact->fileTags));
+ scope().setProperty("fileTags",
+ toScriptValue(engine(), outputArtifact->fileTags.toStringList()));
QVariantMap artifactModulesCfg = outputArtifact->properties->value().value("modules").toMap();
for (int i=0; i < ra->bindings.count(); ++i) {
@@ -236,10 +237,10 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule
m_transformer->inputs.unite(inputArtifacts);
if (m_transformer->inputs.count() > 1 && !m_rule->multiplex) {
- QString th = "[" + QStringList(outputArtifact->fileTags.toList()).join(", ") + "]";
+ QString th = "[" + outputArtifact->fileTags.toStringList().join(", ") + "]";
QString e = Tr::tr("Conflicting rules for producing %1 %2 \n").arg(outputArtifact->filePath(), th);
- th = "[" + m_rule->inputs.join(", ")
- + "] -> [" + QStringList(outputArtifact->fileTags.toList()).join(", ") + "]";
+ th = "[" + m_rule->inputs.toStringList().join(", ")
+ + "] -> [" + outputArtifact->fileTags.toStringList().join(", ") + "]";
e += QString(" while trying to apply: %1:%2:%3 %4\n")
.arg(m_rule->script->location.fileName)
@@ -255,12 +256,12 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule
throw Error(e);
}
}
- outputArtifact->fileTags += ruleArtifact->fileTags.toSet();
+ outputArtifact->fileTags += ruleArtifact->fileTags;
} else {
outputArtifact = new Artifact(m_buildProduct->project);
outputArtifact->artifactType = Artifact::Generated;
outputArtifact->setFilePath(outputPath);
- outputArtifact->fileTags = ruleArtifact->fileTags.toSet();
+ outputArtifact->fileTags = ruleArtifact->fileTags;
outputArtifact->alwaysUpdated = ruleArtifact->alwaysUpdated;
m_buildProduct->insertArtifact(outputArtifact, m_logger);
}
@@ -275,7 +276,7 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule
for (int i = 0; i < m_buildProduct->rProduct->artifactProperties.count(); ++i) {
const ArtifactPropertiesConstPtr &props = m_buildProduct->rProduct->artifactProperties.at(i);
- QSet<QString> filter = props->fileTagsFilter().toSet();
+ FileTags filter = props->fileTagsFilter();
if (!filter.intersect(outputArtifact->fileTags).isEmpty()) {
outputArtifact->properties = props->propertyMap();
break;
diff --git a/src/lib/buildgraph/rulesapplicator.h b/src/lib/buildgraph/rulesapplicator.h
index e9d4c9e9f..8aa5dae76 100644
--- a/src/lib/buildgraph/rulesapplicator.h
+++ b/src/lib/buildgraph/rulesapplicator.h
@@ -31,6 +31,7 @@
#include "artifactlist.h"
#include "forward_decls.h"
+#include <language/filetags.h>
#include <language/forward_decls.h>
#include <logging/logger.h>
@@ -42,7 +43,7 @@ namespace qbs {
namespace Internal {
class ScriptEngine;
-typedef QMap<QString, ArtifactList> ArtifactsPerFileTagMap;
+typedef QMap<FileTag, ArtifactList> ArtifactsPerFileTagMap;
class RulesApplicator
{
diff --git a/src/lib/buildgraph/transformer.cpp b/src/lib/buildgraph/transformer.cpp
index d9cf7d205..1e9d8adbc 100644
--- a/src/lib/buildgraph/transformer.cpp
+++ b/src/lib/buildgraph/transformer.cpp
@@ -55,7 +55,7 @@ QScriptValue Transformer::translateFileConfig(QScriptEngine *scriptEngine, Artif
QScriptValue artifactConfig = scriptEngine->newObject();
artifactConfig.setPrototype(config);
artifactConfig.setProperty(QLatin1String("fileName"), artifact->filePath());
- QStringList fileTags = artifact->fileTags.toList();
+ const QStringList fileTags = artifact->fileTags.toStringList();
artifactConfig.setProperty(QLatin1String("fileTags"), scriptEngine->toScriptValue(fileTags));
if (!defaultModuleName.isEmpty())
artifactConfig.setProperty(QLatin1String("module"), config.property("modules").property(defaultModuleName));
@@ -67,8 +67,8 @@ QScriptValue Transformer::translateInOutputs(QScriptEngine *scriptEngine, const
typedef QMap<QString, QList<Artifact*> > TagArtifactsMap;
TagArtifactsMap tagArtifactsMap;
foreach (Artifact *artifact, artifacts)
- foreach (const QString &fileTag, artifact->fileTags)
- tagArtifactsMap[fileTag].append(artifact);
+ foreach (const FileTag &fileTag, artifact->fileTags)
+ tagArtifactsMap[fileTag.toString()].append(artifact);
QScriptValue jsTagFiles = scriptEngine->newObject();
for (TagArtifactsMap::const_iterator tag = tagArtifactsMap.constBegin(); tag != tagArtifactsMap.constEnd(); ++tag) {
@@ -91,8 +91,9 @@ void Transformer::setupInputs(QScriptEngine *scriptEngine, QScriptValue targetSc
targetScriptValue.setProperty("inputs", scriptValue);
if (inputs.count() == 1) {
Artifact *input = *inputs.begin();
- const QSet<QString> &fileTags = input->fileTags;
- QScriptValue inputsForFileTag = scriptValue.property(*fileTags.begin());
+ const FileTags &fileTags = input->fileTags;
+ QBS_ASSERT(!fileTags.isEmpty(), return);
+ QScriptValue inputsForFileTag = scriptValue.property(fileTags.begin()->toString());
QScriptValue inputScriptValue = inputsForFileTag.property(0);
targetScriptValue.setProperty("input", inputScriptValue);
}
@@ -105,9 +106,9 @@ void Transformer::setupOutputs(QScriptEngine *scriptEngine, QScriptValue targetS
targetScriptValue.setProperty("outputs", scriptValue);
if (outputs.count() == 1) {
Artifact *output = *outputs.begin();
- const QSet<QString> &fileTags = output->fileTags;
+ const FileTags &fileTags = output->fileTags;
QBS_ASSERT(!fileTags.isEmpty(), return);
- QScriptValue outputsForFileTag = scriptValue.property(*fileTags.begin());
+ QScriptValue outputsForFileTag = scriptValue.property(fileTags.begin()->toString());
QScriptValue outputScriptValue = outputsForFileTag.property(0);
targetScriptValue.setProperty("output", outputScriptValue);
}
diff --git a/src/lib/language/artifactproperties.h b/src/lib/language/artifactproperties.h
index 64a853729..eba29d071 100644
--- a/src/lib/language/artifactproperties.h
+++ b/src/lib/language/artifactproperties.h
@@ -42,8 +42,8 @@ class ArtifactProperties : public PersistentObject
public:
static ArtifactPropertiesPtr create();
- void setFileTagsFilter(const QStringList &filter) { m_fileTagsFilter = filter; }
- QStringList fileTagsFilter() const { return m_fileTagsFilter; }
+ void setFileTagsFilter(const FileTags &filter) { m_fileTagsFilter = filter; }
+ FileTags fileTagsFilter() const { return m_fileTagsFilter; }
PropertyMapPtr propertyMap() const { return m_propertyMap; }
void setPropertyMap(const PropertyMapPtr &pmap) { m_propertyMap = pmap; }
@@ -54,7 +54,7 @@ private:
void load(PersistentPool &);
void store(PersistentPool &) const;
- QStringList m_fileTagsFilter;
+ FileTags m_fileTagsFilter;
PropertyMapPtr m_propertyMap;
};
diff --git a/src/lib/language/filetags.cpp b/src/lib/language/filetags.cpp
new file mode 100644
index 000000000..c7c12b642
--- /dev/null
+++ b/src/lib/language/filetags.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "filetags.h"
+#include <QStringList>
+
+namespace qbs {
+namespace Internal {
+
+void FileTag::clear()
+{
+ Id::operator=(Id());
+}
+
+QStringList FileTags::toStringList() const
+{
+ QStringList strlst;
+ foreach (const FileTag &tag, *this)
+ strlst += tag.toString();
+ return strlst;
+}
+
+FileTags FileTags::fromStringList(const QStringList &strings)
+{
+ FileTags result;
+ foreach (const QString &str, strings)
+ result += FileTag(str.toLocal8Bit());
+ return result;
+}
+
+LogWriter operator <<(LogWriter w, const FileTags &tags)
+{
+ bool firstLoop = true;
+ w.write('(');
+ foreach (const FileTag &tag, tags) {
+ if (firstLoop)
+ firstLoop = false;
+ else
+ w.write(QLatin1String(", "));
+ w.write(tag.toString());
+ }
+ w.write(')');
+ return w;
+}
+
+QDataStream &operator >>(QDataStream &s, FileTags &tags)
+{
+ int i;
+ s >> i;
+ tags.clear();
+ tags.reserve(i);
+ QVariant v;
+ while (--i >= 0) {
+ s >> v;
+ tags += FileTag::fromSetting(v);
+ }
+ return s;
+}
+
+QDataStream &operator <<(QDataStream &s, const FileTags &tags)
+{
+ s << tags.count();
+ foreach (const FileTag &ft, tags)
+ s << ft.toSetting();
+ return s;
+}
+
+} // namespace Internal
+} // namespace qbs
diff --git a/src/lib/language/filetags.h b/src/lib/language/filetags.h
new file mode 100644
index 000000000..cebdc84b0
--- /dev/null
+++ b/src/lib/language/filetags.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_FILETAGS_H
+#define QBS_FILETAGS_H
+
+#include <logging/logger.h>
+#include <tools/id.h>
+#include <QDataStream>
+#include <QSet>
+
+namespace qbs {
+namespace Internal {
+
+class FileTag : public Id
+{
+public:
+ FileTag()
+ : Id()
+ {}
+
+ FileTag(const Id &other)
+ : Id(other)
+ {}
+
+ FileTag(const char *str)
+ : Id(str)
+ {}
+
+ explicit FileTag(const QByteArray &ba)
+ : Id(ba)
+ {}
+
+ void clear();
+};
+
+class FileTags : public QSet<FileTag>
+{
+public:
+ QStringList toStringList() const;
+ static FileTags fromStringList(const QStringList &strings);
+};
+
+LogWriter operator <<(LogWriter w, const FileTags &tags);
+QDataStream &operator >>(QDataStream &s, FileTags & tags);
+QDataStream &operator <<(QDataStream &s, const FileTags &tags);
+
+} // namespace Internal
+} // namespace qbs
+
+#endif // QBS_FILETAGS_H
+
diff --git a/src/lib/language/language.cpp b/src/lib/language/language.cpp
index 412c00775..145cf3fd4 100644
--- a/src/lib/language/language.cpp
+++ b/src/lib/language/language.cpp
@@ -42,8 +42,6 @@
#include <QMutexLocker>
#include <QScriptValue>
-#include <algorithm>
-
QT_BEGIN_NAMESPACE
inline QDataStream& operator>>(QDataStream &stream, qbs::Internal::JsImport &jsImport)
{
@@ -151,13 +149,13 @@ void PropertyMap::store(PersistentPool &pool) const
void FileTagger::load(PersistentPool &pool)
{
m_artifactExpression.setPattern(pool.idLoadString());
- m_fileTags = pool.idLoadStringList();
+ pool.stream() >> m_fileTags;
}
void FileTagger::store(PersistentPool &pool) const
{
pool.storeString(m_artifactExpression.pattern());
- pool.storeStringList(m_fileTags);
+ pool.stream() << m_fileTags;
}
/*!
@@ -345,16 +343,15 @@ void ResolvedModule::store(PersistentPool &pool) const
QString Rule::toString() const
{
- return "[" + inputs.join(",") + " -> " + outputFileTags().join(",") + "]";
+ return QLatin1Char('[') + inputs.toStringList().join(QLatin1String(",")) + QLatin1String(" -> ")
+ + outputFileTags().toStringList().join(QLatin1String(",")) + QLatin1Char(']');
}
-QStringList Rule::outputFileTags() const
+FileTags Rule::outputFileTags() const
{
- QStringList result;
+ FileTags result;
foreach (const RuleArtifactConstPtr &artifact, artifacts)
- result.append(artifact->fileTags);
- result.sort();
- std::unique(result.begin(), result.end());
+ result.unite(artifact->fileTags);
return result;
}
@@ -419,12 +416,12 @@ QList<SourceArtifactPtr> ResolvedProduct::allEnabledFiles() const
return lst;
}
-QSet<QString> ResolvedProduct::fileTagsForFileName(const QString &fileName) const
+FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const
{
- QSet<QString> result;
+ FileTags result;
foreach (FileTaggerConstPtr tagger, fileTaggers) {
if (FileInfo::globMatches(tagger->artifactExpression(), fileName)) {
- result.unite(tagger->fileTags().toSet());
+ result.unite(tagger->fileTags());
}
}
return result;
diff --git a/src/lib/language/language.h b/src/lib/language/language.h
index 79a37c217..9f52f2aee 100644
--- a/src/lib/language/language.h
+++ b/src/lib/language/language.h
@@ -30,6 +30,7 @@
#ifndef QBS_L2_LANGUAGE_HPP
#define QBS_L2_LANGUAGE_HPP
+#include "filetags.h"
#include "forward_decls.h"
#include "jsimports.h"
#include <tools/codelocation.h>
@@ -86,15 +87,15 @@ class FileTagger : public PersistentObject
{
public:
static FileTaggerPtr create() { return FileTaggerPtr(new FileTagger); }
- static FileTaggerPtr create(const QRegExp &artifactExpression, const QStringList &fileTags) {
+ static FileTaggerPtr create(const QRegExp &artifactExpression, const FileTags &fileTags) {
return FileTaggerPtr(new FileTagger(artifactExpression, fileTags));
}
const QRegExp &artifactExpression() const { return m_artifactExpression; }
- const QStringList &fileTags() const { return m_fileTags; }
+ const FileTags &fileTags() const { return m_fileTags; }
private:
- FileTagger(const QRegExp &artifactExpression, const QStringList &fileTags)
+ FileTagger(const QRegExp &artifactExpression, const FileTags &fileTags)
: m_artifactExpression(artifactExpression), m_fileTags(fileTags)
{ }
@@ -106,7 +107,7 @@ private:
void store(PersistentPool &) const;
QRegExp m_artifactExpression;
- QStringList m_fileTags;
+ FileTags m_fileTags;
};
class RuleArtifact : public PersistentObject
@@ -115,7 +116,7 @@ public:
static RuleArtifactPtr create() { return RuleArtifactPtr(new RuleArtifact); }
QString fileName;
- QStringList fileTags;
+ FileTags fileTags;
bool alwaysUpdated;
class Binding
@@ -143,7 +144,7 @@ public:
static SourceArtifactPtr create() { return SourceArtifactPtr(new SourceArtifact); }
QString absoluteFilePath;
- QSet<QString> fileTags;
+ FileTags fileTags;
bool overrideFileTags;
PropertyMapPtr properties;
@@ -257,9 +258,9 @@ public:
ResolvedModuleConstPtr module;
JsImports jsImports;
PrepareScriptConstPtr script;
- QStringList inputs;
- QStringList usings;
- QStringList explicitlyDependsOn;
+ FileTags inputs;
+ FileTags usings;
+ FileTags explicitlyDependsOn;
bool multiplex;
QList<RuleArtifactConstPtr> artifacts;
@@ -267,7 +268,7 @@ public:
int ruleGraphId;
QString toString() const;
- QStringList outputFileTags() const;
+ FileTags outputFileTags() const;
private:
Rule() : multiplex(false), ruleGraphId(-1) {}
@@ -304,8 +305,8 @@ public:
~ResolvedProduct();
bool enabled;
- QStringList fileTags;
- QStringList additionalFileTags;
+ FileTags fileTags;
+ FileTags additionalFileTags;
QString name;
QString targetName;
QString sourceDirectory;
@@ -327,7 +328,7 @@ public:
QList<SourceArtifactPtr> allFiles() const;
QList<SourceArtifactPtr> allEnabledFiles() const;
- QSet<QString> fileTagsForFileName(const QString &fileName) const;
+ FileTags fileTagsForFileName(const QString &fileName) const;
void setupBuildEnvironment(ScriptEngine *scriptEngine, const QProcessEnvironment &env) const;
void setupRunEnvironment(ScriptEngine *scriptEngine, const QProcessEnvironment &env) const;
diff --git a/src/lib/language/language.pri b/src/lib/language/language.pri
index 9f9fbeb20..cd0759e81 100644
--- a/src/lib/language/language.pri
+++ b/src/lib/language/language.pri
@@ -1,6 +1,7 @@
HEADERS += \
$$PWD/artifactproperties.h \
$$PWD/evaluationobject.h \
+ $$PWD/filetags.h \
$$PWD/forward_decls.h \
$$PWD/identifiersearch.h \
$$PWD/jsimports.h \
@@ -20,6 +21,7 @@ HEADERS += \
SOURCES += \
$$PWD/artifactproperties.cpp \
$$PWD/evaluationobject.cpp \
+ $$PWD/filetags.cpp \
$$PWD/identifiersearch.cpp \
$$PWD/language.cpp \
$$PWD/languagebasics.cpp \
diff --git a/src/lib/language/loader.cpp b/src/lib/language/loader.cpp
index 313628839..1c7ca9ed5 100644
--- a/src/lib/language/loader.cpp
+++ b/src/lib/language/loader.cpp
@@ -31,6 +31,7 @@
#include "artifactproperties.h"
#include "evaluationobject.h"
+#include "filetags.h"
#include "identifiersearch.h"
#include "language.h"
#include "languageobject.h"
@@ -237,19 +238,19 @@ static const QLatin1String name_PropertyOptions("PropertyOptions");
static const QLatin1String name_Depends("Depends");
static const QLatin1String name_moduleSearchPaths("moduleSearchPaths");
static const QLatin1String name_Probe("Probe");
-static const uint hashName_FileTagger = qHash(name_FileTagger);
-static const uint hashName_Rule = qHash(name_Rule);
-static const uint hashName_Transformer = qHash(name_Transformer);
-static const uint hashName_Artifact = qHash(name_Artifact);
-static const uint hashName_Group = qHash(name_Group);
-static const uint hashName_Project = qHash(name_Project);
-static const uint hashName_Product = qHash(name_Product);
-static const uint hashName_ProductModule = qHash(name_ProductModule);
-static const uint hashName_Module = qHash(name_Module);
-static const uint hashName_Properties = qHash(name_Properties);
-static const uint hashName_PropertyOptions = qHash(name_PropertyOptions);
-static const uint hashName_Depends = qHash(name_Depends);
-static const uint hashName_Probe = qHash(name_Probe);
+static const uint hashName_FileTagger = qHash(QString(name_FileTagger));
+static const uint hashName_Rule = qHash(QString(name_Rule));
+static const uint hashName_Transformer = qHash(QString(name_Transformer));
+static const uint hashName_Artifact = qHash(QString(name_Artifact));
+static const uint hashName_Group = qHash(QString(name_Group));
+static const uint hashName_Project = qHash(QString(name_Project));
+static const uint hashName_Product = qHash(QString(name_Product));
+static const uint hashName_ProductModule = qHash(QString(name_ProductModule));
+static const uint hashName_Module = qHash(QString(name_Module));
+static const uint hashName_Properties = qHash(QString(name_Properties));
+static const uint hashName_PropertyOptions = qHash(QString(name_PropertyOptions));
+static const uint hashName_Depends = qHash(QString(name_Depends));
+static const uint hashName_Probe = qHash(QString(name_Probe));
static const QLatin1String name_productPropertyScope("product property scope");
static const QLatin1String name_projectPropertyScope("project property scope");
@@ -1460,10 +1461,10 @@ void Loader::LoaderPrivate::applyFileTaggers(const SourceArtifactPtr &artifact,
const ResolvedProductConstPtr &product)
{
if (!artifact->overrideFileTags || artifact->fileTags.isEmpty()) {
- QSet<QString> fileTags = product->fileTagsForFileName(artifact->absoluteFilePath);
+ FileTags fileTags = product->fileTagsForFileName(artifact->absoluteFilePath);
artifact->fileTags.unite(fileTags);
if (artifact->fileTags.isEmpty())
- artifact->fileTags.insert(QLatin1String("unknown-file-tag"));
+ artifact->fileTags.insert("unknown-file-tag");
if (m_logger.traceEnabled()) {
m_logger.qbsTrace() << "[LDR] adding file tags " << artifact->fileTags << " to "
<< FileInfo::fileName(artifact->absoluteFilePath);
@@ -1559,11 +1560,9 @@ void Loader::LoaderPrivate::resolveModule(ResolvedProductPtr rproduct, const QSt
rmodule->jsImports = module->instantiatingObject()->file->jsImports;
rmodule->setupBuildEnvironmentScript = module->scope->verbatimValue("setupBuildEnvironment");
rmodule->setupRunEnvironmentScript = module->scope->verbatimValue("setupRunEnvironment");
- QStringList additionalProductFileTags = module->scope->stringListValue("additionalProductFileTags");
- if (!additionalProductFileTags.isEmpty()) {
- rproduct->additionalFileTags.append(additionalProductFileTags);
- rproduct->additionalFileTags = rproduct->additionalFileTags.toSet().toList();
- }
+ rproduct->additionalFileTags.unite(
+ FileTags::fromStringList(
+ module->scope->stringListValue("additionalProductFileTags")));
foreach (Module::Ptr m, module->modules)
rmodule->moduleDependencies.append(m->name);
rproduct->modules.append(rmodule);
@@ -1578,7 +1577,7 @@ void Loader::LoaderPrivate::resolveModule(ResolvedProductPtr rproduct, const QSt
static void createSourceArtifact(const ResolvedProductConstPtr &rproduct,
const PropertyMapPtr &properties,
const QString &fileName,
- const QSet<QString> &fileTags,
+ const FileTags &fileTags,
bool overrideTags,
QList<SourceArtifactPtr> &artifactList)
{
@@ -1620,7 +1619,8 @@ void Loader::LoaderPrivate::resolveGroup(ResolvedProductPtr rproduct, Evaluation
properties->setValue(evaluateModuleValues(rproduct, product, group->scope));
}
- const QStringList fileTagsFilter = group->scope->stringListValue("fileTagsFilter");
+ const FileTags fileTagsFilter
+ = FileTags::fromStringList(group->scope->stringListValue("fileTagsFilter"));
if (!fileTagsFilter.isEmpty()) {
if (!files.isEmpty())
throw Error(Tr::tr("Group.files and Group.fileTagsFilters are exclusive."),
@@ -1664,9 +1664,9 @@ void Loader::LoaderPrivate::resolveGroup(ResolvedProductPtr rproduct, Evaluation
files[i].prepend(prefix);
}
}
- QSet<QString> fileTags;
+ FileTags fileTags;
if (isGroup)
- fileTags = group->scope->stringListValue("fileTags").toSet();
+ fileTags = FileTags::fromStringList(group->scope->stringListValue("fileTags"));
bool overrideTags = true;
if (isGroup)
overrideTags = group->scope->boolValue("overrideTags", true);
@@ -1745,7 +1745,7 @@ void Loader::LoaderPrivate::resolveTransformer(ResolvedProductPtr rproduct, Eval
throw Error(Tr::tr("Artifact fileName must not be empty."));
artifact->absoluteFilePath = FileInfo::resolvePath(rproduct->project->buildDirectory,
fileName);
- artifact->fileTags = child->scope->stringListValue("fileTags").toSet();
+ artifact->fileTags = FileTags::fromStringList(child->scope->stringListValue("fileTags"));
rtrafo->outputs += artifact;
}
rproduct->transformers += rtrafo;
@@ -1817,7 +1817,7 @@ RulePtr Loader::LoaderPrivate::resolveRule(EvaluationObject *object, ResolvedMod
RuleArtifactPtr artifact = RuleArtifact::create();
artifacts.append(artifact);
artifact->fileName = child->scope->verbatimValue("fileName");
- artifact->fileTags = child->scope->stringListValue("fileTags");
+ artifact->fileTags = FileTags::fromStringList(child->scope->stringListValue("fileTags"));
artifact->alwaysUpdated = child->scope->boolValue("alwaysUpdated", true);
if (artifact->alwaysUpdated)
hasAlwaysUpdatedArtifact = true;
@@ -1856,9 +1856,10 @@ RulePtr Loader::LoaderPrivate::resolveRule(EvaluationObject *object, ResolvedMod
rule->script = prepareScript;
rule->artifacts = artifacts;
rule->multiplex = object->scope->boolValue("multiplex", false);
- rule->inputs = object->scope->stringListValue("inputs");
- rule->usings = object->scope->stringListValue("usings");
- rule->explicitlyDependsOn = object->scope->stringListValue("explicitlyDependsOn");
+ rule->inputs = FileTags::fromStringList(object->scope->stringListValue("inputs"));
+ rule->usings = FileTags::fromStringList(object->scope->stringListValue("usings"));
+ rule->explicitlyDependsOn = FileTags::fromStringList(
+ object->scope->stringListValue("explicitlyDependsOn"));
rule->module = module;
return rule;
@@ -1868,7 +1869,7 @@ FileTaggerConstPtr Loader::LoaderPrivate::resolveFileTagger(EvaluationObject *ev
{
const Scope::Ptr scope = evaluationObject->scope;
return FileTagger::create(QRegExp(scope->stringValue("pattern")),
- scope->stringListValue("fileTags"));
+ FileTags::fromStringList(scope->stringListValue("fileTags")));
}
/// --------------------------------------------------------------------------
@@ -2532,7 +2533,7 @@ void Loader::LoaderPrivate::resolveProduct(const ResolvedProductPtr &rproduct,
productProps->properties.insert("buildDirectory", p);
}
- rproduct->fileTags = productProps->stringListValue("type");
+ rproduct->fileTags = FileTags::fromStringList(productProps->stringListValue("type"));
rproduct->destinationDirectory = productProps->stringValue("destination");
foreach (const RulePtr &rule, globalRules)
rproduct->rules.insert(rule);
diff --git a/src/lib/language/tst_language.cpp b/src/lib/language/tst_language.cpp
index 875216ece..2a185079e 100644
--- a/src/lib/language/tst_language.cpp
+++ b/src/lib/language/tst_language.cpp
@@ -683,7 +683,7 @@ void TestLanguage::fileTags()
QVERIFY(group);
QCOMPARE(group->files.count(), 1);
SourceArtifactConstPtr sourceFile = group->files.first();
- QStringList fileTags = sourceFile->fileTags.toList();
+ QStringList fileTags = sourceFile->fileTags.toStringList();
fileTags.sort();
QCOMPARE(fileTags, expectedFileTags);
}
diff --git a/src/lib/tools/id.cpp b/src/lib/tools/id.cpp
index 3b85d7bcf..052a9ed9c 100644
--- a/src/lib/tools/id.cpp
+++ b/src/lib/tools/id.cpp
@@ -161,13 +161,13 @@ Id::Id(const QByteArray &name)
: m_id(theId(name))
{}
-/*!
- \overload
- \deprecated
-*/
-Id::Id(const QString &name)
- : m_id(theId(name.toUtf8()))
-{}
+///*!
+// \overload
+// \deprecated
+//*/
+//Id::Id(const QString &name)
+// : m_id(theId(name.toUtf8()))
+//{}
/*!
Returns an internal representation of the id.
diff --git a/src/lib/tools/id.h b/src/lib/tools/id.h
index a8990b294..d40416a80 100644
--- a/src/lib/tools/id.h
+++ b/src/lib/tools/id.h
@@ -45,7 +45,7 @@ public:
Id() : m_id(0) {}
Id(int uid) : m_id(uid) {}
Id(const char *name);
- explicit Id(const QString &name);
+// explicit Id(const QString &name);
explicit Id(const QByteArray &name);
Id withSuffix(int suffix) const;
diff --git a/src/lib/tools/persistence.cpp b/src/lib/tools/persistence.cpp
index 40b5a5688..0206118df 100644
--- a/src/lib/tools/persistence.cpp
+++ b/src/lib/tools/persistence.cpp
@@ -39,7 +39,7 @@
namespace qbs {
namespace Internal {
-static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE0_0_1__31";
+static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE0_0_1__32";
PersistentPool::PersistentPool(const Logger &logger) : m_logger(logger)
{
diff --git a/src/lib/tools/scannerpluginmanager.cpp b/src/lib/tools/scannerpluginmanager.cpp
index 52aec9879..3f6830b0c 100644
--- a/src/lib/tools/scannerpluginmanager.cpp
+++ b/src/lib/tools/scannerpluginmanager.cpp
@@ -49,7 +49,7 @@ ScannerPluginManager::ScannerPluginManager()
{
}
-QList<ScannerPlugin *> ScannerPluginManager::scannersForFileTag(const QString &fileTag)
+QList<ScannerPlugin *> ScannerPluginManager::scannersForFileTag(const FileTag &fileTag)
{
return instance()->m_scannerPlugins.value(fileTag);
}
@@ -96,7 +96,7 @@ void ScannerPluginManager::loadPlugins(const QStringList &pluginPaths, const Log
"loaded.").arg(QDir::toNativeSeparators(fileName));
for (int i = 0; plugins[i] != 0; ++i)
- m_scannerPlugins[QString::fromLocal8Bit(plugins[i]->fileTag)] += plugins[i];
+ m_scannerPlugins[FileTag(plugins[i]->fileTag)] += plugins[i];
m_libs.append(lib.take());
}
}
diff --git a/src/lib/tools/scannerpluginmanager.h b/src/lib/tools/scannerpluginmanager.h
index 4ea9107a4..ea0cea92c 100644
--- a/src/lib/tools/scannerpluginmanager.h
+++ b/src/lib/tools/scannerpluginmanager.h
@@ -30,9 +30,10 @@
#ifndef QBS_PLUGINS_H
#define QBS_PLUGINS_H
+#include <language/filetags.h>
#include <plugins/scanner/scanner.h>
-#include <QMap>
+#include <QHash>
#include <QString>
QT_BEGIN_NAMESPACE
@@ -47,7 +48,7 @@ class ScannerPluginManager
{
public:
static ScannerPluginManager *instance();
- static QList<ScannerPlugin *> scannersForFileTag(const QString &fileTag);
+ static QList<ScannerPlugin *> scannersForFileTag(const FileTag &fileTag);
void loadPlugins(const QStringList &paths, const Logger &logger);
private:
@@ -55,7 +56,7 @@ private:
private:
QList<QLibrary *> m_libs;
- QMap<QString, QList<ScannerPlugin*> > m_scannerPlugins;
+ QHash<FileTag, QList<ScannerPlugin*> > m_scannerPlugins;
};
} // namespace Internal