Use more Utils::CommandLine in make steps

Change-Id: I72bbc65e0bec19a94418f1cb8bf9ba6fafbbe3bc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-05-29 17:23:42 +02:00
parent 1b4766e26c
commit c7badbd701
6 changed files with 35 additions and 39 deletions

View File

@@ -79,11 +79,11 @@ bool MakeStep::init()
if (!bc) if (!bc)
emit addTask(Task::buildConfigurationMissingTask()); emit addTask(Task::buildConfigurationMissingTask());
const FilePath make = effectiveMakeCommand(); const CommandLine make = effectiveMakeCommand();
if (make.isEmpty()) if (make.executable().isEmpty())
emit addTask(makeCommandMissingTask()); emit addTask(makeCommandMissingTask());
if (!bc || make.isEmpty()) { if (!bc || make.executable().isEmpty()) {
emitFaultyConfigurationMessage(); emitFaultyConfigurationMessage();
return false; return false;
} }
@@ -92,8 +92,7 @@ bool MakeStep::init()
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory()); pp->setWorkingDirectory(bc->buildDirectory());
pp->setEnvironment(environment(bc)); pp->setEnvironment(environment(bc));
pp->setCommand(make); pp->setCommandLine(make);
pp->setArguments(allArguments());
pp->resolveAll(); pp->resolveAll();
// If we are cleaning, then make can fail with an error code, but that doesn't mean // If we are cleaning, then make can fail with an error code, but that doesn't mean
@@ -308,13 +307,6 @@ QStringList MakeStep::jobArguments() const
return {"-j" + QString::number(m_userJobCount)}; return {"-j" + QString::number(m_userJobCount)};
} }
QString MakeStep::allArguments() const
{
QString args = m_makeArguments;
Utils::QtcProcess::addArgs(&args, jobArguments() + m_buildTargets);
return args;
}
QString MakeStep::userArguments() const QString MakeStep::userArguments() const
{ {
return m_makeArguments; return m_makeArguments;
@@ -330,11 +322,15 @@ FilePath MakeStep::makeCommand() const
return m_makeCommand; return m_makeCommand;
} }
FilePath MakeStep::effectiveMakeCommand() const CommandLine MakeStep::effectiveMakeCommand() const
{ {
if (!m_makeCommand.isEmpty()) CommandLine cmd(m_makeCommand.isEmpty() ? defaultMakeCommand() : m_makeCommand);
return m_makeCommand;
return defaultMakeCommand(); cmd.addArgs(m_makeArguments, CommandLine::Raw);
cmd.addArgs(jobArguments());
cmd.addArgs(m_buildTargets);
return cmd;
} }
BuildStepConfigWidget *MakeStep::createConfigWidget() BuildStepConfigWidget *MakeStep::createConfigWidget()
@@ -466,7 +462,8 @@ void MakeStepConfigWidget::updateDetails()
else else
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake))); m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake)));
if (m_makeStep->effectiveMakeCommand().isEmpty()) { const CommandLine make = m_makeStep->effectiveMakeCommand();
if (make.executable().isEmpty()) {
setSummaryText(tr("<b>Make:</b> %1").arg(MakeStep::msgNoMakeCommand())); setSummaryText(tr("<b>Make:</b> %1").arg(MakeStep::msgNoMakeCommand()));
return; return;
} }
@@ -486,8 +483,7 @@ void MakeStepConfigWidget::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory()); param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(m_makeStep->effectiveMakeCommand()); param.setCommandLine(make);
param.setArguments(m_makeStep->allArguments());
param.setEnvironment(m_makeStep->environment(bc)); param.setEnvironment(m_makeStep->environment(bc));
if (param.commandMissing()) if (param.commandMissing())

View File

@@ -55,12 +55,11 @@ public:
bool buildsTarget(const QString &target) const; bool buildsTarget(const QString &target) const;
void setBuildTarget(const QString &target, bool on); void setBuildTarget(const QString &target, bool on);
QStringList availableTargets() const; QStringList availableTargets() const;
QString allArguments() const;
QString userArguments() const; QString userArguments() const;
void setUserArguments(const QString &args); void setUserArguments(const QString &args);
Utils::FilePath makeCommand() const; Utils::FilePath makeCommand() const;
void setMakeCommand(const Utils::FilePath &command); void setMakeCommand(const Utils::FilePath &command);
Utils::FilePath effectiveMakeCommand() const; Utils::CommandLine effectiveMakeCommand() const;
void setClean(bool clean); void setClean(bool clean);
bool isClean() const; bool isClean() const;

View File

@@ -861,7 +861,7 @@ MakeInstallCommand Project::makeInstallCommand(const Target *target, const QStri
if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) { if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) {
if (const auto makeStep = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD) if (const auto makeStep = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)
->firstOfType<MakeStep>()) { ->firstOfType<MakeStep>()) {
cmd.command = makeStep->effectiveMakeCommand(); cmd.command = makeStep->effectiveMakeCommand().executable();
} }
} }
cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot)); cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot));

View File

