diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-10-27 12:52:18 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-11-02 16:29:25 +0000 |
commit | 1202dd60e6e40af9cfae7cb09c17ee418fa5ada4 (patch) | |
tree | abd28ef050b7a2db9a5da2ce0c1fed45ed2333dc | |
parent | 6534ed02c9878c4fa02dea5cc646e0e7f1696cbd (diff) |
Include file dependencies in artifact rescue data
These were just getting lost. Alternatively, we could always do a re-
scan of rescued artifacts, but that would be unnecessary most of the
time, and scanning is an expensive operation.
Task-number: QBS-697
Change-Id: I49f1a7b5b5c1a1691cb9f97e553b2b1b98fab3bd
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r-- | src/lib/corelib/buildgraph/buildgraphloader.cpp | 5 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 20 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rescuableartifactdata.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rescuableartifactdata.h | 3 | ||||
-rw-r--r-- | src/lib/corelib/tools/persistence.cpp | 2 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs | 4 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 18 |
7 files changed, 53 insertions, 1 deletions
diff --git a/src/lib/corelib/buildgraph/buildgraphloader.cpp b/src/lib/corelib/buildgraph/buildgraphloader.cpp index 4729ea0db..7e2c8f35f 100644 --- a/src/lib/corelib/buildgraph/buildgraphloader.cpp +++ b/src/lib/corelib/buildgraph/buildgraphloader.cpp @@ -69,6 +69,7 @@ #include <QtCore/qfileinfo.h> #include <algorithm> +#include <functional> #include <unordered_map> namespace qbs { @@ -1048,6 +1049,10 @@ void BuildGraphLoader::rescueOldBuildData(const ResolvedProductConstPtr &restore rad.children << RescuableArtifactData::ChildData(child->product->name, child->product->multiplexConfigurationId, child->filePath(), childrenInfo.childrenAddedByScanner.contains(child)); + std::transform(oldArtifact->fileDependencies.cbegin(), + oldArtifact->fileDependencies.cend(), + std::back_inserter(rad.fileDependencies), + std::mem_fn(&FileDependency::filePath)); } newlyResolvedProduct->buildData->rescuableArtifactData.insert( oldArtifact->filePath(), rad); diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index c27c0e5cc..61533c4f0 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -765,6 +765,26 @@ void Executor::rescueOldBuildData(Artifact *artifact, bool *childrenAdded = 0) if (canRescue) childrenToConnect << std::make_pair(child, cd.addedByScanner); } + for (const QString &depPath : rad.fileDependencies) { + const QList<FileResourceBase *> depList = m_project->buildData->lookupFiles(depPath); + if (depList.empty()) { + canRescue = false; + qCDebug(lcBuildGraph) << "File dependency" << depPath + << "not in the project's list of dependencies anymore."; + break; + } + const auto depFinder = [](const FileResourceBase *f) { + return dynamic_cast<const FileDependency *>(f); + }; + const auto depIt = std::find_if(depList.cbegin(), depList.cend(), depFinder); + if (depIt == depList.cend()) { + canRescue = false; + qCDebug(lcBuildGraph) << "File dependency" << depPath + << "not in the project's list of dependencies anymore."; + break; + } + artifact->fileDependencies.insert(dynamic_cast<FileDependency *>(*depIt)); + } if (canRescue) { const TypeFilter<Artifact> childArtifacts(artifact->children); diff --git a/src/lib/corelib/buildgraph/rescuableartifactdata.cpp b/src/lib/corelib/buildgraph/rescuableartifactdata.cpp index 96bdf64f9..98beaf27e 100644 --- a/src/lib/corelib/buildgraph/rescuableartifactdata.cpp +++ b/src/lib/corelib/buildgraph/rescuableartifactdata.cpp @@ -56,6 +56,7 @@ void RescuableArtifactData::load(PersistentPool &pool) { pool.load(timeStamp); pool.load(children); + pool.load(fileDependencies); pool.load(propertiesRequestedInPrepareScript); pool.load(propertiesRequestedInCommands); pool.load(propertiesRequestedFromArtifactInPrepareScript); @@ -69,6 +70,7 @@ void RescuableArtifactData::store(PersistentPool &pool) const { pool.store(timeStamp); pool.store(children); + pool.store(fileDependencies); pool.store(propertiesRequestedInPrepareScript); pool.store(propertiesRequestedInCommands); pool.store(propertiesRequestedFromArtifactInPrepareScript); diff --git a/src/lib/corelib/buildgraph/rescuableartifactdata.h b/src/lib/corelib/buildgraph/rescuableartifactdata.h index d1d9ae12b..d769a95a2 100644 --- a/src/lib/corelib/buildgraph/rescuableartifactdata.h +++ b/src/lib/corelib/buildgraph/rescuableartifactdata.h @@ -50,6 +50,8 @@ #include <QtCore/qhash.h> #include <QtCore/qlist.h> +#include <vector> + namespace qbs { namespace Internal { class PersistentPool; @@ -95,6 +97,7 @@ public: FileTime timeStamp; QList<ChildData> children; + std::vector<QString> fileDependencies; // Per-Transformer data QList<AbstractCommandPtr> commands; diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp index 029b3902d..1fc800999 100644 --- a/src/lib/corelib/tools/persistence.cpp +++ b/src/lib/corelib/tools/persistence.cpp @@ -50,7 +50,7 @@ namespace qbs { namespace Internal { -static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE_107"; +static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE_108"; NoBuildGraphError::NoBuildGraphError(const QString &filePath) : ErrorInfo(Tr::tr("Build graph not found for configuration '%1'. Expected location was '%2'.") diff --git a/tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs b/tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs index 662879ccb..e99e0932c 100644 --- a/tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs +++ b/tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs @@ -8,6 +8,10 @@ Project { Depends { name: "cpp" } cpp.includePaths: ["awesomelib"] files: ["src/narf.h", "src/narf.cpp", "src/zort.cpp"] + // Group { + // fileTagsFilter: product.type + // qbs.install: true + // } } } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 3abd5e3b3..8869e2619 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -3085,6 +3085,24 @@ void TestBlackbox::fileDependencies() QCOMPARE(runQbs(), 0); QVERIFY(m_qbsStdout.contains("compiling narf.cpp")); QVERIFY(!m_qbsStdout.contains("compiling zort.cpp")); + + // Change the product in between to force the list of dependencies to get rescued. + QFile projectFile("fileDependencies.qbs"); + QVERIFY2(projectFile.open(QIODevice::ReadWrite), qPrintable(projectFile.errorString())); + QByteArray contents = projectFile.readAll(); + contents.replace("//", ""); + projectFile.resize(0); + projectFile.write(contents); + projectFile.close(); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData()); + QVERIFY(!m_qbsStdout.contains("compiling narf.cpp")); + QVERIFY(!m_qbsStdout.contains("compiling zort.cpp")); + WAIT_FOR_NEW_TIMESTAMP(); + touch("awesomelib/magnificent.h"); + QCOMPARE(runQbs(), 0); + QVERIFY(m_qbsStdout.contains("compiling narf.cpp")); + QVERIFY(!m_qbsStdout.contains("compiling zort.cpp")); } void TestBlackbox::installedTransformerOutput() |