diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 20 | ||||
-rw-r--r-- | src/lib/corelib/tools/buildoptions.cpp | 21 | ||||
-rw-r--r-- | src/lib/corelib/tools/buildoptions.h | 3 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 447cdd287..150133c04 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -510,10 +510,26 @@ void Executor::finishJob(ExecutorJob *job, bool success) if (success) { m_project->buildData->isDirty = true; foreach (Artifact *artifact, transformer->outputs) { - if (artifact->alwaysUpdated) + if (artifact->alwaysUpdated) { artifact->setTimestamp(FileTime::currentTime()); - else + if (m_buildOptions.forceOutputCheck() && !FileInfo(artifact->filePath()).exists()) { + if (transformer->rule) { + if (!transformer->rule->name.isEmpty()) { + throw ErrorInfo(tr("Rule '%1' declares artifact '%2', " + "but the artifact was not produced.") + .arg(transformer->rule->name, artifact->filePath())); + } + throw ErrorInfo(tr("Rule declares artifact '%1', " + "but the artifact was not produced.") + .arg(artifact->filePath())); + } + throw ErrorInfo(tr("Transformer declares artifact '%1', " + "but the artifact was not produced.") + .arg(artifact->filePath())); + } + } else { artifact->setTimestamp(FileInfo(artifact->filePath()).lastModified()); + } } finishTransformer(transformer); } diff --git a/src/lib/corelib/tools/buildoptions.cpp b/src/lib/corelib/tools/buildoptions.cpp index fafb86404..a2d5c2db2 100644 --- a/src/lib/corelib/tools/buildoptions.cpp +++ b/src/lib/corelib/tools/buildoptions.cpp @@ -40,6 +40,7 @@ class BuildOptionsPrivate : public QSharedData public: BuildOptionsPrivate() : maxJobCount(0), dryRun(false), keepGoing(false), forceTimestampCheck(false), + forceOutputCheck(false), logElapsedTime(false), echoMode(defaultCommandEchoMode()), install(true), removeExistingInstallation(false), onlyExecuteRules(false) { @@ -52,6 +53,7 @@ public: bool dryRun; bool keepGoing; bool forceTimestampCheck; + bool forceOutputCheck; bool logElapsedTime; CommandEchoMode echoMode; bool install; @@ -240,6 +242,25 @@ void BuildOptions::setForceTimestampCheck(bool enabled) } /*! + * \brief Returns true if qbs will test whether rules and transformers actually create their + * declared output artifacts. + * The default is \c false. + */ +bool BuildOptions::forceOutputCheck() const +{ + return d->forceOutputCheck; +} + +/*! + * \brief Controls whether qbs should test whether rules and transformers actually create their + * declared output artifacts. Enabling this may introduce some small I/O overhead during the build. + */ +void BuildOptions::setForceOutputCheck(bool enabled) +{ + d->forceOutputCheck = enabled; +} + +/*! * \brief Returns true iff the time the operation takes will be logged. * The default is \c false. */ diff --git a/src/lib/corelib/tools/buildoptions.h b/src/lib/corelib/tools/buildoptions.h index df582bc4b..03187bbfe 100644 --- a/src/lib/corelib/tools/buildoptions.h +++ b/src/lib/corelib/tools/buildoptions.h @@ -70,6 +70,9 @@ public: bool forceTimestampCheck() const; void setForceTimestampCheck(bool enabled); + bool forceOutputCheck() const; + void setForceOutputCheck(bool enabled); + bool logElapsedTime() const; void setLogElapsedTime(bool log); |