summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-08-01 17:43:40 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-08-02 10:43:22 +0200
commit7893c2b986c8f767e2cc747e98efcc6b48aec05f (patch)
treebcebc06bdbf45d441d7e21c9171e643d2e04013f
parentc0e44c33033366b33fa9429972ed76262ec0dcbd (diff)
downloadqbs-7893c2b986c8f767e2cc747e98efcc6b48aec05f.tar.gz
remove Artifact::topLevelProject
Every artifact has a product now. That product points to its top level project. Artifact::topLevelProject can go. Change-Id: I7a7ec921043b64eec6c704128ae465fd9ef05031 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r--src/lib/buildgraph/artifact.cpp8
-rw-r--r--src/lib/buildgraph/artifact.h8
-rw-r--r--src/lib/buildgraph/artifactcleaner.cpp2
-rw-r--r--src/lib/buildgraph/automoc.cpp5
-rw-r--r--src/lib/buildgraph/buildgraph.cpp10
-rw-r--r--src/lib/buildgraph/buildgraph.h2
-rw-r--r--src/lib/buildgraph/buildgraphloader.cpp13
-rw-r--r--src/lib/buildgraph/executor.cpp2
-rw-r--r--src/lib/buildgraph/inputartifactscanner.cpp2
-rw-r--r--src/lib/buildgraph/projectbuilddata.cpp4
-rw-r--r--src/lib/buildgraph/rulesapplicator.cpp2
11 files changed, 22 insertions, 36 deletions
diff --git a/src/lib/buildgraph/artifact.cpp b/src/lib/buildgraph/artifact.cpp
index a14c84c58..28fd44dd9 100644
--- a/src/lib/buildgraph/artifact.cpp
+++ b/src/lib/buildgraph/artifact.cpp
@@ -55,13 +55,7 @@ QT_END_NAMESPACE
namespace qbs {
namespace Internal {
-Artifact::Artifact() : topLevelProject(0)
-{
- initialize();
-}
-
-Artifact::Artifact(TopLevelProject *project)
- : topLevelProject(project)
+Artifact::Artifact()
{
initialize();
}
diff --git a/src/lib/buildgraph/artifact.h b/src/lib/buildgraph/artifact.h
index 6cbb4f1e9..0eb17741f 100644
--- a/src/lib/buildgraph/artifact.h
+++ b/src/lib/buildgraph/artifact.h
@@ -57,20 +57,14 @@ class Logger;
class Artifact : public FileResourceBase
{
public:
- // We could save one constructor here by using a default argument, but then we'd have to
- // include language.h in every file that includes artifact.h due to Qt 4's weird
- // QSharedPointer implementation.
Artifact();
- explicit Artifact(TopLevelProject *project);
-
~Artifact();
ArtifactList parents;
ArtifactList children;
QSet<FileDependency *> fileDependencies;
FileTags fileTags;
- TopLevelProject *topLevelProject;
- WeakPointer<ResolvedProduct> product; // Note: file dependency artifacts don't belong to a product.
+ WeakPointer<ResolvedProduct> product;
TransformerPtr transformer;
PropertyMapPtr properties;
diff --git a/src/lib/buildgraph/artifactcleaner.cpp b/src/lib/buildgraph/artifactcleaner.cpp
index 162ffd205..bf7593def 100644
--- a/src/lib/buildgraph/artifactcleaner.cpp
+++ b/src/lib/buildgraph/artifactcleaner.cpp
@@ -61,7 +61,7 @@ static void invalidateArtifactTimestamp(Artifact *artifact)
{
if (artifact->timestamp().isValid()) {
artifact->clearTimestamp();
- artifact->topLevelProject->buildData->isDirty = true;
+ artifact->product->topLevelProject()->buildData->isDirty = true;
}
}
diff --git a/src/lib/buildgraph/automoc.cpp b/src/lib/buildgraph/automoc.cpp
index 4224b986a..a37f96fcf 100644
--- a/src/lib/buildgraph/automoc.cpp
+++ b/src/lib/buildgraph/automoc.cpp
@@ -326,6 +326,7 @@ void AutoMoc::unmoc(Artifact *artifact, const FileTag &mocFileTag)
return;
}
+ TopLevelProject * const project = artifact->product->topLevelProject();
if (mocFileTag == "moc_hpp") {
Artifact *mocObjArtifact = 0;
foreach (Artifact *parent, generatedMocArtifact->parents) {
@@ -344,7 +345,7 @@ void AutoMoc::unmoc(Artifact *artifact, const FileTag &mocFileTag)
m_logger.qbsTrace() << "[AUTOMOC] removing moc obj artifact "
<< relativeArtifactFileName(mocObjArtifact);
}
- artifact->topLevelProject->buildData->removeArtifact(mocObjArtifact, m_logger);
+ project->buildData->removeArtifact(mocObjArtifact, m_logger);
}
}
@@ -352,7 +353,7 @@ void AutoMoc::unmoc(Artifact *artifact, const FileTag &mocFileTag)
m_logger.qbsTrace() << "[AUTOMOC] removing generated artifact "
<< relativeArtifactFileName(generatedMocArtifact);
}
- artifact->topLevelProject->buildData->removeArtifact(generatedMocArtifact, m_logger);
+ project->buildData->removeArtifact(generatedMocArtifact, m_logger);
delete generatedMocArtifact;
}
diff --git a/src/lib/buildgraph/buildgraph.cpp b/src/lib/buildgraph/buildgraph.cpp
index 50d71cd02..4f0648d39 100644
--- a/src/lib/buildgraph/buildgraph.cpp
+++ b/src/lib/buildgraph/buildgraph.cpp
@@ -235,7 +235,7 @@ void connect(Artifact *p, Artifact *c)
QBS_CHECK(p != c);
p->children.insert(c);
c->parents.insert(p);
- p->topLevelProject->buildData->isDirty = true;
+ p->product->topLevelProject()->buildData->isDirty = true;
}
void loggedConnect(Artifact *u, Artifact *v, const Logger &logger)
@@ -305,10 +305,10 @@ void removeGeneratedArtifactFromDisk(Artifact *artifact, const Logger &logger)
}
}
-QString relativeArtifactFileName(const Artifact *n)
+QString relativeArtifactFileName(const Artifact *artifact)
{
- const QString &buildDir = n->topLevelProject->buildDirectory;
- QString str = n->filePath();
+ const QString &buildDir = artifact->product->topLevelProject()->buildDirectory;
+ QString str = artifact->filePath();
if (str.startsWith(buildDir))
str.remove(0, buildDir.count());
if (str.startsWith('/'))
@@ -345,7 +345,7 @@ Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const Artifact
Artifact *createArtifact(const ResolvedProductPtr &product,
const SourceArtifactConstPtr &sourceArtifact, const Logger &logger)
{
- Artifact *artifact = new Artifact(product->topLevelProject());
+ Artifact *artifact = new Artifact;
artifact->artifactType = Artifact::SourceFile;
artifact->setFilePath(sourceArtifact->absoluteFilePath);
artifact->fileTags = sourceArtifact->fileTags;
diff --git a/src/lib/buildgraph/buildgraph.h b/src/lib/buildgraph/buildgraph.h
index 14df4e44e..ac2a0f313 100644
--- a/src/lib/buildgraph/buildgraph.h
+++ b/src/lib/buildgraph/buildgraph.h
@@ -66,7 +66,7 @@ void disconnect(Artifact *u, Artifact *v, const Logger &logger);
void setupScriptEngineForProduct(ScriptEngine *engine, const ResolvedProductConstPtr &product,
const RuleConstPtr &rule, QScriptValue targetObject,
ScriptPropertyObserver *observer = 0);
-QString relativeArtifactFileName(const Artifact *n); // Debugging helpers
+QString relativeArtifactFileName(const Artifact *artifact); // Debugging helpers
template <typename T>
QStringList toStringList(const T &artifactContainer)
diff --git a/src/lib/buildgraph/buildgraphloader.cpp b/src/lib/buildgraph/buildgraphloader.cpp
index 340e70cba..fbaeae2b4 100644
--- a/src/lib/buildgraph/buildgraphloader.cpp
+++ b/src/lib/buildgraph/buildgraphloader.cpp
@@ -77,10 +77,8 @@ static void restoreBackPointers(const ResolvedProjectPtr &project)
product->project = project;
if (!product->buildData)
continue;
- foreach (Artifact * const a, product->buildData->artifacts) {
- a->topLevelProject = project->topLevelProject();
+ foreach (Artifact * const a, product->buildData->artifacts)
project->topLevelProject()->buildData->insertIntoLookupTable(a);
- }
}
foreach (const ResolvedProjectPtr &subProject, project->subProjects) {
@@ -238,10 +236,8 @@ void BuildGraphLoader::trackProjectChanges(const SetupProjectParameters &paramet
if (newlyResolvedProduct->name == restoredProduct->name) {
newlyResolvedProduct->buildData.swap(restoredProduct->buildData);
if (newlyResolvedProduct->buildData) {
- foreach (Artifact * const a, newlyResolvedProduct->buildData->artifacts) {
+ foreach (Artifact * const a, newlyResolvedProduct->buildData->artifacts)
a->product = newlyResolvedProduct;
- a->topLevelProject = newlyResolvedProduct->topLevelProject();
- }
}
// Keep in list if build data still needs to be resolved.
@@ -496,20 +492,21 @@ void BuildGraphLoader::removeArtifactAndExclusiveDependents(Artifact *artifact,
{
if (removedArtifacts)
removedArtifacts->insert(artifact);
+ TopLevelProject * const project = artifact->product->topLevelProject();
foreach (Artifact *parent, artifact->parents) {
bool removeParent = false;
disconnect(parent, artifact, m_logger);
if (parent->children.isEmpty()) {
removeParent = true;
} else if (parent->transformer) {
- artifact->topLevelProject->buildData->artifactsThatMustGetNewTransformers += parent;
+ project->buildData->artifactsThatMustGetNewTransformers += parent;
parent->transformer->inputs.remove(artifact);
removeParent = parent->transformer->inputs.isEmpty();
}
if (removeParent)
removeArtifactAndExclusiveDependents(parent, removedArtifacts);
}
- artifact->topLevelProject->buildData->removeArtifact(artifact, m_logger);
+ project->buildData->removeArtifact(artifact, m_logger);
}
bool BuildGraphLoader::checkForPropertyChanges(const TransformerPtr &restoredTrafo,
diff --git a/src/lib/buildgraph/executor.cpp b/src/lib/buildgraph/executor.cpp
index f690f30a8..690bee49c 100644
--- a/src/lib/buildgraph/executor.cpp
+++ b/src/lib/buildgraph/executor.cpp
@@ -730,7 +730,7 @@ void Executor::onProcessSuccess()
QBS_CHECK(processedArtifact);
// Update the timestamps of the outputs of the transformer we just executed.
- processedArtifact->topLevelProject->buildData->isDirty = true;
+ processedArtifact->product->topLevelProject()->buildData->isDirty = true;
foreach (Artifact *artifact, processedArtifact->transformer->outputs) {
if (artifact->alwaysUpdated)
artifact->setTimestamp(FileTime::currentTime());
diff --git a/src/lib/buildgraph/inputartifactscanner.cpp b/src/lib/buildgraph/inputartifactscanner.cpp
index 080b550ed..b54edd92e 100644
--- a/src/lib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/buildgraph/inputartifactscanner.cpp
@@ -323,7 +323,7 @@ void InputArtifactScanner::handleDependency(ResolvedDependency &dependency)
fileDependency = new FileDependency();
dependency.file = fileDependency;
fileDependency->setFilePath(dependency.filePath);
- m_artifact->topLevelProject->buildData->insertFileDependency(fileDependency);
+ product->topLevelProject()->buildData->insertFileDependency(fileDependency);
} else if (fileDependency) {
// The dependency exists in the project's list of file dependencies.
if (m_logger.traceEnabled()) {
diff --git a/src/lib/buildgraph/projectbuilddata.cpp b/src/lib/buildgraph/projectbuilddata.cpp
index b8dd35124..dea04669f 100644
--- a/src/lib/buildgraph/projectbuilddata.cpp
+++ b/src/lib/buildgraph/projectbuilddata.cpp
@@ -160,7 +160,7 @@ void ProjectBuildData::removeArtifact(Artifact *artifact, ProjectBuildData *proj
void ProjectBuildData::removeArtifact(Artifact *artifact, const Logger &logger)
{
- removeArtifact(artifact, artifact->topLevelProject->buildData.data(), logger);
+ removeArtifact(artifact, artifact->product->topLevelProject()->buildData.data(), logger);
}
void ProjectBuildData::updateNodesThatMustGetNewTransformer(const Logger &logger)
@@ -330,7 +330,7 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc
//add qbsFile artifact
Artifact *qbsFileArtifact = lookupArtifact(product, product->location.fileName());
if (!qbsFileArtifact) {
- qbsFileArtifact = new Artifact(product->topLevelProject());
+ qbsFileArtifact = new Artifact;
qbsFileArtifact->artifactType = Artifact::SourceFile;
qbsFileArtifact->setFilePath(product->location.fileName());
qbsFileArtifact->properties = product->properties;
diff --git a/src/lib/buildgraph/rulesapplicator.cpp b/src/lib/buildgraph/rulesapplicator.cpp
index 3fd4fb7dc..5d3db92cb 100644
--- a/src/lib/buildgraph/rulesapplicator.cpp
+++ b/src/lib/buildgraph/rulesapplicator.cpp
@@ -259,7 +259,7 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule
}
outputArtifact->fileTags += ruleArtifact->fileTags;
} else {
- outputArtifact = new Artifact(m_product->topLevelProject());
+ outputArtifact = new Artifact;
outputArtifact->artifactType = Artifact::Generated;
outputArtifact->setFilePath(outputPath);
outputArtifact->fileTags = ruleArtifact->fileTags;