RemoteLinux: Allow custom command line in MakeInstallStep

Let users tweak the "make install" command, in case they have special
requirements.

Fixes: QTCREATORBUG-23320
Change-Id: Ifa3c7bc499ef1e5d277fdb4cdac461aae575fd6b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-12-11 12:52:07 +01:00
parent 4e3bc88eef
commit 97edfa7b58
2 changed files with 44 additions and 2 deletions

View File

@@ -51,6 +51,7 @@ const char MakeAspectId[] = "RemoteLinux.MakeInstall.Make";
const char InstallRootAspectId[] = "RemoteLinux.MakeInstall.InstallRoot"; const char InstallRootAspectId[] = "RemoteLinux.MakeInstall.InstallRoot";
const char CleanInstallRootAspectId[] = "RemoteLinux.MakeInstall.CleanInstallRoot"; const char CleanInstallRootAspectId[] = "RemoteLinux.MakeInstall.CleanInstallRoot";
const char FullCommandLineAspectId[] = "RemoteLinux.MakeInstall.FullCommandLine"; const char FullCommandLineAspectId[] = "RemoteLinux.MakeInstall.FullCommandLine";
const char CustomCommandLineAspectId[] = "RemoteLinux.MakeInstall.CustomCommandLine";
MakeInstallStep::MakeInstallStep(BuildStepList *parent) : MakeStep(parent, stepId()) MakeInstallStep::MakeInstallStep(BuildStepList *parent) : MakeStep(parent, stepId())
{ {
@@ -76,8 +77,8 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent) : MakeStep(parent, stepI
const auto cleanInstallRootAspect = addAspect<BaseBoolAspect>(); const auto cleanInstallRootAspect = addAspect<BaseBoolAspect>();
cleanInstallRootAspect->setId(CleanInstallRootAspectId); cleanInstallRootAspect->setId(CleanInstallRootAspectId);
cleanInstallRootAspect->setSettingsKey(CleanInstallRootAspectId); cleanInstallRootAspect->setSettingsKey(CleanInstallRootAspectId);
cleanInstallRootAspect->setLabel(tr("Clean install root first"), cleanInstallRootAspect->setLabel(tr("Clean install root first:"),
BaseBoolAspect::LabelPlacement::AtCheckBox); BaseBoolAspect::LabelPlacement::InExtraLabel);
cleanInstallRootAspect->setValue(false); cleanInstallRootAspect->setValue(false);
const auto commandLineAspect = addAspect<BaseStringAspect>(); const auto commandLineAspect = addAspect<BaseStringAspect>();
@@ -85,6 +86,23 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent) : MakeStep(parent, stepI
commandLineAspect->setDisplayStyle(BaseStringAspect::LabelDisplay); commandLineAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
commandLineAspect->setLabelText(tr("Full command line:")); commandLineAspect->setLabelText(tr("Full command line:"));
const auto customCommandLineAspect = addAspect<BaseStringAspect>();
customCommandLineAspect->setId(CustomCommandLineAspectId);
customCommandLineAspect->setSettingsKey(CustomCommandLineAspectId);
customCommandLineAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
customCommandLineAspect->setLabelText(tr("Custom command line:"));
customCommandLineAspect->makeCheckable(BaseStringAspect::CheckBoxPlacement::Top,
tr("Use custom command line instead:"),
"RemoteLinux.MakeInstall.EnableCustomCommandLine");
connect(customCommandLineAspect, &BaseStringAspect::checkedChanged,
this, &MakeInstallStep::updateCommandFromAspect);
connect(customCommandLineAspect, &BaseStringAspect::checkedChanged,
this, &MakeInstallStep::updateArgsFromAspect);
connect(customCommandLineAspect, &BaseStringAspect::checkedChanged,
this, &MakeInstallStep::updateFromCustomCommandLineAspect);
connect(customCommandLineAspect, &BaseStringAspect::changed,
this, &MakeInstallStep::updateFromCustomCommandLineAspect);
QTemporaryDir tmpDir; QTemporaryDir tmpDir;
installRootAspect->setFilePath(FilePath::fromString(tmpDir.path())); installRootAspect->setFilePath(FilePath::fromString(tmpDir.path()));
const MakeInstallCommand cmd = target()->makeInstallCommand(tmpDir.path()); const MakeInstallCommand cmd = target()->makeInstallCommand(tmpDir.path());
@@ -199,12 +217,16 @@ bool MakeInstallStep::cleanInstallRoot() const
void MakeInstallStep::updateCommandFromAspect() void MakeInstallStep::updateCommandFromAspect()
{ {
if (customCommandLineAspect()->isChecked())
return;
setMakeCommand(aspect<ExecutableAspect>()->executable()); setMakeCommand(aspect<ExecutableAspect>()->executable());
updateFullCommandLine(); updateFullCommandLine();
} }
void MakeInstallStep::updateArgsFromAspect() void MakeInstallStep::updateArgsFromAspect()
{ {
if (customCommandLineAspect()->isChecked())
return;
setUserArguments(QtcProcess::joinArgs(target()->makeInstallCommand( setUserArguments(QtcProcess::joinArgs(target()->makeInstallCommand(
static_cast<BaseStringAspect *>(aspect(InstallRootAspectId))->filePath().toString()) static_cast<BaseStringAspect *>(aspect(InstallRootAspectId))->filePath().toString())
.arguments)); .arguments));
@@ -220,12 +242,28 @@ void MakeInstallStep::updateFullCommandLine()
+ ' ' + userArguments()); + ' ' + userArguments());
} }
void MakeInstallStep::updateFromCustomCommandLineAspect()
{
const BaseStringAspect * const aspect = customCommandLineAspect();
if (!aspect->isChecked())
return;
const QStringList tokens = QtcProcess::splitArgs(aspect->value());
setMakeCommand(tokens.isEmpty() ? FilePath() : FilePath::fromString(tokens.first()));
setUserArguments(QtcProcess::joinArgs(tokens.mid(1)));
}
BaseStringAspect *MakeInstallStep::customCommandLineAspect() const
{
return static_cast<BaseStringAspect *>(aspect(CustomCommandLineAspectId));
}
bool MakeInstallStep::fromMap(const QVariantMap &map) bool MakeInstallStep::fromMap(const QVariantMap &map)
{ {
if (!MakeStep::fromMap(map)) if (!MakeStep::fromMap(map))
return false; return false;
updateCommandFromAspect(); updateCommandFromAspect();
updateArgsFromAspect(); updateArgsFromAspect();
updateFromCustomCommandLineAspect();
return true; return true;
} }

View File

@@ -30,6 +30,7 @@
#include <projectexplorer/deploymentdata.h> #include <projectexplorer/deploymentdata.h>
#include <projectexplorer/makestep.h> #include <projectexplorer/makestep.h>
namespace ProjectExplorer { class BaseStringAspect; }
namespace Utils { class FilePath; } namespace Utils { class FilePath; }
namespace RemoteLinux { namespace RemoteLinux {
@@ -57,6 +58,9 @@ private:
void updateCommandFromAspect(); void updateCommandFromAspect();
void updateArgsFromAspect(); void updateArgsFromAspect();
void updateFullCommandLine(); void updateFullCommandLine();
void updateFromCustomCommandLineAspect();
ProjectExplorer::BaseStringAspect *customCommandLineAspect() const;
ProjectExplorer::DeploymentData m_deploymentData; ProjectExplorer::DeploymentData m_deploymentData;
bool m_noInstallTarget = false; bool m_noInstallTarget = false;