ProjectExplorer: Use Utils::FileName in ProcessParameters

For the command and the working directory.

Change-Id: Ia69dc7100aeb57bb6e1b35f4dd4f3cf3763d8cda
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-05-15 13:59:43 +02:00
parent d1f9e466da
commit 9433b8a7e7
29 changed files with 129 additions and 101 deletions

View File

@@ -690,6 +690,11 @@ QString Environment::expandVariables(const QString &input) const
return result; return result;
} }
FileName Environment::expandVariables(const FileName &variables) const
{
return FileName::fromString(expandVariables(variables.toString()));
}
QStringList Environment::expandVariables(const QStringList &variables) const QStringList Environment::expandVariables(const QStringList &variables) const
{ {
return Utils::transform(variables, [this](const QString &i) { return expandVariables(i); }); return Utils::transform(variables, [this](const QString &i) { return expandVariables(i); });

View File

@@ -135,6 +135,7 @@ public:
bool isSameExecutable(const QString &exe1, const QString &exe2) const; bool isSameExecutable(const QString &exe1, const QString &exe2) const;
QString expandVariables(const QString &input) const; QString expandVariables(const QString &input) const;
FileName expandVariables(const FileName &input) const;
QStringList expandVariables(const QStringList &input) const; QStringList expandVariables(const QStringList &input) const;
bool operator!=(const Environment &other) const; bool operator!=(const Environment &other) const;

View File

@@ -290,6 +290,11 @@ QString MacroExpander::expand(const QString &stringWithVariables) const
return res; return res;
} }
FileName MacroExpander::expand(const FileName &fileNameWithVariables) const
{
return FileName::fromString(expand(fileNameWithVariables.toString()));
}
QByteArray MacroExpander::expand(const QByteArray &stringWithVariables) const QByteArray MacroExpander::expand(const QByteArray &stringWithVariables) const
{ {
return expand(QString::fromLatin1(stringWithVariables)).toLatin1(); return expand(QString::fromLatin1(stringWithVariables)).toLatin1();

View File

@@ -37,6 +37,7 @@ namespace Utils {
namespace Internal { class MacroExpanderPrivate; } namespace Internal { class MacroExpanderPrivate; }
class FileName;
class MacroExpander; class MacroExpander;
using MacroExpanderProvider = std::function<MacroExpander *()>; using MacroExpanderProvider = std::function<MacroExpander *()>;
using MacroExpanderProviders = QVector<MacroExpanderProvider>; using MacroExpanderProviders = QVector<MacroExpanderProvider>;
@@ -55,6 +56,7 @@ public:
QString value(const QByteArray &variable, bool *found = nullptr) const; QString value(const QByteArray &variable, bool *found = nullptr) const;
QString expand(const QString &stringWithVariables) const; QString expand(const QString &stringWithVariables) const;
FileName expand(const FileName &fileNameWithVariables) const;
QByteArray expand(const QByteArray &stringWithVariables) const; QByteArray expand(const QByteArray &stringWithVariables) const;
QVariant expandVariant(const QVariant &v) const; QVariant expandVariant(const QVariant &v) const;

View File

@@ -70,6 +70,7 @@
#include <memory> #include <memory>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
using namespace Android::Internal; using namespace Android::Internal;
namespace { namespace {
@@ -90,10 +91,10 @@ static void setupProcessParameters(ProcessParameters *pp,
const QString &command) const QString &command)
{ {
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
Utils::Environment env = bc->environment(); Utils::Environment env = bc->environment();
pp->setEnvironment(env); pp->setEnvironment(env);
pp->setCommand(command); pp->setCommand(FileName::fromString(command));
pp->setArguments(Utils::QtcProcess::joinArgs(arguments)); pp->setArguments(Utils::QtcProcess::joinArgs(arguments));
pp->resolveAll(); pp->resolveAll();
} }
@@ -279,7 +280,7 @@ bool AndroidBuildApkStep::init()
// Generate arguments with keystore password concealed // Generate arguments with keystore password concealed
ProjectExplorer::ProcessParameters pp2; ProjectExplorer::ProcessParameters pp2;
setupProcessParameters(&pp2, bc, argumentsPasswordConcealed, command); setupProcessParameters(&pp2, bc, argumentsPasswordConcealed, command);
m_command = pp2.effectiveCommand(); m_command = pp2.effectiveCommand().toString();
m_argumentsPasswordConcealed = pp2.prettyArguments(); m_argumentsPasswordConcealed = pp2.prettyArguments();
return true; return true;

View File

@@ -72,8 +72,8 @@ bool AndroidPackageInstallationStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
pp->setCommand(tc->makeCommand(bc->environment()).toString()); pp->setCommand(tc->makeCommand(bc->environment()));
Environment env = bc->environment(); Environment env = bc->environment();
Environment::setupEnglishOutput(&env); Environment::setupEnglishOutput(&env);
pp->setEnvironment(env); pp->setEnvironment(env);

View File

@@ -77,9 +77,8 @@ bool AutogenStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment()); pp->setEnvironment(bc->environment());
const QString projectDir(bc->target()->project()->projectDirectory().toString()); pp->setWorkingDirectory(bc->target()->project()->projectDirectory());
pp->setWorkingDirectory(projectDir); pp->setCommand(Utils::FileName::fromString("./autogen.sh"));
pp->setCommand("./autogen.sh");
pp->setArguments(m_additionalArgumentsAspect->value()); pp->setArguments(m_additionalArgumentsAspect->value());
pp->resolveAll(); pp->resolveAll();
@@ -122,9 +121,8 @@ BuildStepConfigWidget *AutogenStep::createConfigWidget()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
const QString projectDir(bc->target()->project()->projectDirectory().toString()); param.setWorkingDirectory(bc->target()->project()->projectDirectory());
param.setWorkingDirectory(projectDir); param.setCommand(Utils::FileName::fromString("./autogen.sh"));
param.setCommand("./autogen.sh");
param.setArguments(m_additionalArgumentsAspect->value()); param.setArguments(m_additionalArgumentsAspect->value());
widget->setSummaryText(param.summary(displayName())); widget->setSummaryText(param.summary(displayName()));

View File

@@ -75,9 +75,8 @@ bool AutoreconfStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment()); pp->setEnvironment(bc->environment());
const QString projectDir(bc->target()->project()->projectDirectory().toString()); pp->setWorkingDirectory(bc->target()->project()->projectDirectory());
pp->setWorkingDirectory(projectDir); pp->setCommand(Utils::FileName::fromString("autoreconf"));
pp->setCommand("autoreconf");
pp->setArguments(m_additionalArgumentsAspect->value()); pp->setArguments(m_additionalArgumentsAspect->value());
pp->resolveAll(); pp->resolveAll();
@@ -114,9 +113,8 @@ BuildStepConfigWidget *AutoreconfStep::createConfigWidget()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
const QString projectDir(bc->target()->project()->projectDirectory().toString()); param.setWorkingDirectory(bc->target()->project()->projectDirectory());
param.setWorkingDirectory(projectDir); param.setCommand(Utils::FileName::fromString("autoreconf"));
param.setCommand("autoreconf");
param.setArguments(m_additionalArgumentsAspect->value()); param.setArguments(m_additionalArgumentsAspect->value());
widget->setSummaryText(param.summary(displayName())); widget->setSummaryText(param.summary(displayName()));

View File

@@ -97,8 +97,8 @@ bool ConfigureStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment()); pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
pp->setCommand(projectDirRelativeToBuildDir(bc) + "configure"); pp->setCommand(Utils::FileName::fromString(projectDirRelativeToBuildDir(bc) + "configure"));
pp->setArguments(m_additionalArgumentsAspect->value()); pp->setArguments(m_additionalArgumentsAspect->value());
pp->resolveAll(); pp->resolveAll();
@@ -158,8 +158,8 @@ void ConfigureStep::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString()); param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(projectDirRelativeToBuildDir(bc) + "configure"); param.setCommand(Utils::FileName::fromString(projectDirRelativeToBuildDir(bc) + "configure"));
param.setArguments(m_additionalArgumentsAspect->value()); param.setArguments(m_additionalArgumentsAspect->value());
m_widget->setSummaryText(param.summaryInWorkdir(displayName())); m_widget->setSummaryText(param.summaryInWorkdir(displayName()));

