aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2024-02-15 11:30:32 +0100
committerEike Ziller <eike.ziller@qt.io>2024-02-15 11:30:32 +0100
commit10a97be988e2bf8a4cefaa6e1d43b12782656871 (patch)
tree99cb7018312a5664629224c0114e45b804388df2 /src/plugins/projectexplorer
parentf00666a9853c8554f8d6b2a16aaf4a5f9521dae1 (diff)
parent27df099c152f3ebcd6788829d387120707126c2a (diff)
Merge remote-tracking branch 'origin/13.0'
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/buildaspects.cpp84
-rw-r--r--src/plugins/projectexplorer/buildaspects.h3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp8
-rw-r--r--src/plugins/projectexplorer/projectexplorersettings.cpp10
-rw-r--r--src/plugins/projectexplorer/projectexplorersettings.h2
5 files changed, 93 insertions, 14 deletions
diff --git a/src/plugins/projectexplorer/buildaspects.cpp b/src/plugins/projectexplorer/buildaspects.cpp
index a108558f36..18f7fe2b85 100644
--- a/src/plugins/projectexplorer/buildaspects.cpp
+++ b/src/plugins/projectexplorer/buildaspects.cpp
@@ -8,10 +8,13 @@
#include "devicesupport/idevice.h"
#include "kitaspects.h"
#include "projectexplorerconstants.h"
+#include "projectexplorer.h"
+#include "projectexplorersettings.h"
#include "projectexplorertr.h"
#include "target.h"
#include <coreplugin/fileutils.h>
+#include <coreplugin/icore.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
@@ -19,6 +22,8 @@
#include <utils/layoutbuilder.h>
#include <utils/pathchooser.h>
+#include <cctype>
+
using namespace Utils;
namespace ProjectExplorer {
@@ -31,8 +36,11 @@ public:
FilePath sourceDir;
Target * const target;
FilePath savedShadowBuildDir;
- QString problem;
- QPointer<InfoLabel> problemLabel;
+ QString specialProblem;
+ QLabel *genericProblemSpacer;
+ QLabel *specialProblemSpacer;
+ QPointer<InfoLabel> genericProblemLabel;
+ QPointer<InfoLabel> specialProblemLabel;
};
BuildDirectoryAspect::BuildDirectoryAspect(AspectContainer *container, const BuildConfiguration *bc)
@@ -48,6 +56,10 @@ BuildDirectoryAspect::BuildDirectoryAspect(AspectContainer *container, const Bui
if (!fixedDir.isEmpty())
text = fixedDir.toUserOutput();
+ const QString problem = updateProblemLabelsHelper(text);
+ if (!problem.isEmpty())
+ return QtFuture::makeReadyFuture(expected_str<QString>(make_unexpected(problem)));
+
const FilePath newPath = FilePath::fromUserInput(text);
const auto buildDevice = BuildDeviceKitAspect::device(d->target->kit());
@@ -56,12 +68,16 @@ BuildDirectoryAspect::BuildDirectoryAspect(AspectContainer *container, const Bui
return QtFuture::makeReadyFuture((Utils::expected_str<QString>(make_unexpected(
Tr::tr("The build directory is not reachable from the build device.")))));
}
+
return pathChooser()->defaultValidationFunction()(text);
});
setOpenTerminalHandler([this, bc] {
Core::FileUtils::openTerminal(expandedValue(), bc->environment());
});
+
+ connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
+ this, &BuildDirectoryAspect::validateInput);
}
BuildDirectoryAspect::~BuildDirectoryAspect()
@@ -83,8 +99,8 @@ bool BuildDirectoryAspect::isShadowBuild() const
void BuildDirectoryAspect::setProblem(const QString &description)
{
- d->problem = description;
- updateProblemLabel();
+ d->specialProblem = description;
+ validateInput();
}
void BuildDirectoryAspect::toMap(Store &map) const
@@ -110,10 +126,18 @@ void BuildDirectoryAspect::fromMap(const Store &map)
void BuildDirectoryAspect::addToLayout(Layouting::LayoutItem &parent)
{
FilePathAspect::addToLayout(parent);
- d->problemLabel = new InfoLabel({}, InfoLabel::Warning);
- d->problemLabel->setElideMode(Qt::ElideNone);
- parent.addItems({Layouting::br, Layouting::empty, d->problemLabel.data()});
- updateProblemLabel();
+ d->genericProblemSpacer = new QLabel;
+ d->specialProblemSpacer = new QLabel;
+ d->genericProblemLabel = new InfoLabel({}, InfoLabel::Warning);
+ d->genericProblemLabel->setElideMode(Qt::ElideNone);
+ connect(d->genericProblemLabel, &QLabel::linkActivated, this, [] {
+ Core::ICore::showOptionsDialog(Constants::BUILD_AND_RUN_SETTINGS_PAGE_ID);
+ });
+ d->specialProblemLabel = new InfoLabel({}, InfoLabel::Warning);
+ d->specialProblemLabel->setElideMode(Qt::ElideNone);
+ parent.addItems({Layouting::br, d->genericProblemSpacer, d->genericProblemLabel.data()});
+ parent.addItems({Layouting::br, d->specialProblemSpacer, d->specialProblemLabel.data()});
+ updateProblemLabels();
if (!d->sourceDir.isEmpty()) {
connect(this, &StringAspect::checkedChanged, this, [this] {
if (isChecked()) {
@@ -153,13 +177,47 @@ FilePath BuildDirectoryAspect::fixupDir(const FilePath &dir)
return {};
}
-void BuildDirectoryAspect::updateProblemLabel()
+void BuildDirectoryAspect::updateProblemLabels()
+{
+ updateProblemLabelsHelper(value());
+}
+
+QString BuildDirectoryAspect::updateProblemLabelsHelper(const QString &value)
{
- if (!d->problemLabel)
- return;
+ if (!d->genericProblemLabel)
+ return {};
+ QTC_ASSERT(d->specialProblemLabel, return {});
+
+ QString genericProblem;
+ QString genericProblemLabelString;
+ if (ProjectExplorerPlugin::projectExplorerSettings().warnAgainstNonAsciiBuildDir) {
+ const auto isInvalid = [](QChar c) { return c.isSpace() || !isascii(c.toLatin1()); };
+ if (const auto invalidChar = Utils::findOr(value, std::nullopt, isInvalid)) {
+ genericProblem = Tr::tr(
+ "Build directory contains potentially problematic character '%1'.")
+ .arg(*invalidChar);
+ genericProblemLabelString
+ = genericProblem
+ + Tr::tr(" This warning can be suppressed <a href=\"dummy\">here</a>.");
+ }
+ }
- d->problemLabel->setText(d->problem);
- d->problemLabel->setVisible(!d->problem.isEmpty());
+ auto updateRow = [](const QString &text, InfoLabel *label, QLabel *spacer) {
+ label->setText(text);
+ label->setVisible(!text.isEmpty());
+ spacer->setVisible(!text.isEmpty());
+ };
+
+ updateRow(genericProblemLabelString, d->genericProblemLabel, d->genericProblemSpacer);
+ updateRow(d->specialProblem, d->specialProblemLabel, d->specialProblemSpacer);
+
+ if (genericProblem.isEmpty() && d->specialProblem.isEmpty())
+ return {};
+ if (genericProblem.isEmpty())
+ return d->specialProblem;
+ if (d->specialProblem.isEmpty())
+ return genericProblem;
+ return genericProblem + '\n' + d->specialProblem;
}
SeparateDebugInfoAspect::SeparateDebugInfoAspect(AspectContainer *container)
diff --git a/src/plugins/projectexplorer/buildaspects.h b/src/plugins/projectexplorer/buildaspects.h
index f159cd9d37..f19cc39385 100644
--- a/src/plugins/projectexplorer/buildaspects.h
+++ b/src/plugins/projectexplorer/buildaspects.h
@@ -31,7 +31,8 @@ private:
void toMap(Utils::Store &map) const override;
void fromMap(const Utils::Store &map) override;
- void updateProblemLabel();
+ void updateProblemLabels();
+ QString updateProblemLabelsHelper(const QString &value);
class Private;
Private * const d;
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 4a9d1ef8aa..cf82aa6e73 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -281,6 +281,7 @@ const char CLEAR_ISSUES_ON_REBUILD_SETTINGS_KEY[] = "ProjectExplorer/Settings/Cl
const char ABORT_BUILD_ALL_ON_ERROR_SETTINGS_KEY[]
= "ProjectExplorer/Settings/AbortBuildAllOnError";
const char LOW_BUILD_PRIORITY_SETTINGS_KEY[] = "ProjectExplorer/Settings/LowBuildPriority";
+const char WARN_AGAINST_NON_ASCII_BUILD_DIR_SETTINGS_KEY[] = "ProjectExplorer/Settings/LowBuildPriority";
const char APP_ENV_CHANGES_SETTINGS_KEY[] = "ProjectExplorer/Settings/AppEnvChanges";
const char CUSTOM_PARSER_COUNT_KEY[] = "ProjectExplorer/Settings/CustomParserCount";
@@ -1696,6 +1697,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd->m_projectExplorerSettings.lowBuildPriority
= s->value(Constants::LOW_BUILD_PRIORITY_SETTINGS_KEY, defaultSettings.lowBuildPriority)
.toBool();
+ dd->m_projectExplorerSettings.warnAgainstNonAsciiBuildDir
+ = s->value(Constants::WARN_AGAINST_NON_ASCII_BUILD_DIR_SETTINGS_KEY,
+ defaultSettings.warnAgainstNonAsciiBuildDir)
+ .toBool();
dd->m_projectExplorerSettings.appEnvChanges = EnvironmentItem::fromStringList(
s->value(Constants::APP_ENV_CHANGES_SETTINGS_KEY).toStringList());
@@ -2258,6 +2263,9 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
s->setValueWithDefault(Constants::LOW_BUILD_PRIORITY_SETTINGS_KEY,
dd->m_projectExplorerSettings.lowBuildPriority,
defaultSettings.lowBuildPriority);
+ s->setValueWithDefault(Constants::WARN_AGAINST_NON_ASCII_BUILD_DIR_SETTINGS_KEY,
+ dd->m_projectExplorerSettings.warnAgainstNonAsciiBuildDir,
+ defaultSettings.warnAgainstNonAsciiBuildDir);
s->setValueWithDefault(Constants::AUTO_CREATE_RUN_CONFIGS_SETTINGS_KEY,
dd->m_projectExplorerSettings.automaticallyCreateRunConfigurations,
defaultSettings.automaticallyCreateRunConfigurations);
diff --git a/src/plugins/projectexplorer/projectexplorersettings.cpp b/src/plugins/projectexplorer/projectexplorersettings.cpp
index aa60eb4992..6cd79ce8f0 100644
--- a/src/plugins/projectexplorer/projectexplorersettings.cpp
+++ b/src/plugins/projectexplorer/projectexplorersettings.cpp
@@ -70,6 +70,7 @@ private:
QCheckBox *m_clearIssuesCheckBox;
QCheckBox *m_abortBuildAllOnErrorCheckBox;
QCheckBox *m_lowBuildPriorityCheckBox;
+ QCheckBox *m_warnAgainstNonAsciiBuildDirCheckBox;
QComboBox *m_buildBeforeDeployComboBox;
QComboBox *m_stopBeforeBuildComboBox;
QComboBox *m_terminalModeComboBox;
@@ -95,6 +96,12 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget()
m_clearIssuesCheckBox = new QCheckBox(Tr::tr("Clear issues list on new build"));
m_abortBuildAllOnErrorCheckBox = new QCheckBox(Tr::tr("Abort on error when building all projects"));
m_lowBuildPriorityCheckBox = new QCheckBox(Tr::tr("Start build processes with low priority"));
+ m_warnAgainstNonAsciiBuildDirCheckBox = new QCheckBox(
+ Tr::tr("Warn against build directories with spaces or non-ASCII characters"));
+ m_warnAgainstNonAsciiBuildDirCheckBox->setToolTip(
+ Tr::tr("Some legacy build tools do not deal well with paths that contain \"special\" "
+ "characters such as spaces, potentially resulting in spurious build errors.<p>"
+ "Uncheck this option if you do not work with such tools."));
m_buildBeforeDeployComboBox = new QComboBox;
m_buildBeforeDeployComboBox->addItem(Tr::tr("Do Not Build Anything"),
int(BuildBeforeRunMode::Off));
@@ -172,6 +179,7 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget()
m_clearIssuesCheckBox,
m_abortBuildAllOnErrorCheckBox,
m_lowBuildPriorityCheckBox,
+ m_warnAgainstNonAsciiBuildDirCheckBox,
Form {
appEnvDescriptionLabel, Row{m_appEnvLabel, appEnvButton, st}, br,
Tr::tr("Build before deploying:"), m_buildBeforeDeployComboBox, br,
@@ -219,6 +227,7 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const
m_settings.clearIssuesOnRebuild = m_clearIssuesCheckBox->isChecked();
m_settings.abortBuildAllOnError = m_abortBuildAllOnErrorCheckBox->isChecked();
m_settings.lowBuildPriority = m_lowBuildPriorityCheckBox->isChecked();
+ m_settings.warnAgainstNonAsciiBuildDir = m_warnAgainstNonAsciiBuildDirCheckBox->isChecked();
m_settings.appEnvChanges = m_appEnvChanges;
return m_settings;
}
@@ -242,6 +251,7 @@ void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings &
m_clearIssuesCheckBox->setChecked(m_settings.clearIssuesOnRebuild);
m_abortBuildAllOnErrorCheckBox->setChecked(m_settings.abortBuildAllOnError);
m_lowBuildPriorityCheckBox->setChecked(m_settings.lowBuildPriority);
+ m_warnAgainstNonAsciiBuildDirCheckBox->setChecked(m_settings.warnAgainstNonAsciiBuildDir);
}
FilePath ProjectExplorerSettingsWidget::projectsDirectory() const
diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h
index 244d4c76f8..dbec8ea2ae 100644
--- a/src/plugins/projectexplorer/projectexplorersettings.h
+++ b/src/plugins/projectexplorer/projectexplorersettings.h
@@ -36,6 +36,7 @@ public:
&& p1.clearIssuesOnRebuild == p2.clearIssuesOnRebuild
&& p1.abortBuildAllOnError == p2.abortBuildAllOnError
&& p1.appEnvChanges == p2.appEnvChanges
+ && p1.warnAgainstNonAsciiBuildDir == p2.warnAgainstNonAsciiBuildDir
&& p1.lowBuildPriority == p2.lowBuildPriority;
}
@@ -50,6 +51,7 @@ public:
bool clearIssuesOnRebuild = true;
bool abortBuildAllOnError = true;
bool lowBuildPriority = false;
+ bool warnAgainstNonAsciiBuildDir = true;
StopBeforeBuild stopBeforeBuild = Utils::HostOsInfo::isWindowsHost()
? StopBeforeBuild::SameProject
: StopBeforeBuild::None;