forked from qt-creator/qt-creator
QmakeProjectManager: Make "system" execution opt-in
It has too many side effects.
Amends fcd6384f4d
.
T_SYSTEM and E_SYSTEM are now treated the same.
Fixes: QTCREATORBUG-24551
Change-Id: Ib6df2762d329f2ddc0dd66190454159d446a9ac9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
@@ -1161,13 +1161,14 @@ void IntegerAspect::setToolTip(const QString &tooltip)
|
|||||||
Its visual representation is a QComboBox with three items.
|
Its visual representation is a QComboBox with three items.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TriStateAspect::TriStateAspect()
|
TriStateAspect::TriStateAspect(const QString onString, const QString &offString,
|
||||||
|
const QString &defaultString)
|
||||||
{
|
{
|
||||||
setDisplayStyle(DisplayStyle::ComboBox);
|
setDisplayStyle(DisplayStyle::ComboBox);
|
||||||
setDefaultValue(2);
|
setDefaultValue(2);
|
||||||
addOption(tr("Enable"));
|
addOption(onString);
|
||||||
addOption(tr("Disable"));
|
addOption(offString);
|
||||||
addOption(tr("Leave at Default"));
|
addOption(defaultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState TriStateAspect::setting() const
|
TriState TriStateAspect::setting() const
|
||||||
|
@@ -322,7 +322,10 @@ class QTCREATOR_UTILS_EXPORT TriStateAspect : public SelectionAspect
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TriStateAspect();
|
TriStateAspect(
|
||||||
|
const QString onString = tr("Enable"),
|
||||||
|
const QString &offString = tr("Disable"),
|
||||||
|
const QString &defaultString = tr("Leave at Default"));
|
||||||
|
|
||||||
TriState setting() const;
|
TriState setting() const;
|
||||||
void setSetting(TriState setting);
|
void setSetting(TriState setting);
|
||||||
|
@@ -75,6 +75,17 @@ using namespace QmakeProjectManager::Internal;
|
|||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
|
|
||||||
|
class RunSystemAspect : public TriStateAspect
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RunSystemAspect() : TriStateAspect(tr("Run"), tr("Ignore"), tr("Use global setting"))
|
||||||
|
{
|
||||||
|
setSettingsKey("RunSystemFunction");
|
||||||
|
setDisplayName(tr("qmake system() behavior when parsing:"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
QmakeExtraBuildInfo::QmakeExtraBuildInfo()
|
QmakeExtraBuildInfo::QmakeExtraBuildInfo()
|
||||||
{
|
{
|
||||||
const BuildPropertiesSettings &settings = ProjectExplorerPlugin::buildPropertiesSettings();
|
const BuildPropertiesSettings &settings = ProjectExplorerPlugin::buildPropertiesSettings();
|
||||||
@@ -198,6 +209,8 @@ QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, Utils::Id id)
|
|||||||
emit qmakeBuildConfigurationChanged();
|
emit qmakeBuildConfigurationChanged();
|
||||||
qmakeBuildSystem()->scheduleUpdateAllNowOrLater();
|
qmakeBuildSystem()->scheduleUpdateAllNowOrLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addAspect<RunSystemAspect>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeBuildConfiguration::~QmakeBuildConfiguration()
|
QmakeBuildConfiguration::~QmakeBuildConfiguration()
|
||||||
@@ -439,6 +452,17 @@ void QmakeBuildConfiguration::forceQtQuickCompiler(bool enable)
|
|||||||
aspect<QtQuickCompilerAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
|
aspect<QtQuickCompilerAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QmakeBuildConfiguration::runSystemFunction() const
|
||||||
|
{
|
||||||
|
switch (aspect<RunSystemAspect>()->value()) {
|
||||||
|
case 0:
|
||||||
|
return true;
|
||||||
|
case 1:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return QmakeSettings::runSystemFunction();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList QmakeBuildConfiguration::configCommandLineArguments() const
|
QStringList QmakeBuildConfiguration::configCommandLineArguments() const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
@@ -875,3 +899,5 @@ void QmakeBuildConfiguration::restrictNextBuild(const RunConfiguration *rc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmakeProjectManager
|
} // namespace QmakeProjectManager
|
||||||
|
|
||||||
|
#include <qmakebuildconfiguration.moc>
|
||||||
|
@@ -106,6 +106,8 @@ public:
|
|||||||
Utils::TriState useQtQuickCompiler() const;
|
Utils::TriState useQtQuickCompiler() const;
|
||||||
void forceQtQuickCompiler(bool enable);
|
void forceQtQuickCompiler(bool enable);
|
||||||
|
|
||||||
|
bool runSystemFunction() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// emitted for setQMakeBuildConfig, not emitted for Qt version changes, even
|
/// emitted for setQMakeBuildConfig, not emitted for Qt version changes, even
|
||||||
/// if those change the qmakebuildconfig
|
/// if those change the qmakebuildconfig
|
||||||
|
@@ -797,6 +797,7 @@ QtSupport::ProFileReader *QmakeBuildSystem::createProFileReader(const QmakeProFi
|
|||||||
m_qmakeGlobals->environment.insert(env.key(eit), env.expandedValueForKey(env.key(eit)));
|
m_qmakeGlobals->environment.insert(env.key(eit), env.expandedValueForKey(env.key(eit)));
|
||||||
|
|
||||||
m_qmakeGlobals->setCommandLineArguments(buildDir(rootProFile()->filePath()).toString(), qmakeArgs);
|
m_qmakeGlobals->setCommandLineArguments(buildDir(rootProFile()->filePath()).toString(), qmakeArgs);
|
||||||
|
m_qmakeGlobals->runSystemFunction = bc->runSystemFunction();
|
||||||
|
|
||||||
QtSupport::ProFileCacheManager::instance()->incRefCount();
|
QtSupport::ProFileCacheManager::instance()->incRefCount();
|
||||||
|
|
||||||
|
@@ -38,11 +38,13 @@ 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";
|
const char ALWAYS_RUN_QMAKE_KEY[] = "QmakeProjectManager/AlwaysRunQmake";
|
||||||
|
const char RUN_SYSTEM_KEY[] = "QmakeProjectManager/RunSystemFunction";
|
||||||
|
|
||||||
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;
|
&& s1.alwaysRunQmake == s2.alwaysRunQmake
|
||||||
|
&& s1.runSystemFunction == s2.runSystemFunction;
|
||||||
}
|
}
|
||||||
static bool operator!=(const QmakeSettingsData &s1, const QmakeSettingsData &s2)
|
static bool operator!=(const QmakeSettingsData &s1, const QmakeSettingsData &s2)
|
||||||
{
|
{
|
||||||
@@ -59,6 +61,11 @@ bool QmakeSettings::alwaysRunQmake()
|
|||||||
return instance().m_settings.alwaysRunQmake;
|
return instance().m_settings.alwaysRunQmake;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QmakeSettings::runSystemFunction()
|
||||||
|
{
|
||||||
|
return instance().m_settings.runSystemFunction;
|
||||||
|
}
|
||||||
|
|
||||||
QmakeSettings &QmakeSettings::instance()
|
QmakeSettings &QmakeSettings::instance()
|
||||||
{
|
{
|
||||||
static QmakeSettings theSettings;
|
static QmakeSettings theSettings;
|
||||||
@@ -85,6 +92,7 @@ void QmakeSettings::loadSettings()
|
|||||||
m_settings.warnAgainstUnalignedBuildDir = s->value(
|
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();
|
m_settings.alwaysRunQmake = s->value(ALWAYS_RUN_QMAKE_KEY, false).toBool();
|
||||||
|
m_settings.runSystemFunction = s->value(RUN_SYSTEM_KEY, false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeSettings::storeSettings() const
|
void QmakeSettings::storeSettings() const
|
||||||
@@ -92,6 +100,7 @@ void QmakeSettings::storeSettings() const
|
|||||||
QSettings * const s = Core::ICore::settings();
|
QSettings * const s = Core::ICore::settings();
|
||||||
s->setValue(BUILD_DIR_WARNING_KEY, warnAgainstUnalignedBuildDir());
|
s->setValue(BUILD_DIR_WARNING_KEY, warnAgainstUnalignedBuildDir());
|
||||||
s->setValue(ALWAYS_RUN_QMAKE_KEY, alwaysRunQmake());
|
s->setValue(ALWAYS_RUN_QMAKE_KEY, alwaysRunQmake());
|
||||||
|
s->setValue(RUN_SYSTEM_KEY, runSystemFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
class QmakeSettingsPage::SettingsWidget : public QWidget
|
class QmakeSettingsPage::SettingsWidget : public QWidget
|
||||||
@@ -110,9 +119,15 @@ public:
|
|||||||
m_alwaysRunQmakeCheckbox.setToolTip(tr("This option can help to prevent failures on "
|
m_alwaysRunQmakeCheckbox.setToolTip(tr("This option can help to prevent failures on "
|
||||||
"incremental builds, but might slow them down unnecessarily in the general case."));
|
"incremental builds, but might slow them down unnecessarily in the general case."));
|
||||||
m_alwaysRunQmakeCheckbox.setChecked(QmakeSettings::alwaysRunQmake());
|
m_alwaysRunQmakeCheckbox.setChecked(QmakeSettings::alwaysRunQmake());
|
||||||
|
m_ignoreSystemCheckbox.setText(tr("Ignore qmake's system() function "
|
||||||
|
"when parsing a project"));
|
||||||
|
m_ignoreSystemCheckbox.setToolTip(tr("Unchecking this option can help getting more exact "
|
||||||
|
"parsing results, but can have unwanted side effects."));
|
||||||
|
m_ignoreSystemCheckbox.setChecked(!QmakeSettings::runSystemFunction());
|
||||||
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->addWidget(&m_alwaysRunQmakeCheckbox);
|
||||||
|
layout->addWidget(&m_ignoreSystemCheckbox);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +136,14 @@ public:
|
|||||||
QmakeSettingsData settings;
|
QmakeSettingsData settings;
|
||||||
settings.warnAgainstUnalignedBuildDir = m_warnAgainstUnalignedBuildDirCheckbox.isChecked();
|
settings.warnAgainstUnalignedBuildDir = m_warnAgainstUnalignedBuildDirCheckbox.isChecked();
|
||||||
settings.alwaysRunQmake = m_alwaysRunQmakeCheckbox.isChecked();
|
settings.alwaysRunQmake = m_alwaysRunQmakeCheckbox.isChecked();
|
||||||
|
settings.runSystemFunction = !m_ignoreSystemCheckbox.isChecked();
|
||||||
QmakeSettings::setSettingsData(settings);
|
QmakeSettings::setSettingsData(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCheckBox m_warnAgainstUnalignedBuildDirCheckbox;
|
QCheckBox m_warnAgainstUnalignedBuildDirCheckbox;
|
||||||
QCheckBox m_alwaysRunQmakeCheckbox;
|
QCheckBox m_alwaysRunQmakeCheckbox;
|
||||||
|
QCheckBox m_ignoreSystemCheckbox;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmakeSettingsPage::QmakeSettingsPage()
|
QmakeSettingsPage::QmakeSettingsPage()
|
||||||
|
@@ -37,6 +37,7 @@ class QmakeSettingsData {
|
|||||||
public:
|
public:
|
||||||
bool warnAgainstUnalignedBuildDir = false;
|
bool warnAgainstUnalignedBuildDir = false;
|
||||||
bool alwaysRunQmake = false;
|
bool alwaysRunQmake = false;
|
||||||
|
bool runSystemFunction = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmakeSettings : public QObject
|
class QmakeSettings : public QObject
|
||||||
@@ -46,6 +47,7 @@ public:
|
|||||||
static QmakeSettings &instance();
|
static QmakeSettings &instance();
|
||||||
static bool warnAgainstUnalignedBuildDir();
|
static bool warnAgainstUnalignedBuildDir();
|
||||||
static bool alwaysRunQmake();
|
static bool alwaysRunQmake();
|
||||||
|
static bool runSystemFunction();
|
||||||
static void setSettingsData(const QmakeSettingsData &settings);
|
static void setSettingsData(const QmakeSettingsData &settings);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -931,8 +931,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
else if (!m_tmp2.compare(QLatin1String("lines"), Qt::CaseInsensitive))
|
else if (!m_tmp2.compare(QLatin1String("lines"), Qt::CaseInsensitive))
|
||||||
lines = true;
|
lines = true;
|
||||||
}
|
}
|
||||||
int exitCode;
|
int exitCode = 0;
|
||||||
QByteArray bytes = getCommandOutput(args.at(0).toQString(), &exitCode);
|
QByteArray bytes;
|
||||||
|
if (m_option->runSystemFunction)
|
||||||
|
bytes = getCommandOutput(args.at(0).toQString(), &exitCode);
|
||||||
if (args.count() > 2 && !args.at(2).isEmpty()) {
|
if (args.count() > 2 && !args.at(2).isEmpty()) {
|
||||||
m_valuemapStack.top()[args.at(2).toKey()] =
|
m_valuemapStack.top()[args.at(2).toKey()] =
|
||||||
ProStringList(ProString(QString::number(exitCode)));
|
ProStringList(ProString(QString::number(exitCode)));
|
||||||
@@ -1778,6 +1780,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
|||||||
evalError(fL1S("system(exec) requires one argument."));
|
evalError(fL1S("system(exec) requires one argument."));
|
||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
}
|
}
|
||||||
|
if (!m_option->runSystemFunction)
|
||||||
|
return ReturnTrue;
|
||||||
if (m_cumulative) // Anything else would be insanity
|
if (m_cumulative) // Anything else would be insanity
|
||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#ifndef QT_BOOTSTRAPPED
|
||||||
|
@@ -110,6 +110,7 @@ public:
|
|||||||
QString qmakespec, xqmakespec;
|
QString qmakespec, xqmakespec;
|
||||||
QString user_template, user_template_prefix;
|
QString user_template, user_template_prefix;
|
||||||
QString extra_cmds[4];
|
QString extra_cmds[4];
|
||||||
|
bool runSystemFunction = false;
|
||||||
|
|
||||||
#ifdef PROEVALUATOR_DEBUG
|
#ifdef PROEVALUATOR_DEBUG
|
||||||
int debugLevel;
|
int debugLevel;
|
||||||
|
Reference in New Issue
Block a user