diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-08-25 16:19:02 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-08-28 07:35:26 +0000 |
commit | 7ed3fd38aa21cb09fb270402ee3cdd99484cddf0 (patch) | |
tree | bcea8c82b07853dd734055b3eca540751412c0c2 | |
parent | 1518831c3c2de37880f46aa5c3fa773e376d969a (diff) |
Fix dependency tracking when using --check-timestamps
The --check-timestamps option is meant to be used to reconstruct a build
after accidentally removing the build graph file. This means we must re-
scan sources even though they appear up to date, in order to reconstruct
e.g. dependencies between C++ sources and headers.
Task-number: QBS-1178
Change-Id: I19ac385e57ceb7fcbba2df1ef24497935c067512
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/check-timestamps/check-timestamps.qbs | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/check-timestamps/file.cpp | 3 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/check-timestamps/file.h | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/check-timestamps/main.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 14 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
7 files changed, 39 insertions, 1 deletions
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 786fdbc42..dc81385e2 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -906,7 +906,8 @@ void Executor::potentiallyRunTransformer(const TransformerPtr &transformer) return; } - if (!mustExecuteTransformer(transformer)) { + const bool mustExecute = mustExecuteTransformer(transformer); + if (!mustExecute && !m_buildOptions.forceTimestampCheck()) { if (m_doDebug) m_logger.qbsDebug() << "[EXEC] Up to date. Skipping."; finishTransformer(transformer); @@ -925,6 +926,13 @@ void Executor::potentiallyRunTransformer(const TransformerPtr &transformer) return; } + if (!mustExecute) { + if (m_doDebug) + m_logger.qbsDebug() << "[EXEC] Up to date. Skipping."; + finishTransformer(transformer); + return; + } + if (m_buildOptions.executeRulesOnly()) finishTransformer(transformer); else diff --git a/tests/auto/blackbox/testdata/check-timestamps/check-timestamps.qbs b/tests/auto/blackbox/testdata/check-timestamps/check-timestamps.qbs new file mode 100644 index 000000000..32456444c --- /dev/null +++ b/tests/auto/blackbox/testdata/check-timestamps/check-timestamps.qbs @@ -0,0 +1,10 @@ +import qbs + +CppApplication { + name: "app" + files: [ + "file.cpp", + "file.h", + "main.cpp", + ] +} diff --git a/tests/auto/blackbox/testdata/check-timestamps/file.cpp b/tests/auto/blackbox/testdata/check-timestamps/file.cpp new file mode 100644 index 000000000..4752b89d5 --- /dev/null +++ b/tests/auto/blackbox/testdata/check-timestamps/file.cpp @@ -0,0 +1,3 @@ +#include "file.h" + +void f() { } diff --git a/tests/auto/blackbox/testdata/check-timestamps/file.h b/tests/auto/blackbox/testdata/check-timestamps/file.h new file mode 100644 index 000000000..789447c02 --- /dev/null +++ b/tests/auto/blackbox/testdata/check-timestamps/file.h @@ -0,0 +1 @@ +void f(); diff --git a/tests/auto/blackbox/testdata/check-timestamps/main.cpp b/tests/auto/blackbox/testdata/check-timestamps/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata/check-timestamps/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 6aa0fed2f..176f20816 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -4040,6 +4040,20 @@ void TestBlackbox::checkProjectFilePath() QVERIFY2(m_qbsStdout.contains("main2.cpp"), m_qbsStdout.constData()); } +void TestBlackbox::checkTimestamps() +{ + QDir::setCurrent(testDataDir + "/check-timestamps"); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("compiling file.cpp"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); + QVERIFY(QFile::remove(relativeBuildGraphFilePath())); + WAIT_FOR_NEW_TIMESTAMP(); + touch("file.h"); + QCOMPARE(runQbs(QStringList("--check-timestamps")), 0); + QVERIFY2(m_qbsStdout.contains("compiling file.cpp"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); +} + class TemporaryDefaultProfileRemover { public: diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 2f620017a..a56ac2e19 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -54,6 +54,7 @@ private slots: void changeInImportedFile(); void changeTrackingAndMultiplexing(); void checkProjectFilePath(); + void checkTimestamps(); void clean(); void cli(); void combinedSources(); |