aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2012-11-27 22:03:35 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2012-12-03 10:15:24 +0100
commitbb75c2724f4e09327b342f5372719d286526f271 (patch)
treec9ce65bb703f44413d6e604d1a97f266d01c8000
parent9383c14ace1984fe3bb298b2c8f33135acbb7a1e (diff)
Use CodeLocation to save where groups and products were defined
Change-Id: Ic20c9c504c092584b4252e843fafd954452d1c91 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/app/qbs/status.cpp6
-rw-r--r--src/lib/api/project.cpp7
-rw-r--r--src/lib/api/projectdata.cpp8
-rw-r--r--src/lib/api/projectdata.h16
-rw-r--r--src/lib/buildgraph/buildgraph.cpp14
-rw-r--r--src/lib/language/language.cpp11
-rw-r--r--src/lib/language/language.h7
-rw-r--r--src/lib/language/loader.cpp10
-rw-r--r--src/lib/tools/codelocation.h8
-rw-r--r--src/lib/tools/persistence.cpp2
10 files changed, 44 insertions, 45 deletions
diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp
index 4a82fd993..9d7ee178e 100644
--- a/src/app/qbs/status.cpp
+++ b/src/app/qbs/status.cpp
@@ -113,7 +113,7 @@ int printStatus(const QList<ProjectData> &projects)
{
if (projects.isEmpty())
return 0;
- const QString projectFilePath = projects.first().qbsFilePath();
+ const QString projectFilePath = projects.first().location().fileName;
QString projectDirectory = FileInfo::path(projectFilePath);
int projectDirectoryPathLength = projectDirectory.length();
@@ -122,10 +122,10 @@ int printStatus(const QList<ProjectData> &projects)
const ProjectData project = projects.first();
foreach (const ProductData &product, project.products()) {
qbsInfo() << DontPrintLogLevel << TextColorBlue << "\nProduct: " << product.name()
- << " (" << product.qbsFilePath() << ":" << product.qbsLine() << ")";
+ << " (" << product.location().fileName << ":" << product.location().line << ")";
foreach (const GroupData &group, product.groups()) {
qbsInfo() << DontPrintLogLevel << TextColorBlue << " Group: " << group.name()
- << " (" << group.qbsLine() << ")";
+ << " (" << group.location().fileName << ":" << group.location().line << ")";
QStringList sourceFiles = group.allFilePaths();
qSort(sourceFiles);
foreach (const QString &sourceFile, sourceFiles) {
diff --git a/src/lib/api/project.cpp b/src/lib/api/project.cpp
index 1269f7baf..a83a6e1ea 100644
--- a/src/lib/api/project.cpp
+++ b/src/lib/api/project.cpp
@@ -239,19 +239,18 @@ BuildProductPtr ProjectPrivate::internalProduct(const ProductData &product) cons
void ProjectPrivate::retrieveProjectData()
{
- m_projectData.m_qbsFilePath = internalProject->resolvedProject()->qbsFile;
+ m_projectData.m_location = internalProject->resolvedProject()->location;
foreach (const BuildProductPtr &buildProduct, internalProject->buildProducts()) {
const ResolvedProductConstPtr resolvedProduct = buildProduct->rProduct;
ProductData product;
product.m_name = resolvedProduct->name;
- product.m_qbsFilePath = resolvedProduct->qbsFile;
- product.m_qbsLine = resolvedProduct->qbsLine;
+ product.m_location = resolvedProduct->location;
product.m_fileTags = resolvedProduct->fileTags;
product.m_properties = resolvedProduct->properties->value();
foreach (const ResolvedGroup::Ptr &resolvedGroup, resolvedProduct->groups) {
GroupData group;
group.m_name = resolvedGroup->name;
- group.m_qbsLine = resolvedGroup->qbsLine;
+ group.m_location = resolvedGroup->location;
foreach (const SourceArtifactConstPtr &sa, resolvedGroup->files)
group.m_filePaths << sa->absoluteFilePath;
if (resolvedGroup->wildcards) {
diff --git a/src/lib/api/projectdata.cpp b/src/lib/api/projectdata.cpp
index 45288d94b..9f6917164 100644
--- a/src/lib/api/projectdata.cpp
+++ b/src/lib/api/projectdata.cpp
@@ -36,8 +36,7 @@ GroupData::GroupData() { }
bool operator==(const GroupData &lhs, const GroupData &rhs)
{
return lhs.name() == rhs.name()
- && lhs.qbsLine() == rhs.qbsLine()
- && lhs.filePaths() == rhs.filePaths()
+ && lhs.location() == rhs.location()
&& lhs.expandedWildcards() == rhs.expandedWildcards()
&& lhs.properties() == rhs.properties();
}
@@ -52,8 +51,7 @@ ProductData::ProductData() { }
bool operator==(const ProductData &lhs, const ProductData &rhs)
{
return lhs.name() == rhs.name()
- && lhs.qbsFilePath() == rhs.qbsFilePath()
- && lhs.qbsLine() == rhs.qbsLine()
+ && lhs.location() == rhs.location()
&& lhs.fileTags() == rhs.fileTags()
&& lhs.properties() == rhs.properties()
&& lhs.groups() == rhs.groups();
@@ -73,7 +71,7 @@ ProjectData::ProjectData() { }
bool operator==(const ProjectData &lhs, const ProjectData &rhs)
{
- return lhs.qbsFilePath() == rhs.qbsFilePath()
+ return lhs.location() == rhs.location()
&& lhs.products() == rhs.products();
}
diff --git a/src/lib/api/projectdata.h b/src/lib/api/projectdata.h
index 872c89d49..f4f08c05c 100644
--- a/src/lib/api/projectdata.h
+++ b/src/lib/api/projectdata.h
@@ -29,6 +29,8 @@
#ifndef QBS_PROJECTDATA_H
#define QBS_PROJECTDATA_H
+#include <tools/codelocation.h>
+
#include <QList>
#include <QPair>
#include <QString>
@@ -46,7 +48,7 @@ class GroupData
public:
GroupData();
- int qbsLine() const { return m_qbsLine; }
+ CodeLocation location() const { return m_location; }
QString name() const { return m_name; }
QStringList filePaths() const { return m_filePaths; }
QStringList expandedWildcards() const { return m_expandedWildcards; }
@@ -57,7 +59,7 @@ public:
private:
QString m_name;
- int m_qbsLine;
+ CodeLocation m_location;
QStringList m_filePaths;
QStringList m_expandedWildcards;
QVariantMap m_properties;
@@ -74,16 +76,14 @@ public:
ProductData();
QString name() const { return m_name; }
- QString qbsFilePath() const { return m_qbsFilePath; }
- int qbsLine() const { return m_qbsLine; }
+ CodeLocation location() const { return m_location; }
QStringList fileTags() const { return m_fileTags; }
QVariantMap properties() const { return m_properties; }
QList<GroupData> groups() const { return m_groups; }
private:
QString m_name;
- QString m_qbsFilePath;
- int m_qbsLine;
+ CodeLocation m_location;
QStringList m_fileTags;
QVariantMap m_properties;
QList<GroupData> m_groups;
@@ -99,11 +99,11 @@ class ProjectData
public:
ProjectData();
- QString qbsFilePath() const { return m_qbsFilePath; }
+ CodeLocation location() const { return m_location; }
QList<ProductData> products() const { return m_products; }
private:
- QString m_qbsFilePath;
+ CodeLocation m_location;
QList<ProductData> m_products;
};
diff --git a/src/lib/buildgraph/buildgraph.cpp b/src/lib/buildgraph/buildgraph.cpp
index 19cb4b278..4f4db8498 100644
--- a/src/lib/buildgraph/buildgraph.cpp
+++ b/src/lib/buildgraph/buildgraph.cpp
@@ -214,8 +214,8 @@ void BuildGraph::setupScriptEngineForProduct(ScriptEngine *engine,
QVariant(reinterpret_cast<qulonglong>(product->project.data())));
QScriptValue projectScriptValue;
projectScriptValue = engine->newObject();
- projectScriptValue.setProperty("filePath", product->project->qbsFile);
- projectScriptValue.setProperty("path", FileInfo::path(product->project->qbsFile));
+ projectScriptValue.setProperty("filePath", product->project->location.fileName);
+ projectScriptValue.setProperty("path", FileInfo::path(product->project->location.fileName));
targetObject.setProperty("project", projectScriptValue);
}
@@ -1067,11 +1067,11 @@ BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &r
}
//add qbsFile artifact
- Artifact *qbsFileArtifact = product->lookupArtifact(rProduct->qbsFile);
+ Artifact *qbsFileArtifact = product->lookupArtifact(rProduct->location.fileName);
if (!qbsFileArtifact) {
qbsFileArtifact = new Artifact(m_project.data());
qbsFileArtifact->artifactType = Artifact::SourceFile;
- qbsFileArtifact->setFilePath(rProduct->qbsFile);
+ qbsFileArtifact->setFilePath(rProduct->location.fileName);
qbsFileArtifact->properties = rProduct->properties;
product->insertArtifact(qbsFileArtifact);
}
@@ -1183,7 +1183,7 @@ BuildProjectLoader::LoadResult BuildProjectLoader::load(const QString &projectFi
project->load(pool);
foreach (const BuildProductPtr &bp, project->buildProducts())
bp->project = project;
- project->resolvedProject()->qbsFile = projectFilePath;
+ project->resolvedProject()->location = CodeLocation(projectFilePath, 1, 1);
project->resolvedProject()->setBuildConfiguration(pool.headData().projectConfig);
project->resolvedProject()->buildDirectory = buildDir;
m_result.loadedProject = project;
@@ -1196,7 +1196,7 @@ BuildProjectLoader::LoadResult BuildProjectLoader::load(const QString &projectFi
QList<BuildProductPtr> changedProducts;
foreach (BuildProductPtr product, project->buildProducts()) {
const ResolvedProductConstPtr &resolvedProduct = product->rProduct;
- const FileInfo pfi(resolvedProduct->qbsFile);
+ const FileInfo pfi(resolvedProduct->location.fileName);
if (!pfi.exists()) {
referencedProductRemoved = true;
} else if (bgfi.lastModified() < pfi.lastModified()) {
@@ -1222,7 +1222,7 @@ BuildProjectLoader::LoadResult BuildProjectLoader::load(const QString &projectFi
Loader ldr(bg->engine());
ldr.setSearchPaths(loaderSearchPaths);
const ResolvedProjectPtr changedProject
- = ldr.loadProject(project->resolvedProject()->qbsFile, buildRoot, cfg);
+ = ldr.loadProject(project->resolvedProject()->location.fileName, buildRoot, cfg);
m_result.changedResolvedProject = changedProject;
QMap<QString, ResolvedProductPtr> changedProductsMap;
diff --git a/src/lib/language/language.cpp b/src/lib/language/language.cpp
index df0065ba3..07e4c510c 100644
--- a/src/lib/language/language.cpp
+++ b/src/lib/language/language.cpp
@@ -200,7 +200,7 @@ QList<SourceArtifactPtr> ResolvedGroup::allFiles() const
void ResolvedGroup::load(PersistentPool &pool)
{
name = pool.idLoadString();
- pool.stream() >> qbsLine;
+ pool.stream() >> location;
pool.loadContainerS(files);
wildcards = pool.idLoadS<SourceWildCards>();
properties = pool.idLoadS<PropertyMap>();
@@ -209,7 +209,7 @@ void ResolvedGroup::load(PersistentPool &pool)
void ResolvedGroup::store(PersistentPool &pool) const
{
pool.storeString(name);
- pool.stream() << qbsLine;
+ pool.stream() << location;
pool.storeContainer(files);
pool.store(wildcards);
pool.store(properties);
@@ -379,9 +379,7 @@ void ResolvedProduct::load(PersistentPool &pool)
>> targetName
>> sourceDirectory
>> destinationDirectory
- >> qbsFile
- >> qbsLine;
-
+ >> location;
properties = pool.idLoadS<PropertyMap>();
pool.loadContainerS(rules);
pool.loadContainerS(dependencies);
@@ -398,8 +396,7 @@ void ResolvedProduct::store(PersistentPool &pool) const
<< targetName
<< sourceDirectory
<< destinationDirectory
- << qbsFile
- << qbsLine;
+ << location;
pool.store(properties);
pool.storeContainer(rules);
diff --git a/src/lib/language/language.h b/src/lib/language/language.h
index 34e6a489f..c4f6abd50 100644
--- a/src/lib/language/language.h
+++ b/src/lib/language/language.h
@@ -191,7 +191,7 @@ public:
static Ptr create() { return Ptr(new ResolvedGroup); }
- int qbsLine;
+ CodeLocation location;
QString name;
QList<SourceArtifactPtr> files;
@@ -308,8 +308,7 @@ public:
QString targetName;
QString sourceDirectory;
QString destinationDirectory;
- QString qbsFile;
- int qbsLine;
+ CodeLocation location;
WeakPointer<ResolvedProject> project;
PropertyMapPtr properties;
QSet<RulePtr> rules;
@@ -343,7 +342,7 @@ public:
static QString deriveId(const QVariantMap &config);
static QString deriveBuildDirectory(const QString &buildRoot, const QString &id);
- QString qbsFile; // Not saved.
+ CodeLocation location; // Not saved.
QString buildDirectory; // Not saved
QVariantMap platformEnvironment;
QList<ResolvedProductPtr> products;
diff --git a/src/lib/language/loader.cpp b/src/lib/language/loader.cpp
index 2c6eec7af..8a3615efc 100644
--- a/src/lib/language/loader.cpp
+++ b/src/lib/language/loader.cpp
@@ -2343,7 +2343,7 @@ ResolvedProjectPtr Loader::LoaderPrivate::resolveProject(const QString &buildRoo
m_scopesWithEvaluatedProperties->clear();
m_convertedScopesCache.clear();
ResolvedProjectPtr rproject = ResolvedProject::create();
- rproject->qbsFile = m_project->fileName;
+ rproject->location = CodeLocation(m_project->fileName, 1, 1);
rproject->setBuildConfiguration(userProperties);
rproject->buildDirectory = ResolvedProject::deriveBuildDirectory(buildRoot, rproject->id());
@@ -2502,7 +2502,7 @@ void Loader::LoaderPrivate::resolveGroup(ResolvedProductPtr rproduct, Evaluation
overrideTags = group->scope->boolValue("overrideTags", true);
ResolvedGroup::Ptr resolvedGroup = ResolvedGroup::create();
- resolvedGroup->qbsLine = group->instantiatingObject()->prototypeLocation.line;
+ resolvedGroup->location = group->instantiatingObject()->prototypeLocation;
if (!patterns.isEmpty()) {
SourceWildCards::Ptr wildcards = SourceWildCards::create();
@@ -3249,8 +3249,7 @@ void Loader::LoaderPrivate::resolveTopLevel(const ResolvedProjectPtr &rproject,
setPathAndFilePath(evaluationObject->scope, object->file->fileName);
const ResolvedProductPtr rproduct = ResolvedProduct::create();
- rproduct->qbsFile = projectFileName;
- rproduct->qbsLine = evaluationObject->instantiatingObject()->prototypeLocation.line;
+ rproduct->location = evaluationObject->instantiatingObject()->prototypeLocation;
rproduct->sourceDirectory = QFileInfo(projectFileName).absolutePath();
rproduct->project = rproject;
@@ -3470,7 +3469,8 @@ void Loader::LoaderPrivate::resolveProductDependencies(const ResolvedProjectPtr
qbsWarning() << unknownModule->failureMessage;
continue;
}
- throw Error(Tr::tr("Product dependency '%1' not found in '%2'.").arg(usedProductName, rproduct->qbsFile),
+ throw Error(Tr::tr("Product dependency '%1' not found in '%2'.")
+ .arg(usedProductName, rproduct->location.fileName),
CodeLocation(m_project->fileName));
}
if (usedProductCandidates.count() > 1)
diff --git a/src/lib/tools/codelocation.h b/src/lib/tools/codelocation.h
index 669cbc590..10a98c561 100644
--- a/src/lib/tools/codelocation.h
+++ b/src/lib/tools/codelocation.h
@@ -52,9 +52,15 @@ struct CodeLocation
return !fileName.isEmpty();
}
+ bool operator == (const CodeLocation &rhs) const
+ {
+ return fileName == rhs.fileName
+ && line == rhs.line
+ && column == rhs.column;
+ }
bool operator != (const CodeLocation &rhs) const
{
- return fileName != rhs.fileName || line != rhs.line || column != rhs.column;
+ return !operator==(rhs);
}
QString fileName;
diff --git a/src/lib/tools/persistence.cpp b/src/lib/tools/persistence.cpp
index df4cb06a5..23a2fcb28 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__25";
+static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE0_0_1__26";
PersistentPool::PersistentPool()
{