forked from qt-creator/qt-creator
RemoteLinux: Use aspects more directly in MakeInstallStep
Change-Id: I0586f24154a42033e4c6c1a1ac6274e348447e2a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -32,12 +32,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
|
|
||||||
const char MakeAspectId[] = "RemoteLinux.MakeInstall.Make";
|
|
||||||
const char InstallRootAspectId[] = "RemoteLinux.MakeInstall.InstallRoot";
|
|
||||||
const char CleanInstallRootAspectId[] = "RemoteLinux.MakeInstall.CleanInstallRoot";
|
|
||||||
const char FullCommandLineAspectId[] = "RemoteLinux.MakeInstall.FullCommandLine";
|
|
||||||
const char CustomCommandLineAspectId[] = "RemoteLinux.MakeInstall.CustomCommandLine";
|
|
||||||
|
|
||||||
class MakeInstallStep : public MakeStep
|
class MakeInstallStep : public MakeStep
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -50,15 +44,16 @@ private:
|
|||||||
void finish(ProcessResult result) override;
|
void finish(ProcessResult result) override;
|
||||||
bool isJobCountSupported() const override { return false; }
|
bool isJobCountSupported() const override { return false; }
|
||||||
|
|
||||||
FilePath installRoot() const;
|
|
||||||
bool cleanInstallRoot() const;
|
|
||||||
|
|
||||||
void updateCommandFromAspect();
|
void updateCommandFromAspect();
|
||||||
void updateArgsFromAspect();
|
void updateArgsFromAspect();
|
||||||
void updateFullCommandLine();
|
void updateFullCommandLine();
|
||||||
void updateFromCustomCommandLineAspect();
|
void updateFromCustomCommandLineAspect();
|
||||||
|
|
||||||
StringAspect *customCommandLineAspect() const;
|
ExecutableAspect m_makeBinary{this};
|
||||||
|
FilePathAspect m_installRoot{this};
|
||||||
|
BoolAspect m_cleanInstallRoot{this};
|
||||||
|
StringAspect m_fullCommand{this};
|
||||||
|
StringAspect m_customCommand{this};
|
||||||
|
|
||||||
DeploymentData m_deploymentData;
|
DeploymentData m_deploymentData;
|
||||||
bool m_noInstallTarget = false;
|
bool m_noInstallTarget = false;
|
||||||
@@ -67,7 +62,7 @@ private:
|
|||||||
|
|
||||||
MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent, id)
|
MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent, id)
|
||||||
{
|
{
|
||||||
m_makeCommandAspect.setVisible(false);
|
m_makeBinary.setVisible(false);
|
||||||
m_buildTargetsAspect.setVisible(false);
|
m_buildTargetsAspect.setVisible(false);
|
||||||
m_userArgumentsAspect.setVisible(false);
|
m_userArgumentsAspect.setVisible(false);
|
||||||
m_overrideMakeflagsAspect.setVisible(false);
|
m_overrideMakeflagsAspect.setVisible(false);
|
||||||
@@ -87,42 +82,32 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
|
|||||||
rootPath = FilePath::fromString(tmpDir.path());
|
rootPath = FilePath::fromString(tmpDir.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto makeAspect = addAspect<ExecutableAspect>();
|
m_makeBinary.setDeviceSelector(parent->target(), ExecutableAspect::BuildDevice);
|
||||||
makeAspect->setDeviceSelector(parent->target(), ExecutableAspect::BuildDevice);
|
m_makeBinary.setSettingsKey("RemoteLinux.MakeInstall.Make");
|
||||||
makeAspect->setId(MakeAspectId);
|
m_makeBinary.setReadOnly(false);
|
||||||
makeAspect->setSettingsKey(MakeAspectId);
|
m_makeBinary.setLabelText(Tr::tr("Command:"));
|
||||||
makeAspect->setReadOnly(false);
|
connect(&m_makeBinary, &BaseAspect::changed,
|
||||||
makeAspect->setLabelText(Tr::tr("Command:"));
|
|
||||||
connect(makeAspect, &ExecutableAspect::changed,
|
|
||||||
this, &MakeInstallStep::updateCommandFromAspect);
|
this, &MakeInstallStep::updateCommandFromAspect);
|
||||||
|
|
||||||
const auto installRootAspect = addAspect<FilePathAspect>();
|
m_installRoot.setSettingsKey("RemoteLinux.MakeInstall.InstallRoot");
|
||||||
installRootAspect->setId(InstallRootAspectId);
|
m_installRoot.setExpectedKind(PathChooser::Directory);
|
||||||
installRootAspect->setSettingsKey(InstallRootAspectId);
|
m_installRoot.setLabelText(Tr::tr("Install root:"));
|
||||||
installRootAspect->setExpectedKind(PathChooser::Directory);
|
m_installRoot.setValue(rootPath);
|
||||||
installRootAspect->setLabelText(Tr::tr("Install root:"));
|
connect(&m_installRoot, &BaseAspect::changed,
|
||||||
installRootAspect->setValue(rootPath);
|
|
||||||
connect(installRootAspect, &StringAspect::changed,
|
|
||||||
this, &MakeInstallStep::updateArgsFromAspect);
|
this, &MakeInstallStep::updateArgsFromAspect);
|
||||||
|
|
||||||
const auto cleanInstallRootAspect = addAspect<BoolAspect>();
|
m_cleanInstallRoot.setSettingsKey("RemoteLinux.MakeInstall.CleanInstallRoot");
|
||||||
cleanInstallRootAspect->setId(CleanInstallRootAspectId);
|
m_cleanInstallRoot.setLabelText(Tr::tr("Clean install root first:"));
|
||||||
cleanInstallRootAspect->setSettingsKey(CleanInstallRootAspectId);
|
m_cleanInstallRoot.setLabelPlacement(BoolAspect::LabelPlacement::InExtraLabel);
|
||||||
cleanInstallRootAspect->setLabel(Tr::tr("Clean install root first:"),
|
m_cleanInstallRoot.setDefaultValue(true);
|
||||||
BoolAspect::LabelPlacement::InExtraLabel);
|
|
||||||
cleanInstallRootAspect->setValue(true);
|
|
||||||
|
|
||||||
const auto commandLineAspect = addAspect<StringAspect>();
|
m_fullCommand.setDisplayStyle(StringAspect::LabelDisplay);
|
||||||
commandLineAspect->setId(FullCommandLineAspectId);
|
m_fullCommand.setLabelText(Tr::tr("Full command line:"));
|
||||||
commandLineAspect->setDisplayStyle(StringAspect::LabelDisplay);
|
|
||||||
commandLineAspect->setLabelText(Tr::tr("Full command line:"));
|
|
||||||
|
|
||||||
const auto customCommandLineAspect = addAspect<StringAspect>();
|
m_customCommand.setSettingsKey("RemoteLinux.MakeInstall.CustomCommandLine");
|
||||||
customCommandLineAspect->setId(CustomCommandLineAspectId);
|
m_customCommand.setDisplayStyle(StringAspect::LineEditDisplay);
|
||||||
customCommandLineAspect->setSettingsKey(CustomCommandLineAspectId);
|
m_customCommand.setLabelText(Tr::tr("Custom command line:"));
|
||||||
customCommandLineAspect->setDisplayStyle(StringAspect::LineEditDisplay);
|
m_customCommand.makeCheckable(StringAspect::CheckBoxPlacement::Top,
|
||||||
customCommandLineAspect->setLabelText(Tr::tr("Custom command line:"));
|
|
||||||
customCommandLineAspect->makeCheckable(StringAspect::CheckBoxPlacement::Top,
|
|
||||||
Tr::tr("Use custom command line instead:"),
|
Tr::tr("Use custom command line instead:"),
|
||||||
"RemoteLinux.MakeInstall.EnableCustomCommandLine");
|
"RemoteLinux.MakeInstall.EnableCustomCommandLine");
|
||||||
const auto updateCommand = [this] {
|
const auto updateCommand = [this] {
|
||||||
@@ -131,15 +116,15 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
|
|||||||
updateFromCustomCommandLineAspect();
|
updateFromCustomCommandLineAspect();
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(customCommandLineAspect, &StringAspect::checkedChanged, this, updateCommand);
|
connect(&m_customCommand, &StringAspect::checkedChanged, this, updateCommand);
|
||||||
connect(customCommandLineAspect, &StringAspect::changed,
|
connect(&m_customCommand, &StringAspect::changed,
|
||||||
this, &MakeInstallStep::updateFromCustomCommandLineAspect);
|
this, &MakeInstallStep::updateFromCustomCommandLineAspect);
|
||||||
|
|
||||||
connect(target(), &Target::buildSystemUpdated, this, updateCommand);
|
connect(target(), &Target::buildSystemUpdated, this, updateCommand);
|
||||||
|
|
||||||
const MakeInstallCommand cmd = buildSystem()->makeInstallCommand(rootPath);
|
const MakeInstallCommand cmd = buildSystem()->makeInstallCommand(rootPath);
|
||||||
QTC_ASSERT(!cmd.command.isEmpty(), return);
|
QTC_ASSERT(!cmd.command.isEmpty(), return);
|
||||||
makeAspect->setExecutable(cmd.command.executable());
|
m_makeBinary.setExecutable(cmd.command.executable());
|
||||||
|
|
||||||
connect(this, &BuildStep::addOutput, this, [this](const QString &string, OutputFormat format) {
|
connect(this, &BuildStep::addOutput, this, [this](const QString &string, OutputFormat format) {
|
||||||
// When using Makefiles: "No rule to make target 'install'"
|
// When using Makefiles: "No rule to make target 'install'"
|
||||||
@@ -160,12 +145,12 @@ bool MakeInstallStep::init()
|
|||||||
if (!MakeStep::init())
|
if (!MakeStep::init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const FilePath rootDir = makeCommand().withNewPath(installRoot().path()); // FIXME: Needed?
|
const FilePath rootDir = makeCommand().withNewPath(m_installRoot().path()); // FIXME: Needed?
|
||||||
if (rootDir.isEmpty()) {
|
if (rootDir.isEmpty()) {
|
||||||
emit addTask(BuildSystemTask(Task::Error, Tr::tr("You must provide an install root.")));
|
emit addTask(BuildSystemTask(Task::Error, Tr::tr("You must provide an install root.")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cleanInstallRoot() && !rootDir.removeRecursively()) {
|
if (m_cleanInstallRoot() && !rootDir.removeRecursively()) {
|
||||||
emit addTask(BuildSystemTask(Task::Error,
|
emit addTask(BuildSystemTask(Task::Error,
|
||||||
Tr::tr("The install root \"%1\" could not be cleaned.")
|
Tr::tr("The install root \"%1\" could not be cleaned.")
|
||||||
.arg(rootDir.displayName())));
|
.arg(rootDir.displayName())));
|
||||||
@@ -206,7 +191,7 @@ bool MakeInstallStep::init()
|
|||||||
void MakeInstallStep::finish(ProcessResult result)
|
void MakeInstallStep::finish(ProcessResult result)
|
||||||
{
|
{
|
||||||
if (isSuccess(result)) {
|
if (isSuccess(result)) {
|
||||||
const FilePath rootDir = makeCommand().withNewPath(installRoot().path()); // FIXME: Needed?
|
const FilePath rootDir = makeCommand().withNewPath(m_installRoot().path()); // FIXME: Needed?
|
||||||
|
|
||||||
m_deploymentData = DeploymentData();
|
m_deploymentData = DeploymentData();
|
||||||
m_deploymentData.setLocalInstallRoot(rootDir);
|
m_deploymentData.setLocalInstallRoot(rootDir);
|
||||||
@@ -235,29 +220,19 @@ void MakeInstallStep::finish(ProcessResult result)
|
|||||||
MakeStep::finish(result);
|
MakeStep::finish(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath MakeInstallStep::installRoot() const
|
|
||||||
{
|
|
||||||
return static_cast<StringAspect *>(aspect(InstallRootAspectId))->filePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MakeInstallStep::cleanInstallRoot() const
|
|
||||||
{
|
|
||||||
return static_cast<BoolAspect *>(aspect(CleanInstallRootAspectId))->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MakeInstallStep::updateCommandFromAspect()
|
void MakeInstallStep::updateCommandFromAspect()
|
||||||
{
|
{
|
||||||
if (customCommandLineAspect()->isChecked())
|
if (m_customCommand.isChecked())
|
||||||
return;
|
return;
|
||||||
setMakeCommand(aspect<ExecutableAspect>()->executable());
|
setMakeCommand(m_makeBinary());
|
||||||
updateFullCommandLine();
|
updateFullCommandLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeInstallStep::updateArgsFromAspect()
|
void MakeInstallStep::updateArgsFromAspect()
|
||||||
{
|
{
|
||||||
if (customCommandLineAspect()->isChecked())
|
if (m_customCommand.isChecked())
|
||||||
return;
|
return;
|
||||||
const CommandLine cmd = buildSystem()->makeInstallCommand(installRoot()).command;
|
const CommandLine cmd = buildSystem()->makeInstallCommand(m_installRoot()).command;
|
||||||
setUserArguments(cmd.arguments());
|
setUserArguments(cmd.arguments());
|
||||||
updateFullCommandLine();
|
updateFullCommandLine();
|
||||||
}
|
}
|
||||||
@@ -265,24 +240,18 @@ void MakeInstallStep::updateArgsFromAspect()
|
|||||||
void MakeInstallStep::updateFullCommandLine()
|
void MakeInstallStep::updateFullCommandLine()
|
||||||
{
|
{
|
||||||
CommandLine cmd{makeExecutable(), userArguments(), CommandLine::Raw};
|
CommandLine cmd{makeExecutable(), userArguments(), CommandLine::Raw};
|
||||||
static_cast<StringAspect *>(aspect(FullCommandLineAspectId))->setValue(cmd.toUserOutput());
|
m_fullCommand.setValue(cmd.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeInstallStep::updateFromCustomCommandLineAspect()
|
void MakeInstallStep::updateFromCustomCommandLineAspect()
|
||||||
{
|
{
|
||||||
const StringAspect * const aspect = customCommandLineAspect();
|
if (m_customCommand.isChecked())
|
||||||
if (!aspect->isChecked())
|
|
||||||
return;
|
return;
|
||||||
const QStringList tokens = ProcessArgs::splitArgs(aspect->value(), HostOsInfo::hostOs());
|
const QStringList tokens = ProcessArgs::splitArgs(m_customCommand(), HostOsInfo::hostOs());
|
||||||
setMakeCommand(tokens.isEmpty() ? FilePath() : FilePath::fromString(tokens.first()));
|
setMakeCommand(tokens.isEmpty() ? FilePath() : FilePath::fromString(tokens.first()));
|
||||||
setUserArguments(ProcessArgs::joinArgs(tokens.mid(1)));
|
setUserArguments(ProcessArgs::joinArgs(tokens.mid(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringAspect *MakeInstallStep::customCommandLineAspect() const
|
|
||||||
{
|
|
||||||
return static_cast<StringAspect *>(aspect(CustomCommandLineAspectId));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MakeInstallStep::fromMap(const QVariantMap &map)
|
bool MakeInstallStep::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
if (!MakeStep::fromMap(map))
|
if (!MakeStep::fromMap(map))
|
||||||
|
Reference in New Issue
Block a user