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)
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("<b>Make:</b> %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())

View File

@@ -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;

View File

@@ -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<MakeStep>()) {
cmd.command = makeStep->effectiveMakeCommand();
cmd.command = makeStep->effectiveMakeCommand().executable();
}
}
cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot));

View File

@@ -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());

View File

@@ -449,7 +449,7 @@ void QMakeStep::setSeparateDebugInfo(bool enable)
FilePath QMakeStep::makeCommand() const
{
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

View File

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