Qmake: Allow users to force a qmake run on every build

Some people are fine with paying the extra cost for the somewhat lower
chance of an incremental build breakage.

Fixes: QTCREATORBUG-20888
Change-Id: I96409dfbbc7c747cb01dacbf1efc2b10ee38d07a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Christian Kandeler
2019-03-06 10:44:28 +01:00
parent 940e798a3a
commit a8ebc37da2
3 changed files with 27 additions and 5 deletions

View File

@@ -37,10 +37,12 @@ namespace QmakeProjectManager {
namespace Internal { namespace Internal {
const char BUILD_DIR_WARNING_KEY[] = "QmakeProjectManager/WarnAgainstUnalignedBuildDir"; const char BUILD_DIR_WARNING_KEY[] = "QmakeProjectManager/WarnAgainstUnalignedBuildDir";
const char ALWAYS_RUN_QMAKE_KEY[] = "QmakeProjectManager/AlwaysRunQmake";
static bool operator==(const QmakeSettingsData &s1, const QmakeSettingsData &s2) static bool operator==(const QmakeSettingsData &s1, const QmakeSettingsData &s2)
{ {
return s1.warnAgainstUnalignedBuildDir == s2.warnAgainstUnalignedBuildDir; return s1.warnAgainstUnalignedBuildDir == s2.warnAgainstUnalignedBuildDir
&& s1.alwaysRunQmake == s2.alwaysRunQmake;
} }
static bool operator!=(const QmakeSettingsData &s1, const QmakeSettingsData &s2) static bool operator!=(const QmakeSettingsData &s1, const QmakeSettingsData &s2)
{ {
@@ -52,6 +54,11 @@ bool QmakeSettings::warnAgainstUnalignedBuildDir()
return instance().m_settings.warnAgainstUnalignedBuildDir; return instance().m_settings.warnAgainstUnalignedBuildDir;
} }
bool QmakeSettings::alwaysRunQmake()
{
return instance().m_settings.alwaysRunQmake;
}
QmakeSettings &QmakeSettings::instance() QmakeSettings &QmakeSettings::instance()
{ {
static QmakeSettings theSettings; static QmakeSettings theSettings;
@@ -74,13 +81,17 @@ QmakeSettings::QmakeSettings()
void QmakeSettings::loadSettings() void QmakeSettings::loadSettings()
{ {
m_settings.warnAgainstUnalignedBuildDir = Core::ICore::settings()->value( QSettings * const s = Core::ICore::settings();
m_settings.warnAgainstUnalignedBuildDir = s->value(
BUILD_DIR_WARNING_KEY, Utils::HostOsInfo::isWindowsHost()).toBool(); BUILD_DIR_WARNING_KEY, Utils::HostOsInfo::isWindowsHost()).toBool();
m_settings.alwaysRunQmake = s->value(ALWAYS_RUN_QMAKE_KEY, false).toBool();
} }
void QmakeSettings::storeSettings() const void QmakeSettings::storeSettings() const
{ {
Core::ICore::settings()->setValue(BUILD_DIR_WARNING_KEY, warnAgainstUnalignedBuildDir()); QSettings * const s = Core::ICore::settings();
s->setValue(BUILD_DIR_WARNING_KEY, warnAgainstUnalignedBuildDir());
s->setValue(ALWAYS_RUN_QMAKE_KEY, alwaysRunQmake());
} }
class QmakeSettingsPage::SettingsWidget : public QWidget class QmakeSettingsPage::SettingsWidget : public QWidget
@@ -95,8 +106,13 @@ public:
"can trigger if source and build directory are not at the same level.")); "can trigger if source and build directory are not at the same level."));
m_warnAgainstUnalignedBuildDirCheckbox.setChecked( m_warnAgainstUnalignedBuildDirCheckbox.setChecked(
QmakeSettings::warnAgainstUnalignedBuildDir()); QmakeSettings::warnAgainstUnalignedBuildDir());
m_alwaysRunQmakeCheckbox.setText(tr("Run qmake on every build"));
m_alwaysRunQmakeCheckbox.setToolTip(tr("This option can help to prevent failures on "
"incremental builds, but might slow them down unnecessarily in the general case."));
m_alwaysRunQmakeCheckbox.setChecked(QmakeSettings::alwaysRunQmake());
const auto layout = new QVBoxLayout(this); const auto layout = new QVBoxLayout(this);
layout->addWidget(&m_warnAgainstUnalignedBuildDirCheckbox); layout->addWidget(&m_warnAgainstUnalignedBuildDirCheckbox);
layout->addWidget(&m_alwaysRunQmakeCheckbox);
layout->addStretch(1); layout->addStretch(1);
} }
@@ -104,11 +120,13 @@ public:
{ {
QmakeSettingsData settings; QmakeSettingsData settings;
settings.warnAgainstUnalignedBuildDir = m_warnAgainstUnalignedBuildDirCheckbox.isChecked(); settings.warnAgainstUnalignedBuildDir = m_warnAgainstUnalignedBuildDirCheckbox.isChecked();
settings.alwaysRunQmake = m_alwaysRunQmakeCheckbox.isChecked();
QmakeSettings::setSettingsData(settings); QmakeSettings::setSettingsData(settings);
} }
private: private:
QCheckBox m_warnAgainstUnalignedBuildDirCheckbox; QCheckBox m_warnAgainstUnalignedBuildDirCheckbox;
QCheckBox m_alwaysRunQmakeCheckbox;
}; };
QmakeSettingsPage::QmakeSettingsPage() QmakeSettingsPage::QmakeSettingsPage()

View File

@@ -36,6 +36,7 @@ namespace Internal {
class QmakeSettingsData { class QmakeSettingsData {
public: public:
bool warnAgainstUnalignedBuildDir = false; bool warnAgainstUnalignedBuildDir = false;
bool alwaysRunQmake = false;
}; };
class QmakeSettings : public QObject class QmakeSettings : public QObject
@@ -44,6 +45,7 @@ class QmakeSettings : public QObject
public: public:
static QmakeSettings &instance(); static QmakeSettings &instance();
static bool warnAgainstUnalignedBuildDir(); static bool warnAgainstUnalignedBuildDir();
static bool alwaysRunQmake();
static void setSettingsData(const QmakeSettingsData &settings); static void setSettingsData(const QmakeSettingsData &settings);
signals: signals:

View File

@@ -33,6 +33,7 @@
#include "qmakeparser.h" #include "qmakeparser.h"
#include "qmakeproject.h" #include "qmakeproject.h"
#include "qmakeprojectmanagerconstants.h" #include "qmakeprojectmanagerconstants.h"
#include "qmakesettings.h"
#include <projectexplorer/buildmanager.h> #include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
@@ -213,9 +214,10 @@ bool QMakeStep::init()
} }
// Check whether we need to run qmake // Check whether we need to run qmake
bool makefileOutDated = (qmakeBc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches); if (m_forced || QmakeSettings::alwaysRunQmake()
if (m_forced || makefileOutDated) || qmakeBc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches) {
m_needToRunQMake = true; m_needToRunQMake = true;
}
m_forced = false; m_forced = false;
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();