View File

@@ -218,7 +218,7 @@ bool CMakeBuildStep::init()
if (!env.value("NINJA_STATUS").startsWith(m_ninjaProgressString)) if (!env.value("NINJA_STATUS").startsWith(m_ninjaProgressString))
env.set("NINJA_STATUS", m_ninjaProgressString + "%o/sec] "); env.set("NINJA_STATUS", m_ninjaProgressString + "%o/sec] ");
pp->setEnvironment(env); pp->setEnvironment(env);
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
pp->setCommand(cmakeCommand()); pp->setCommand(cmakeCommand());
pp->setArguments(arguments); pp->setArguments(arguments);
pp->resolveAll(); pp->resolveAll();
@@ -373,10 +373,10 @@ QString CMakeBuildStep::allArguments(const CMakeRunConfiguration *rc) const
return arguments; return arguments;
} }
QString CMakeBuildStep::cmakeCommand() const Utils::FileName CMakeBuildStep::cmakeCommand() const
{ {
CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit()); CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit());
return tool ? tool->cmakeExecutable().toString() : QString(); return tool ? tool->cmakeExecutable() : Utils::FileName();
} }
QString CMakeBuildStep::cleanTarget() QString CMakeBuildStep::cleanTarget()
@@ -531,7 +531,7 @@ void CMakeBuildStepConfigWidget::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString()); param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(m_buildStep->cmakeCommand()); param.setCommand(m_buildStep->cmakeCommand());
param.setArguments(m_buildStep->allArguments(nullptr)); param.setArguments(m_buildStep->allArguments(nullptr));

View File

@@ -66,7 +66,7 @@ public:
QString allArguments(const CMakeRunConfiguration *rc) const; QString allArguments(const CMakeRunConfiguration *rc) const;
QString cmakeCommand() const; Utils::FileName cmakeCommand() const;
QVariantMap toMap() const override; QVariantMap toMap() const override;

View File

@@ -635,7 +635,7 @@ MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) { if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) {
if (const auto cmakeStep = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD) if (const auto cmakeStep = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)
->firstOfType<CMakeBuildStep>()) { ->firstOfType<CMakeBuildStep>()) {
cmd.command = FileName::fromString(cmakeStep->cmakeCommand()); cmd.command = cmakeStep->cmakeCommand();
} }
} }
cmd.arguments << "--build" << "." << "--target" << "install"; cmd.arguments << "--build" << "." << "--target" << "install";

