forked from qt-creator/qt-creator
AbstractProcessStep: Remove processStarted() virtual method
Add concealedParameters / setConcealedParameters instead, to be used in AndroidBuildApkStep. Use concealed parameters also on start failure and on done. By default, concealedParameters() equals processParameters() (i.e. no sensitive data to hide) unless the implementation decides to replace some sensitive data (e.g. password) with asterisks. In this case the reimplementation needs to store separate instance of ProcessParameters and redirect the pointer of concealedParameters() into own structure. This is being done through a call to setConcealedParameters(). Change-Id: I8b1573b007c0f8a10c9592ccaf25e6f088f04691 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -578,12 +578,9 @@ bool AndroidBuildApkStep::init()
|
|||||||
processParameters()->setCommandLine({command, arguments});
|
processParameters()->setCommandLine({command, arguments});
|
||||||
|
|
||||||
// Generate arguments with keystore password concealed
|
// Generate arguments with keystore password concealed
|
||||||
ProjectExplorer::ProcessParameters pp2;
|
setupProcessParameters(&m_concealedParams);
|
||||||
setupProcessParameters(&pp2);
|
m_concealedParams.setCommandLine({command, argumentsPasswordConcealed});
|
||||||
pp2.setCommandLine({command, argumentsPasswordConcealed});
|
setDisplayedParameters(&m_concealedParams);
|
||||||
m_command = pp2.effectiveCommand();
|
|
||||||
m_argumentsPasswordConcealed = pp2.prettyArguments();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,13 +833,6 @@ void AndroidBuildApkStep::reportWarningOrError(const QString &message, Task::Tas
|
|||||||
TaskHub::addTask(BuildSystemTask(type, message));
|
TaskHub::addTask(BuildSystemTask(type, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBuildApkStep::processStarted()
|
|
||||||
{
|
|
||||||
emit addOutput(Tr::tr("Starting: \"%1\" %2")
|
|
||||||
.arg(m_command.toUserOutput(), m_argumentsPasswordConcealed),
|
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AndroidBuildApkStep::fromMap(const QVariantMap &map)
|
bool AndroidBuildApkStep::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_keystorePath = FilePath::fromVariant(map.value(KeystoreLocationKey));
|
m_keystorePath = FilePath::fromVariant(map.value(KeystoreLocationKey));
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "android_global.h"
|
#include "android_global.h"
|
||||||
|
|
||||||
#include <projectexplorer/abstractprocessstep.h>
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
@@ -61,7 +62,6 @@ private:
|
|||||||
bool init() override;
|
bool init() override;
|
||||||
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
|
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
|
||||||
QWidget *createConfigWidget() override;
|
QWidget *createConfigWidget() override;
|
||||||
void processStarted() override;
|
|
||||||
void processFinished(bool success) override;
|
void processFinished(bool success) override;
|
||||||
bool verifyKeystorePassword();
|
bool verifyKeystorePassword();
|
||||||
bool verifyCertificatePassword();
|
bool verifyCertificatePassword();
|
||||||
@@ -84,8 +84,7 @@ private:
|
|||||||
QString m_certificatePasswd;
|
QString m_certificatePasswd;
|
||||||
Utils::FilePath m_packagePath;
|
Utils::FilePath m_packagePath;
|
||||||
|
|
||||||
Utils::FilePath m_command;
|
ProjectExplorer::ProcessParameters m_concealedParams;
|
||||||
QString m_argumentsPasswordConcealed;
|
|
||||||
bool m_skipBuilding = false;
|
bool m_skipBuilding = false;
|
||||||
Utils::FilePath m_inputFile;
|
Utils::FilePath m_inputFile;
|
||||||
};
|
};
|
||||||
|
@@ -76,6 +76,7 @@ public:
|
|||||||
AbstractProcessStep *q;
|
AbstractProcessStep *q;
|
||||||
std::unique_ptr<QtcProcess> m_process;
|
std::unique_ptr<QtcProcess> m_process;
|
||||||
ProcessParameters m_param;
|
ProcessParameters m_param;
|
||||||
|
ProcessParameters *m_displayedParams = &m_param;
|
||||||
std::function<CommandLine()> m_commandLineProvider;
|
std::function<CommandLine()> m_commandLineProvider;
|
||||||
std::function<FilePath()> m_workingDirectoryProvider;
|
std::function<FilePath()> m_workingDirectoryProvider;
|
||||||
std::function<void(Environment &)> m_environmentModifier;
|
std::function<void(Environment &)> m_environmentModifier;
|
||||||
@@ -100,7 +101,7 @@ AbstractProcessStep::~AbstractProcessStep()
|
|||||||
void AbstractProcessStep::emitFaultyConfigurationMessage()
|
void AbstractProcessStep::emitFaultyConfigurationMessage()
|
||||||
{
|
{
|
||||||
emit addOutput(tr("Configuration is faulty. Check the Issues view for details."),
|
emit addOutput(tr("Configuration is faulty. Check the Issues view for details."),
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
OutputFormat::NormalMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractProcessStep::ignoreReturnValue() const
|
bool AbstractProcessStep::ignoreReturnValue() const
|
||||||
@@ -172,7 +173,7 @@ void AbstractProcessStep::doRun()
|
|||||||
if (!wd.exists()) {
|
if (!wd.exists()) {
|
||||||
if (!wd.createDir()) {
|
if (!wd.createDir()) {
|
||||||
emit addOutput(tr("Could not create directory \"%1\"").arg(wd.toUserOutput()),
|
emit addOutput(tr("Could not create directory \"%1\"").arg(wd.toUserOutput()),
|
||||||
BuildStep::OutputFormat::ErrorMessage);
|
OutputFormat::ErrorMessage);
|
||||||
finish(false);
|
finish(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -209,8 +210,12 @@ void AbstractProcessStep::doRun()
|
|||||||
connect(d->m_process.get(), &QtcProcess::readyReadStandardError, this, [this] {
|
connect(d->m_process.get(), &QtcProcess::readyReadStandardError, this, [this] {
|
||||||
stdError(d->stderrStream->toUnicode(d->m_process->readAllStandardError()));
|
stdError(d->stderrStream->toUnicode(d->m_process->readAllStandardError()));
|
||||||
});
|
});
|
||||||
connect(d->m_process.get(), &QtcProcess::started,
|
connect(d->m_process.get(), &QtcProcess::started, this, [this] {
|
||||||
this, &AbstractProcessStep::processStarted);
|
ProcessParameters *params = displayedParameters();
|
||||||
|
emit addOutput(tr("Starting: \"%1\" %2")
|
||||||
|
.arg(params->effectiveCommand().toUserOutput(), params->prettyArguments()),
|
||||||
|
OutputFormat::NormalMessage);
|
||||||
|
});
|
||||||
connect(d->m_process.get(), &QtcProcess::done,
|
connect(d->m_process.get(), &QtcProcess::done,
|
||||||
this, &AbstractProcessStep::handleProcessDone);
|
this, &AbstractProcessStep::handleProcessDone);
|
||||||
|
|
||||||
@@ -258,19 +263,29 @@ bool AbstractProcessStep::setupProcessParameters(ProcessParameters *params) cons
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProcessParameters *AbstractProcessStep::displayedParameters() const
|
||||||
|
{
|
||||||
|
return d->m_displayedParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractProcessStep::setDisplayedParameters(ProcessParameters *params)
|
||||||
|
{
|
||||||
|
d->m_displayedParams = params;
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::Private::cleanUp(int exitCode, QProcess::ExitStatus status)
|
void AbstractProcessStep::Private::cleanUp(int exitCode, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
const QString command = m_param.effectiveCommand().toUserOutput();
|
const QString command = q->displayedParameters()->effectiveCommand().toUserOutput();
|
||||||
if (status == QProcess::NormalExit && exitCode == 0) {
|
if (status == QProcess::NormalExit && exitCode == 0) {
|
||||||
emit q->addOutput(tr("The process \"%1\" exited normally.").arg(command),
|
emit q->addOutput(tr("The process \"%1\" exited normally.").arg(command),
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
OutputFormat::NormalMessage);
|
||||||
} else if (status == QProcess::NormalExit) {
|
} else if (status == QProcess::NormalExit) {
|
||||||
emit q->addOutput(tr("The process \"%1\" exited with code %2.")
|
emit q->addOutput(tr("The process \"%1\" exited with code %2.")
|
||||||
.arg(command, QString::number(exitCode)),
|
.arg(command, QString::number(exitCode)),
|
||||||
BuildStep::OutputFormat::ErrorMessage);
|
OutputFormat::ErrorMessage);
|
||||||
} else {
|
} else {
|
||||||
emit q->addOutput(tr("The process \"%1\" crashed.").arg(command),
|
emit q->addOutput(tr("The process \"%1\" crashed.").arg(command),
|
||||||
BuildStep::OutputFormat::ErrorMessage);
|
OutputFormat::ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool success = exitCode == 0 && status == QProcess::NormalExit
|
const bool success = exitCode == 0 && status == QProcess::NormalExit
|
||||||
@@ -281,21 +296,6 @@ void AbstractProcessStep::Private::cleanUp(int exitCode, QProcess::ExitStatus st
|
|||||||
q->finish(success || m_ignoreReturnValue);
|
q->finish(success || m_ignoreReturnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Called after the process is started.
|
|
||||||
|
|
||||||
The default implementation adds a process-started message to the output
|
|
||||||
message.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void AbstractProcessStep::processStarted()
|
|
||||||
{
|
|
||||||
emit addOutput(tr("Starting: \"%1\" %2")
|
|
||||||
.arg(d->m_param.effectiveCommand().toUserOutput(),
|
|
||||||
d->m_param.prettyArguments()),
|
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Called after the process is finished.
|
Called after the process is finished.
|
||||||
|
|
||||||
@@ -315,9 +315,9 @@ void AbstractProcessStep::processFinished(bool success)
|
|||||||
|
|
||||||
void AbstractProcessStep::processStartupFailed()
|
void AbstractProcessStep::processStartupFailed()
|
||||||
{
|
{
|
||||||
|
ProcessParameters *params = displayedParameters();
|
||||||
emit addOutput(tr("Could not start process \"%1\" %2.")
|
emit addOutput(tr("Could not start process \"%1\" %2.")
|
||||||
.arg(d->m_param.effectiveCommand().toUserOutput(),
|
.arg(params->effectiveCommand().toUserOutput(), params->prettyArguments()),
|
||||||
d->m_param.prettyArguments()),
|
|
||||||
OutputFormat::ErrorMessage);
|
OutputFormat::ErrorMessage);
|
||||||
|
|
||||||
QString err = d->m_process ? d->m_process->errorString() : QString();
|
QString err = d->m_process ? d->m_process->errorString() : QString();
|
||||||
@@ -334,7 +334,7 @@ void AbstractProcessStep::processStartupFailed()
|
|||||||
|
|
||||||
void AbstractProcessStep::stdOutput(const QString &output)
|
void AbstractProcessStep::stdOutput(const QString &output)
|
||||||
{
|
{
|
||||||
emit addOutput(output, BuildStep::OutputFormat::Stdout, BuildStep::DontAppendNewline);
|
emit addOutput(output, OutputFormat::Stdout, DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -345,7 +345,7 @@ void AbstractProcessStep::stdOutput(const QString &output)
|
|||||||
|
|
||||||
void AbstractProcessStep::stdError(const QString &output)
|
void AbstractProcessStep::stdError(const QString &output)
|
||||||
{
|
{
|
||||||
emit addOutput(output, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline);
|
emit addOutput(output, OutputFormat::Stderr, DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::finish(bool success)
|
void AbstractProcessStep::finish(bool success)
|
||||||
|
@@ -42,14 +42,15 @@ protected:
|
|||||||
void doRun() override;
|
void doRun() override;
|
||||||
void doCancel() override;
|
void doCancel() override;
|
||||||
void setLowPriority();
|
void setLowPriority();
|
||||||
|
void setDisplayedParameters(ProcessParameters *params);
|
||||||
|
|
||||||
virtual void finish(bool success);
|
virtual void finish(bool success);
|
||||||
virtual void processStarted();
|
|
||||||
virtual void processStartupFailed();
|
virtual void processStartupFailed();
|
||||||
virtual void stdOutput(const QString &output);
|
virtual void stdOutput(const QString &output);
|
||||||
virtual void stdError(const QString &output);
|
virtual void stdError(const QString &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ProcessParameters *displayedParameters() const;
|
||||||
virtual void processFinished(bool success);
|
virtual void processFinished(bool success);
|
||||||
void handleProcessDone();
|
void handleProcessDone();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user