@@ -70,11 +70,12 @@ bool QmakeMakeStep::init()
if (!bc) if (!bc)
emit addTask(Task::buildConfigurationMissingTask()); emit addTask(Task::buildConfigurationMissingTask());
Utils::FilePath make = effectiveMakeCommand(); const Utils::CommandLine unmodifiedMake = effectiveMakeCommand();
if (make.isEmpty()) const Utils::FileName makeExecutable = unmodifiedMake.executable();
if (makeExecutable.isEmpty())
emit addTask(makeCommandMissingTask()); emit addTask(makeCommandMissingTask());
if (!bc || make.isEmpty()) { if (!bc || makeExecutable.isEmpty()) {
emitFaultyConfigurationMessage(); emitFaultyConfigurationMessage();
return false; return false;
} }
@@ -93,14 +94,12 @@ bool QmakeMakeStep::init()
workingDirectory = bc->buildDirectory().toString(); workingDirectory = bc->buildDirectory().toString();
pp->setWorkingDirectory(Utils::FilePath::fromString(workingDirectory)); pp->setWorkingDirectory(Utils::FilePath::fromString(workingDirectory));
pp->setCommand(make);
// If we are cleaning, then make can fail with a error code, but that doesn't mean // If we are cleaning, then make can fail with a error code, but that doesn't mean
// we should stop the clean queue // we should stop the clean queue
// That is mostly so that rebuild works on a already clean project // That is mostly so that rebuild works on a already clean project
setIgnoreReturnValue(isClean()); setIgnoreReturnValue(isClean());
QString args; Utils::CommandLine makeCmd(makeExecutable);
QmakeProjectManager::QmakeProFileNode *subProFile = bc->subNodeBuild(); QmakeProjectManager::QmakeProFileNode *subProFile = bc->subNodeBuild();
if (subProFile) { if (subProFile) {
@@ -116,22 +115,22 @@ bool QmakeMakeStep::init()
else else
makefile += ".Release"; makefile += ".Release";
} }
if (makefile != "Makefile") {
Utils::QtcProcess::addArg(&args, "-f"); if (makefile != "Makefile")
Utils::QtcProcess::addArg(&args, makefile); makeCmd.addArgs({"-f", makefile});
}
m_makeFileToCheck = QDir(workingDirectory).filePath(makefile); m_makeFileToCheck = QDir(workingDirectory).filePath(makefile);
} else { } else {
if (!bc->makefile().isEmpty()) { if (!bc->makefile().isEmpty()) {
Utils::QtcProcess::addArg(&args, "-f"); makeCmd.addArgs({"-f", bc->makefile()});
Utils::QtcProcess::addArg(&args, bc->makefile());
m_makeFileToCheck = QDir(workingDirectory).filePath(bc->makefile()); m_makeFileToCheck = QDir(workingDirectory).filePath(bc->makefile());
} else { } else {
m_makeFileToCheck = QDir(workingDirectory).filePath("Makefile"); m_makeFileToCheck = QDir(workingDirectory).filePath("Makefile");
} }
} }
Utils::QtcProcess::addArgs(&args, allArguments()); makeCmd.addArgs(unmodifiedMake.arguments(), Utils::CommandLine::Raw);
if (bc->fileNodeBuild() && subProFile) { if (bc->fileNodeBuild() && subProFile) {
QString objectsDir = subProFile->objectsDirectory(); QString objectsDir = subProFile->objectsDirectory();
if (objectsDir.isEmpty()) { if (objectsDir.isEmpty()) {
@@ -152,10 +151,11 @@ bool QmakeMakeStep::init()
QString objectFile = relObjectsDir + QString objectFile = relObjectsDir +
bc->fileNodeBuild()->filePath().toFileInfo().baseName() + bc->fileNodeBuild()->filePath().toFileInfo().baseName() +
subProFile->objectExtension(); subProFile->objectExtension();
Utils::QtcProcess::addArg(&args, objectFile); makeCmd.addArg(objectFile);
} }
pp->setEnvironment(environment(bc)); pp->setEnvironment(environment(bc));
pp->setArguments(args); pp->setCommandLine(makeCmd);
pp->resolveAll(); pp->resolveAll();
setOutputParser(new ProjectExplorer::GnuMakeParser()); setOutputParser(new ProjectExplorer::GnuMakeParser());

View File

@@ -449,7 +449,7 @@ void QMakeStep::setSeparateDebugInfo(bool enable)
FilePath QMakeStep::makeCommand() const FilePath QMakeStep::makeCommand() const
{ {
auto ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>(); auto ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>();
return ms ? ms->effectiveMakeCommand() : FilePath(); return ms ? ms->effectiveMakeCommand().executable() : FilePath();
} }
QString QMakeStep::makeArguments(const QString &makefile) const QString QMakeStep::makeArguments(const QString &makefile) const

View File

@@ -207,9 +207,10 @@ void MakeInstallStep::updateArgsFromAspect()
void MakeInstallStep::updateFullCommandLine() void MakeInstallStep::updateFullCommandLine()
{ {
// FIXME: Only executable?
static_cast<BaseStringAspect *>(aspect(FullCommandLineAspectId))->setValue( static_cast<BaseStringAspect *>(aspect(FullCommandLineAspectId))->setValue(
QDir::toNativeSeparators( QDir::toNativeSeparators(
QtcProcess::quoteArg(effectiveMakeCommand().toString())) QtcProcess::quoteArg(effectiveMakeCommand().executable().toString()))
+ ' ' + userArguments()); + ' ' + userArguments());
} }