View File

@@ -87,11 +87,11 @@ bool IosBuildStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
Utils::Environment env = bc->environment(); Utils::Environment env = bc->environment();
Utils::Environment::setupEnglishOutput(&env); Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env); pp->setEnvironment(env);
pp->setCommand(buildCommand()); pp->setCommand(Utils::FileName::fromString(buildCommand()));
pp->setArguments(Utils::QtcProcess::joinArgs(allArguments())); pp->setArguments(Utils::QtcProcess::joinArgs(allArguments()));
pp->resolveAll(); pp->resolveAll();
@@ -251,9 +251,9 @@ void IosBuildStepConfigWidget::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory().toString()); param.setWorkingDirectory(bc->buildDirectory());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
param.setCommand(m_buildStep->buildCommand()); param.setCommand(Utils::FileName::fromString(m_buildStep->buildCommand()));
param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->allArguments())); param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->allArguments()));
setSummaryText(param.summary(displayName())); setSummaryText(param.summary(displayName()));

View File

@@ -68,11 +68,11 @@ bool IosDsymBuildStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
Utils::Environment env = bc->environment(); Utils::Environment env = bc->environment();
Utils::Environment::setupEnglishOutput(&env); Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env); pp->setEnvironment(env);
pp->setCommand(command()); pp->setCommand(Utils::FileName::fromString(command()));
pp->setArguments(Utils::QtcProcess::joinArgs(arguments())); pp->setArguments(Utils::QtcProcess::joinArgs(arguments()));
pp->resolveAll(); pp->resolveAll();
@@ -268,9 +268,9 @@ void IosDsymBuildStepConfigWidget::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory().toString()); param.setWorkingDirectory(bc->buildDirectory());
param.setEnvironment(bc->environment()); param.setEnvironment(bc->environment());
param.setCommand(m_buildStep->command()); param.setCommand(Utils::FileName::fromString(m_buildStep->command()));
param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->arguments())); param.setArguments(Utils::QtcProcess::joinArgs(m_buildStep->arguments()));
setSummaryText(param.summary(displayName())); setSummaryText(param.summary(displayName()));

View File

@@ -228,14 +228,14 @@ void NimCompilerBuildStep::updateCommand()
Kit *kit = target()->kit(); Kit *kit = target()->kit();
auto tc = dynamic_cast<NimToolChain*>(ToolChainKitAspect::toolChain(kit, Constants::C_NIMLANGUAGE_ID)); auto tc = dynamic_cast<NimToolChain*>(ToolChainKitAspect::toolChain(kit, Constants::C_NIMLANGUAGE_ID));
QTC_ASSERT(tc, return); QTC_ASSERT(tc, return);
processParameters()->setCommand(tc->compilerCommand().toString()); processParameters()->setCommand(tc->compilerCommand());
} }
void NimCompilerBuildStep::updateWorkingDirectory() void NimCompilerBuildStep::updateWorkingDirectory()
{ {
auto bc = qobject_cast<NimBuildConfiguration *>(buildConfiguration()); auto bc = qobject_cast<NimBuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return); QTC_ASSERT(bc, return);
processParameters()->setWorkingDirectory(bc->buildDirectory().toString()); processParameters()->setWorkingDirectory(bc->buildDirectory());
} }
void NimCompilerBuildStep::updateArguments() void NimCompilerBuildStep::updateArguments()

View File

@@ -104,7 +104,7 @@ void NimCompilerBuildStepConfigWidget::updateCommandLineText()
ProcessParameters *parameters = m_buildStep->processParameters(); ProcessParameters *parameters = m_buildStep->processParameters();
QStringList command; QStringList command;
command << parameters->command(); command << parameters->command().toString();
command << parameters->arguments(); command << parameters->arguments();
// Remove empty args // Remove empty args

View File

