From c7badbd701e7ad9a93695a1b943184b0102e1cca Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 29 May 2019 17:23:42 +0200 Subject: [PATCH] Use more Utils::CommandLine in make steps Change-Id: I72bbc65e0bec19a94418f1cb8bf9ba6fafbbe3bc Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/makestep.cpp | 34 ++++++++----------- src/plugins/projectexplorer/makestep.h | 3 +- src/plugins/projectexplorer/project.cpp | 2 +- .../qmakeprojectmanager/qmakemakestep.cpp | 30 ++++++++-------- src/plugins/qmakeprojectmanager/qmakestep.cpp | 2 +- src/plugins/remotelinux/makeinstallstep.cpp | 3 +- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index fecaacc89c6..405498a85f5 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -79,11 +79,11 @@ bool MakeStep::init() if (!bc) emit addTask(Task::buildConfigurationMissingTask()); - const FilePath make = effectiveMakeCommand(); - if (make.isEmpty()) + const CommandLine make = effectiveMakeCommand(); + if (make.executable().isEmpty()) emit addTask(makeCommandMissingTask()); - if (!bc || make.isEmpty()) { + if (!bc || make.executable().isEmpty()) { emitFaultyConfigurationMessage(); return false; } @@ -92,8 +92,7 @@ bool MakeStep::init() pp->setMacroExpander(bc->macroExpander()); pp->setWorkingDirectory(bc->buildDirectory()); pp->setEnvironment(environment(bc)); - pp->setCommand(make); - pp->setArguments(allArguments()); + pp->setCommandLine(make); pp->resolveAll(); // 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)}; } -QString MakeStep::allArguments() const -{ - QString args = m_makeArguments; - Utils::QtcProcess::addArgs(&args, jobArguments() + m_buildTargets); - return args; -} - QString MakeStep::userArguments() const { return m_makeArguments; @@ -330,11 +322,15 @@ FilePath MakeStep::makeCommand() const return m_makeCommand; } -FilePath MakeStep::effectiveMakeCommand() const +CommandLine MakeStep::effectiveMakeCommand() const { - if (!m_makeCommand.isEmpty()) - return m_makeCommand; - return defaultMakeCommand(); + CommandLine cmd(m_makeCommand.isEmpty() ? defaultMakeCommand() : m_makeCommand); + + cmd.addArgs(m_makeArguments, CommandLine::Raw); + cmd.addArgs(jobArguments()); + cmd.addArgs(m_buildTargets); + + return cmd; } BuildStepConfigWidget *MakeStep::createConfigWidget() @@ -466,7 +462,8 @@ void MakeStepConfigWidget::updateDetails() else 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("Make: %1").arg(MakeStep::msgNoMakeCommand())); return; } @@ -486,8 +483,7 @@ void MakeStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setWorkingDirectory(bc->buildDirectory()); - param.setCommand(m_makeStep->effectiveMakeCommand()); - param.setArguments(m_makeStep->allArguments()); + param.setCommandLine(make); param.setEnvironment(m_makeStep->environment(bc)); if (param.commandMissing()) diff --git a/src/plugins/projectexplorer/makestep.h b/src/plugins/projectexplorer/makestep.h index e44b52851e0..8cfb998f936 100644 --- a/src/plugins/projectexplorer/makestep.h +++ b/src/plugins/projectexplorer/makestep.h @@ -55,12 +55,11 @@ public: bool buildsTarget(const QString &target) const; void setBuildTarget(const QString &target, bool on); QStringList availableTargets() const; - QString allArguments() const; QString userArguments() const; void setUserArguments(const QString &args); Utils::FilePath makeCommand() const; void setMakeCommand(const Utils::FilePath &command); - Utils::FilePath effectiveMakeCommand() const; + Utils::CommandLine effectiveMakeCommand() const; void setClean(bool clean); bool isClean() const; diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 026cb381ba5..420d6dad32b 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -861,7 +861,7 @@ MakeInstallCommand Project::makeInstallCommand(const Target *target, const QStri if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) { if (const auto makeStep = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD) ->firstOfType()) { - cmd.command = makeStep->effectiveMakeCommand(); + cmd.command = makeStep->effectiveMakeCommand().executable(); } } cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot)); diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index 3b4642a6df0..6c64dc867b6 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -70,11 +70,12 @@ bool QmakeMakeStep::init() if (!bc) emit addTask(Task::buildConfigurationMissingTask()); - Utils::FilePath make = effectiveMakeCommand(); - if (make.isEmpty()) + const Utils::CommandLine unmodifiedMake = effectiveMakeCommand(); + const Utils::FileName makeExecutable = unmodifiedMake.executable(); + if (makeExecutable.isEmpty()) emit addTask(makeCommandMissingTask()); - if (!bc || make.isEmpty()) { + if (!bc || makeExecutable.isEmpty()) { emitFaultyConfigurationMessage(); return false; } @@ -93,14 +94,12 @@ bool QmakeMakeStep::init() workingDirectory = bc->buildDirectory().toString(); 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 // we should stop the clean queue // That is mostly so that rebuild works on a already clean project setIgnoreReturnValue(isClean()); - QString args; + Utils::CommandLine makeCmd(makeExecutable); QmakeProjectManager::QmakeProFileNode *subProFile = bc->subNodeBuild(); if (subProFile) { @@ -116,22 +115,22 @@ bool QmakeMakeStep::init() else makefile += ".Release"; } - if (makefile != "Makefile") { - Utils::QtcProcess::addArg(&args, "-f"); - Utils::QtcProcess::addArg(&args, makefile); - } + + if (makefile != "Makefile") + makeCmd.addArgs({"-f", makefile}); + m_makeFileToCheck = QDir(workingDirectory).filePath(makefile); } else { if (!bc->makefile().isEmpty()) { - Utils::QtcProcess::addArg(&args, "-f"); - Utils::QtcProcess::addArg(&args, bc->makefile()); + makeCmd.addArgs({"-f", bc->makefile()}); m_makeFileToCheck = QDir(workingDirectory).filePath(bc->makefile()); } else { m_makeFileToCheck = QDir(workingDirectory).filePath("Makefile"); } } - Utils::QtcProcess::addArgs(&args, allArguments()); + makeCmd.addArgs(unmodifiedMake.arguments(), Utils::CommandLine::Raw); + if (bc->fileNodeBuild() && subProFile) { QString objectsDir = subProFile->objectsDirectory(); if (objectsDir.isEmpty()) { @@ -152,10 +151,11 @@ bool QmakeMakeStep::init() QString objectFile = relObjectsDir + bc->fileNodeBuild()->filePath().toFileInfo().baseName() + subProFile->objectExtension(); - Utils::QtcProcess::addArg(&args, objectFile); + makeCmd.addArg(objectFile); } + pp->setEnvironment(environment(bc)); - pp->setArguments(args); + pp->setCommandLine(makeCmd); pp->resolveAll(); setOutputParser(new ProjectExplorer::GnuMakeParser()); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index 31e14588345..92d10cd323c 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -449,7 +449,7 @@ void QMakeStep::setSeparateDebugInfo(bool enable) FilePath QMakeStep::makeCommand() const { auto ms = qobject_cast(parent())->firstOfType(); - return ms ? ms->effectiveMakeCommand() : FilePath(); + return ms ? ms->effectiveMakeCommand().executable() : FilePath(); } QString QMakeStep::makeArguments(const QString &makefile) const diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 0b1fa704add..ae3d0231796 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -207,9 +207,10 @@ void MakeInstallStep::updateArgsFromAspect() void MakeInstallStep::updateFullCommandLine() { + // FIXME: Only executable? static_cast(aspect(FullCommandLineAspectId))->setValue( QDir::toNativeSeparators( - QtcProcess::quoteArg(effectiveMakeCommand().toString())) + QtcProcess::quoteArg(effectiveMakeCommand().executable().toString())) + ' ' + userArguments()); }