@@ -200,7 +200,7 @@ bool AbstractProcessStep::init()
void AbstractProcessStep::doRun() void AbstractProcessStep::doRun()
{ {
QDir wd(d->m_param.effectiveWorkingDirectory()); QDir wd(d->m_param.effectiveWorkingDirectory().toString());
if (!wd.exists()) { if (!wd.exists()) {
if (!wd.mkpath(wd.absolutePath())) { if (!wd.mkpath(wd.absolutePath())) {
emit addOutput(tr("Could not create directory \"%1\"") emit addOutput(tr("Could not create directory \"%1\"")
@@ -211,7 +211,7 @@ void AbstractProcessStep::doRun()
} }
} }
QString effectiveCommand = d->m_param.effectiveCommand(); QString effectiveCommand = d->m_param.effectiveCommand().toString();
if (!QFileInfo::exists(effectiveCommand)) { if (!QFileInfo::exists(effectiveCommand)) {
processStartupFailed(); processStartupFailed();
finish(false); finish(false);
@@ -275,7 +275,7 @@ void AbstractProcessStep::cleanUp(QProcess *process)
void AbstractProcessStep::processStarted() void AbstractProcessStep::processStarted()
{ {
emit addOutput(tr("Starting: \"%1\" %2") emit addOutput(tr("Starting: \"%1\" %2")
.arg(QDir::toNativeSeparators(d->m_param.effectiveCommand()), .arg(QDir::toNativeSeparators(d->m_param.effectiveCommand().toString()),
d->m_param.prettyArguments()), d->m_param.prettyArguments()),
BuildStep::OutputFormat::NormalMessage); BuildStep::OutputFormat::NormalMessage);
} }
@@ -291,7 +291,7 @@ void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus sta
if (d->m_outputParserChain) if (d->m_outputParserChain)
d->m_outputParserChain->flush(); d->m_outputParserChain->flush();
QString command = QDir::toNativeSeparators(d->m_param.effectiveCommand()); QString command = QDir::toNativeSeparators(d->m_param.effectiveCommand().toString());
if (status == QProcess::NormalExit && exitCode == 0) { if (status == QProcess::NormalExit && exitCode == 0) {
emit addOutput(tr("The process \"%1\" exited normally.").arg(command), emit addOutput(tr("The process \"%1\" exited normally.").arg(command),
BuildStep::OutputFormat::NormalMessage); BuildStep::OutputFormat::NormalMessage);
@@ -313,7 +313,7 @@ void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus sta
void AbstractProcessStep::processStartupFailed() void AbstractProcessStep::processStartupFailed()
{ {
emit addOutput(tr("Could not start process \"%1\" %2") emit addOutput(tr("Could not start process \"%1\" %2")
.arg(QDir::toNativeSeparators(d->m_param.effectiveCommand()), .arg(QDir::toNativeSeparators(d->m_param.effectiveCommand().toString()),
d->m_param.prettyArguments()), d->m_param.prettyArguments()),
BuildStep::OutputFormat::ErrorMessage); BuildStep::OutputFormat::ErrorMessage);
} }

View File

@@ -207,6 +207,11 @@ void IOutputParser::setWorkingDirectory(const QString &workingDirectory)
m_parser->setWorkingDirectory(workingDirectory); m_parser->setWorkingDirectory(workingDirectory);
} }
void IOutputParser::setWorkingDirectory(const Utils::FileName &fn)
{
setWorkingDirectory(fn.toString());
}
void IOutputParser::flush() void IOutputParser::flush()
{ {
doFlush(); doFlush();

View File

@@ -53,6 +53,7 @@ public:
virtual bool hasFatalErrors() const; virtual bool hasFatalErrors() const;
virtual void setWorkingDirectory(const QString &workingDirectory); virtual void setWorkingDirectory(const QString &workingDirectory);
void setWorkingDirectory(const Utils::FileName &fn);
void flush(); // flush out pending tasks void flush(); // flush out pending tasks

View File

@@ -79,7 +79,7 @@ bool MakeStep::init()
if (!bc) if (!bc)
emit addTask(Task::buildConfigurationMissingTask()); emit addTask(Task::buildConfigurationMissingTask());
const QString make = effectiveMakeCommand(); const FileName make = effectiveMakeCommand();
if (make.isEmpty()) if (make.isEmpty())
emit addTask(makeCommandMissingTask()); emit addTask(makeCommandMissingTask());
@@ -90,7 +90,7 @@ bool MakeStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setWorkingDirectory(bc->buildDirectory());
pp->setEnvironment(environment(bc)); pp->setEnvironment(environment(bc));
pp->setCommand(make); pp->setCommand(make);
pp->setArguments(allArguments()); pp->setArguments(allArguments());
@@ -105,7 +105,7 @@ bool MakeStep::init()
IOutputParser *parser = target()->kit()->createOutputParser(); IOutputParser *parser = target()->kit()->createOutputParser();
if (parser) if (parser)
appendOutputParser(parser); appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory().toString());
return AbstractProcessStep::init(); return AbstractProcessStep::init();
} }
@@ -143,18 +143,18 @@ static const QList<ToolChain *> preferredToolChains(const Kit *kit)
return tcs; return tcs;
} }
QString MakeStep::defaultMakeCommand() const FileName MakeStep::defaultMakeCommand() const
{ {
BuildConfiguration *bc = buildConfiguration(); BuildConfiguration *bc = buildConfiguration();
if (!bc) if (!bc)
return QString(); return {};
const Utils::Environment env = environment(bc); const Utils::Environment env = environment(bc);
for (const ToolChain *tc : preferredToolChains(target()->kit())) { for (const ToolChain *tc : preferredToolChains(target()->kit())) {
FileName make = tc->makeCommand(env); FileName make = tc->makeCommand(env);
if (!make.isEmpty()) if (!make.isEmpty())
return make.toString(); return make;
} }
return QString(); return {};
} }
QString MakeStep::msgNoMakeCommand() QString MakeStep::msgNoMakeCommand()
@@ -260,7 +260,7 @@ Utils::Environment MakeStep::environment(BuildConfiguration *bc) const
return env; return env;
} }
void MakeStep::setMakeCommand(const QString &command) void MakeStep::setMakeCommand(const FileName &command)
{ {
m_makeCommand = command; m_makeCommand = command;
} }
@@ -271,7 +271,7 @@ QVariantMap MakeStep::toMap() const
map.insert(id().withSuffix(BUILD_TARGETS_SUFFIX).toString(), m_buildTargets); map.insert(id().withSuffix(BUILD_TARGETS_SUFFIX).toString(), m_buildTargets);
map.insert(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString(), m_makeArguments); map.insert(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString(), m_makeArguments);
map.insert(id().withSuffix(MAKE_COMMAND_SUFFIX).toString(), m_makeCommand); map.insert(id().withSuffix(MAKE_COMMAND_SUFFIX).toString(), m_makeCommand.toString());
map.insert(id().withSuffix(CLEAN_SUFFIX).toString(), m_clean); map.insert(id().withSuffix(CLEAN_SUFFIX).toString(), m_clean);
const QString jobCountKey = id().withSuffix(JOBCOUNT_SUFFIX).toString(); const QString jobCountKey = id().withSuffix(JOBCOUNT_SUFFIX).toString();
if (m_userJobCount != defaultJobCount()) if (m_userJobCount != defaultJobCount())
@@ -286,7 +286,8 @@ bool MakeStep::fromMap(const QVariantMap &map)
{ {
m_buildTargets = map.value(id().withSuffix(BUILD_TARGETS_SUFFIX).toString()).toStringList(); m_buildTargets = map.value(id().withSuffix(BUILD_TARGETS_SUFFIX).toString()).toStringList();
m_makeArguments = map.value(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString()).toString(); m_makeArguments = map.value(id().withSuffix(MAKE_ARGUMENTS_SUFFIX).toString()).toString();
m_makeCommand = map.value(id().withSuffix(MAKE_COMMAND_SUFFIX).toString()).toString(); m_makeCommand = FileName::fromString(
map.value(id().withSuffix(MAKE_COMMAND_SUFFIX).toString()).toString());
m_clean = map.value(id().withSuffix(CLEAN_SUFFIX).toString()).toBool(); m_clean = map.value(id().withSuffix(CLEAN_SUFFIX).toString()).toBool();
m_overrideMakeflags = map.value(id().withSuffix(OVERRIDE_MAKEFLAGS_SUFFIX).toString(), false).toBool(); m_overrideMakeflags = map.value(id().withSuffix(OVERRIDE_MAKEFLAGS_SUFFIX).toString(), false).toBool();
m_userJobCount = map.value(id().withSuffix(JOBCOUNT_SUFFIX).toString(), defaultJobCount()).toInt(); m_userJobCount = map.value(id().withSuffix(JOBCOUNT_SUFFIX).toString(), defaultJobCount()).toInt();
@@ -324,12 +325,12 @@ void MakeStep::setUserArguments(const QString &args)
m_makeArguments = args; m_makeArguments = args;
} }
QString MakeStep::makeCommand() const FileName MakeStep::makeCommand() const
{ {
return m_makeCommand; return m_makeCommand;
} }
QString MakeStep::effectiveMakeCommand() const FileName MakeStep::effectiveMakeCommand() const
{ {
if (!m_makeCommand.isEmpty()) if (!m_makeCommand.isEmpty())
return m_makeCommand; return m_makeCommand;
@@ -386,7 +387,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
m_ui->makeLineEdit->setExpectedKind(Utils::PathChooser::ExistingCommand); m_ui->makeLineEdit->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui->makeLineEdit->setBaseDirectory(Utils::PathChooser::homePath()); m_ui->makeLineEdit->setBaseDirectory(Utils::PathChooser::homePath());
m_ui->makeLineEdit->setHistoryCompleter("PE.MakeCommand.History"); m_ui->makeLineEdit->setHistoryCompleter("PE.MakeCommand.History");
m_ui->makeLineEdit->setPath(m_makeStep->makeCommand()); m_ui->makeLineEdit->setPath(m_makeStep->makeCommand().toString());
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments()); m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
m_ui->nonOverrideWarning->setToolTip("<html><body><p>" + m_ui->nonOverrideWarning->setToolTip("<html><body><p>" +
tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.") tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.")
@@ -459,7 +460,7 @@ void MakeStepConfigWidget::updateDetails()
{ {
BuildConfiguration *bc = m_makeStep->buildConfiguration(); BuildConfiguration *bc = m_makeStep->buildConfiguration();
const QString defaultMake = m_makeStep->defaultMakeCommand(); const QString defaultMake = m_makeStep->defaultMakeCommand().toString();
if (defaultMake.isEmpty()) if (defaultMake.isEmpty())
m_ui->makeLabel->setText(tr("Make:")); m_ui->makeLabel->setText(tr("Make:"));
else else
@@ -484,14 +485,14 @@ void MakeStepConfigWidget::updateDetails()
ProcessParameters param; ProcessParameters param;
param.setMacroExpander(bc->macroExpander()); param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory().toString()); param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(m_makeStep->effectiveMakeCommand()); param.setCommand(m_makeStep->effectiveMakeCommand());
param.setArguments(m_makeStep->allArguments()); param.setArguments(m_makeStep->allArguments());
param.setEnvironment(m_makeStep->environment(bc)); param.setEnvironment(m_makeStep->environment(bc));
if (param.commandMissing()) if (param.commandMissing())
setSummaryText(tr("<b>Make:</b> %1 not found in the environment.").arg(param.command())); // Override display text setSummaryText(tr("<b>Make:</b> %1 not found in the environment.")
.arg(param.command().toString())); // Override display text
else else
setSummaryText(param.summaryInWorkdir(displayName())); setSummaryText(param.summaryInWorkdir(displayName()));
} }
@@ -504,7 +505,7 @@ void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
void MakeStepConfigWidget::makeLineEditTextEdited() void MakeStepConfigWidget::makeLineEditTextEdited()
{ {
m_makeStep->setMakeCommand(m_ui->makeLineEdit->rawPath()); m_makeStep->setMakeCommand(FileName::fromString(m_ui->makeLineEdit->rawPath()));
updateDetails(); updateDetails();
} }

View File

@@ -28,6 +28,8 @@
#include "abstractprocessstep.h" #include "abstractprocessstep.h"
#include "projectexplorer_global.h" #include "projectexplorer_global.h"
#include <utils/fileutils.h>
QT_FORWARD_DECLARE_CLASS(QListWidgetItem); QT_FORWARD_DECLARE_CLASS(QListWidgetItem);
namespace Utils { class Environment; } namespace Utils { class Environment; }
@@ -56,16 +58,16 @@ public:
QString allArguments() const; QString allArguments() const;
QString userArguments() const; QString userArguments() const;
void setUserArguments(const QString &args); void setUserArguments(const QString &args);
QString makeCommand() const; Utils::FileName makeCommand() const;
void setMakeCommand(const QString &command); void setMakeCommand(const Utils::FileName &command);
QString effectiveMakeCommand() const; Utils::FileName effectiveMakeCommand() const;
void setClean(bool clean); void setClean(bool clean);
bool isClean() const; bool isClean() const;
static QString defaultDisplayName(); static QString defaultDisplayName();
QString defaultMakeCommand() const; Utils::FileName defaultMakeCommand() const;
static QString msgNoMakeCommand(); static QString msgNoMakeCommand();
static Task makeCommandMissingTask(); static Task makeCommandMissingTask();
@@ -91,7 +93,7 @@ private:
QStringList m_buildTargets; QStringList m_buildTargets;
QStringList m_availableTargets; QStringList m_availableTargets;
QString m_makeArguments; QString m_makeArguments;
QString m_makeCommand; Utils::FileName m_makeCommand;
int m_userJobCount = 4; int m_userJobCount = 4;
bool m_overrideMakeflags = false; bool m_overrideMakeflags = false;
bool m_clean = false; bool m_clean = false;

View File

@@ -44,7 +44,9 @@
\sa ProjectExplorer::AbstractProcessStep \sa ProjectExplorer::AbstractProcessStep
*/ */
using namespace ProjectExplorer; using namespace Utils;
namespace ProjectExplorer {
ProcessParameters::ProcessParameters() : ProcessParameters::ProcessParameters() :
m_macroExpander(nullptr), m_macroExpander(nullptr),
@@ -56,7 +58,7 @@ ProcessParameters::ProcessParameters() :
Sets the executable to run. Sets the executable to run.
*/ */
void ProcessParameters::setCommand(const QString &cmd) void ProcessParameters::setCommand(const Utils::FileName &cmd)
{ {
m_command = cmd; m_command = cmd;
m_effectiveCommand.clear(); m_effectiveCommand.clear();
@@ -78,7 +80,7 @@ void ProcessParameters::setArguments(const QString &arguments)
Should be called from init(). Should be called from init().
*/ */
void ProcessParameters::setWorkingDirectory(const QString &workingDirectory) void ProcessParameters::setWorkingDirectory(const FileName &workingDirectory)
{ {
m_workingDirectory = workingDirectory; m_workingDirectory = workingDirectory;
m_effectiveWorkingDirectory.clear(); m_effectiveWorkingDirectory.clear();
@@ -103,13 +105,14 @@ void ProcessParameters::setWorkingDirectory(const QString &workingDirectory)
Gets the fully expanded working directory. Gets the fully expanded working directory.
*/ */
QString ProcessParameters::effectiveWorkingDirectory() const FileName ProcessParameters::effectiveWorkingDirectory() const
{ {
if (m_effectiveWorkingDirectory.isEmpty()) { if (m_effectiveWorkingDirectory.isEmpty()) {
QString wds = m_workingDirectory; QString wds = m_workingDirectory.toString();
if (m_macroExpander) if (m_macroExpander)
wds = m_macroExpander->expand(wds); wds = m_macroExpander->expand(wds);
m_effectiveWorkingDirectory = QDir::cleanPath(m_environment.expandVariables(wds)); m_effectiveWorkingDirectory
= FileName::fromString(QDir::cleanPath(m_environment.expandVariables(wds)));
} }
return m_effectiveWorkingDirectory; return m_effectiveWorkingDirectory;
} }
@@ -118,14 +121,15 @@ QString ProcessParameters::effectiveWorkingDirectory() const
Gets the fully expanded command name to run. Gets the fully expanded command name to run.
*/ */
QString ProcessParameters::effectiveCommand() const FileName ProcessParameters::effectiveCommand() const
{ {
if (m_effectiveCommand.isEmpty()) { if (m_effectiveCommand.isEmpty()) {
QString cmd = m_command; FileName cmd = m_command;
if (m_macroExpander) if (m_macroExpander)
cmd = m_macroExpander->expand(cmd); cmd = m_macroExpander->expand(cmd);
m_effectiveCommand = m_effectiveCommand =
m_environment.searchInPath(cmd, {Utils::FileName::fromString(effectiveWorkingDirectory())}).toString(); m_environment.searchInPath(cmd.toString(),
{effectiveWorkingDirectory()});
m_commandMissing = m_effectiveCommand.isEmpty(); m_commandMissing = m_effectiveCommand.isEmpty();
if (m_commandMissing) if (m_commandMissing)
m_effectiveCommand = cmd; m_effectiveCommand = cmd;
@@ -155,7 +159,7 @@ QString ProcessParameters::effectiveArguments() const
QString ProcessParameters::prettyCommand() const QString ProcessParameters::prettyCommand() const
{ {
QString cmd = m_command; QString cmd = m_command.toString();
if (m_macroExpander) if (m_macroExpander)
cmd = m_macroExpander->expand(cmd); cmd = m_macroExpander->expand(cmd);
return Utils::FileName::fromString(cmd).fileName(); return Utils::FileName::fromString(cmd).fileName();
@@ -164,7 +168,7 @@ QString ProcessParameters::prettyCommand() const
QString ProcessParameters::prettyArguments() const QString ProcessParameters::prettyArguments() const
{ {
QString margs = effectiveArguments(); QString margs = effectiveArguments();
QString workDir = effectiveWorkingDirectory(); QString workDir = effectiveWorkingDirectory().toString();
Utils::QtcProcess::SplitError err; Utils::QtcProcess::SplitError err;
Utils::QtcProcess::Arguments args = Utils::QtcProcess::Arguments args =
Utils::QtcProcess::prepareArgs(margs, &err, Utils::HostOsInfo::hostOs(), &m_environment, &workDir); Utils::QtcProcess::prepareArgs(margs, &err, Utils::HostOsInfo::hostOs(), &m_environment, &workDir);
@@ -187,7 +191,7 @@ QString ProcessParameters::summaryInWorkdir(const QString &displayName) const
.arg(displayName, .arg(displayName,
Utils::QtcProcess::quoteArg(prettyCommand()), Utils::QtcProcess::quoteArg(prettyCommand()),
prettyArguments(), prettyArguments(),
QDir::toNativeSeparators(effectiveWorkingDirectory())); QDir::toNativeSeparators(effectiveWorkingDirectory().toString()));
} }
void ProcessParameters::resolveAll() void ProcessParameters::resolveAll()
@@ -196,3 +200,5 @@ void ProcessParameters::resolveAll()
effectiveArguments(); effectiveArguments();
effectiveWorkingDirectory(); effectiveWorkingDirectory();
} }
} // ProcessExplorer

View File

@@ -28,6 +28,7 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/fileutils.h>
namespace Utils { class MacroExpander; } namespace Utils { class MacroExpander; }
@@ -39,14 +40,14 @@ class PROJECTEXPLORER_EXPORT ProcessParameters
public: public:
ProcessParameters(); ProcessParameters();
void setCommand(const QString &cmd); void setCommand(const Utils::FileName &cmd);
QString command() const { return m_command; } Utils::FileName command() const { return m_command; }
void setArguments(const QString &arguments); void setArguments(const QString &arguments);
QString arguments() const { return m_arguments; } QString arguments() const { return m_arguments; }
void setWorkingDirectory(const QString &workingDirectory); void setWorkingDirectory(const Utils::FileName &workingDirectory);
QString workingDirectory() const { return m_workingDirectory; } Utils::FileName workingDirectory() const { return m_workingDirectory; }
void setEnvironment(const Utils::Environment &env) { m_environment = env; } void setEnvironment(const Utils::Environment &env) { m_environment = env; }
Utils::Environment environment() const { return m_environment; } Utils::Environment environment() const { return m_environment; }
@@ -55,9 +56,9 @@ public:
Utils::MacroExpander *macroExpander() const { return m_macroExpander; } Utils::MacroExpander *macroExpander() const { return m_macroExpander; }
/// Get the fully expanded working directory: /// Get the fully expanded working directory:
QString effectiveWorkingDirectory() const; Utils::FileName effectiveWorkingDirectory() const;
/// Get the fully expanded command name to run: /// Get the fully expanded command name to run:
QString effectiveCommand() const; Utils::FileName effectiveCommand() const;
/// Get the fully expanded arguments to use: /// Get the fully expanded arguments to use:
QString effectiveArguments() const; QString effectiveArguments() const;
@@ -71,14 +72,14 @@ public:
void resolveAll(); void resolveAll();
private: private:
QString m_workingDirectory; Utils::FileName m_workingDirectory;
QString m_command; Utils::FileName m_command;
QString m_arguments; QString m_arguments;
Utils::Environment m_environment; Utils::Environment m_environment;
Utils::MacroExpander *m_macroExpander; Utils::MacroExpander *m_macroExpander;
mutable QString m_effectiveWorkingDirectory; mutable Utils::FileName m_effectiveWorkingDirectory;
mutable QString m_effectiveCommand; mutable Utils::FileName m_effectiveCommand;
mutable QString m_effectiveArguments; mutable QString m_effectiveArguments;
mutable bool m_commandMissing; mutable bool m_commandMissing;
}; };

View File

@@ -93,8 +93,8 @@ void ProcessStep::setupProcessParameters(ProcessParameters *pp)
pp->setMacroExpander(bc ? bc->macroExpander() : Utils::globalMacroExpander()); pp->setMacroExpander(bc ? bc->macroExpander() : Utils::globalMacroExpander());
pp->setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment()); pp->setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment());
pp->setWorkingDirectory(workingDirectory); pp->setWorkingDirectory(Utils::FileName::fromString(workingDirectory));
pp->setCommand(command); pp->setCommand(Utils::FileName::fromString(command));
pp->setArguments(arguments); pp->setArguments(arguments);
pp->resolveAll(); pp->resolveAll();
} }

View File

@@ -855,7 +855,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 = Utils::FileName::fromString(makeStep->effectiveMakeCommand()); cmd.command = makeStep->effectiveMakeCommand();
} }
} }
cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot)); cmd.arguments << "install" << ("INSTALL_ROOT=" + QDir::toNativeSeparators(installRoot));

View File

@@ -75,7 +75,7 @@ bool QmakeMakeStep::init()
if (!bc) if (!bc)
emit addTask(Task::buildConfigurationMissingTask()); emit addTask(Task::buildConfigurationMissingTask());
const QString make = effectiveMakeCommand(); Utils::FileName make = effectiveMakeCommand();
if (make.isEmpty()) if (make.isEmpty())
emit addTask(makeCommandMissingTask()); emit addTask(makeCommandMissingTask());
@@ -96,7 +96,7 @@ bool QmakeMakeStep::init()
workingDirectory = bc->subNodeBuild()->buildDir(); workingDirectory = bc->subNodeBuild()->buildDir();
else else
workingDirectory = bc->buildDirectory().toString(); workingDirectory = bc->buildDirectory().toString();
pp->setWorkingDirectory(workingDirectory); pp->setWorkingDirectory(Utils::FileName::fromString(workingDirectory));
pp->setCommand(make); pp->setCommand(make);
@@ -148,7 +148,8 @@ bool QmakeMakeStep::init()
objectsDir += "/release"; objectsDir += "/release";
} }
} }
QString relObjectsDir = QDir(pp->workingDirectory()).relativeFilePath(objectsDir); QString relObjectsDir = QDir(pp->workingDirectory().toString())
.relativeFilePath(objectsDir);
if (relObjectsDir == ".") if (relObjectsDir == ".")
relObjectsDir.clear(); relObjectsDir.clear();
if (!relObjectsDir.isEmpty()) if (!relObjectsDir.isEmpty())

View File

@@ -223,7 +223,7 @@ bool QMakeStep::init()
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(qmakeBc->macroExpander()); pp->setMacroExpander(qmakeBc->macroExpander());
pp->setWorkingDirectory(workingDirectory); pp->setWorkingDirectory(Utils::FileName::fromString(workingDirectory));
pp->setEnvironment(qmakeBc->environment()); pp->setEnvironment(qmakeBc->environment());
setOutputParser(new QMakeParser); setOutputParser(new QMakeParser);
@@ -314,7 +314,7 @@ void QMakeStep::finish(bool success)
void QMakeStep::startOneCommand(const QString &command, const QString &args) void QMakeStep::startOneCommand(const QString &command, const QString &args)
{ {
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setCommand(command); pp->setCommand(Utils::FileName::fromString(command));
pp->setArguments(args); pp->setArguments(args);
pp->resolveAll(); pp->resolveAll();
@@ -343,7 +343,7 @@ void QMakeStep::runNextCommand()
case State::RUN_MAKE_QMAKE_ALL: case State::RUN_MAKE_QMAKE_ALL:
{ {
auto *parser = new GnuMakeParser; auto *parser = new GnuMakeParser;
parser->setWorkingDirectory(processParameters()->workingDirectory()); parser->setWorkingDirectory(processParameters()->workingDirectory().toString());
setOutputParser(parser); setOutputParser(parser);
m_nextState = State::POST_PROCESS; m_nextState = State::POST_PROCESS;
startOneCommand(m_makeExecutable, m_makeArguments); startOneCommand(m_makeExecutable, m_makeArguments);
@@ -439,7 +439,7 @@ void QMakeStep::setSeparateDebugInfo(bool enable)
QString QMakeStep::makeCommand() const QString QMakeStep::makeCommand() const
{ {
auto *ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>(); auto *ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>();
return ms ? ms->effectiveMakeCommand() : QString(); return ms ? ms->effectiveMakeCommand().toString() : QString();
} }
QString QMakeStep::makeArguments(const QString &makefile) const QString QMakeStep::makeArguments(const QString &makefile) const

View File

@@ -173,7 +173,7 @@ bool MakeInstallStep::cleanInstallRoot() const
void MakeInstallStep::updateCommandFromAspect() void MakeInstallStep::updateCommandFromAspect()
{ {
setMakeCommand(aspect<ExecutableAspect>()->executable().toString()); setMakeCommand(aspect<ExecutableAspect>()->executable());
updateFullCommandLine(); updateFullCommandLine();
} }
@@ -188,7 +188,8 @@ void MakeInstallStep::updateArgsFromAspect()
void MakeInstallStep::updateFullCommandLine() void MakeInstallStep::updateFullCommandLine()
{ {
static_cast<BaseStringAspect *>(aspect(FullCommandLineAspectId))->setValue( static_cast<BaseStringAspect *>(aspect(FullCommandLineAspectId))->setValue(
QDir::toNativeSeparators(QtcProcess::quoteArg(effectiveMakeCommand())) QDir::toNativeSeparators(
QtcProcess::quoteArg(effectiveMakeCommand().toString()))
+ ' ' + userArguments()); + ' ' + userArguments());
} }

View File

@@ -107,7 +107,7 @@ bool WinRtPackageDeploymentStep::init()
QDir::toNativeSeparators(qt->binPath().toString()))); QDir::toNativeSeparators(qt->binPath().toString())));
return false; return false;
} }
params->setCommand(windeployqtPath); params->setCommand(Utils::FileName::fromString(windeployqtPath));
params->setArguments(args); params->setArguments(args);
params->setEnvironment(buildConfiguration()->environment()); params->setEnvironment(buildConfiguration()->environment());