forked from qt-creator/qt-creator
replace env variable injection with pervasive expando support
do not inject SOURCEDIR and BUILDDIR into the environment of
build steps and run configurations any more.
instead, all custom executable paths, argument lists and working
directories now support the %{sourceDir} and %{buildDir} macros.
this approach is more elegant and more scalable.
This commit is contained in:
@@ -3217,9 +3217,6 @@
|
||||
referenced using the platform's native syntax: $VARNAME or ${VARNAME} on
|
||||
Unix and %VARNAME% on Windows.
|
||||
|
||||
\note Qt Creator sets SOURCEDIR and BUILDDIR as part of the build environment.
|
||||
For more information, see \l{Build Environment}.
|
||||
|
||||
\section1 Clean Steps
|
||||
|
||||
You can use the cleaning process to remove intermediate files. This process
|
||||
|
||||
@@ -83,8 +83,6 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
|
||||
m_msvcVersion = map.value(QLatin1String(MSVC_VERSION_KEY)).toString();
|
||||
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY), cmakeTarget()->defaultBuildDirectory()).toString();
|
||||
|
||||
environment().set("BUILDDIR", m_buildDirectory);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -143,7 +141,6 @@ void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
|
||||
if (m_buildDirectory == buildDirectory)
|
||||
return;
|
||||
m_buildDirectory = buildDirectory;
|
||||
environment().set("BUILDDIR", m_buildDirectory);
|
||||
emit buildDirectoryChanged();
|
||||
emit environmentChanged();
|
||||
}
|
||||
|
||||
@@ -131,7 +131,8 @@ ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration
|
||||
|
||||
QString CMakeRunConfiguration::workingDirectory() const
|
||||
{
|
||||
return environment().expandVariables(baseWorkingDirectory());
|
||||
return QDir::cleanPath(environment().expandVariables(
|
||||
Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::baseWorkingDirectory() const
|
||||
@@ -143,7 +144,7 @@ QString CMakeRunConfiguration::baseWorkingDirectory() const
|
||||
|
||||
QString CMakeRunConfiguration::commandLineArguments() const
|
||||
{
|
||||
return m_arguments;
|
||||
return Utils::QtcProcess::expandMacros(m_arguments, macroExpander());
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::title() const
|
||||
|
||||
@@ -129,18 +129,20 @@ bool MakeStep::init()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
||||
|
||||
setEnabled(true);
|
||||
setWorkingDirectory(bc->buildDirectory());
|
||||
|
||||
setCommand(bc->toolChain()->makeCommand());
|
||||
|
||||
QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
|
||||
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
|
||||
setArguments(arguments);
|
||||
setEnvironment(bc->environment());
|
||||
|
||||
setEnabled(true);
|
||||
setIgnoreReturnValue(m_clean);
|
||||
|
||||
setOutputParser(new ProjectExplorer::GnuMakeParser(workingDirectory()));
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setMacroExpander(bc->macroExpander());
|
||||
pp->setEnvironment(bc->environment());
|
||||
pp->setWorkingDirectory(bc->buildDirectory());
|
||||
pp->setCommand(bc->toolChain()->makeCommand());
|
||||
pp->setArguments(arguments);
|
||||
|
||||
setOutputParser(new ProjectExplorer::GnuMakeParser(pp->effectiveWorkingDirectory()));
|
||||
if (bc->toolChain())
|
||||
appendOutputParser(bc->toolChain()->outputParser());
|
||||
|
||||
@@ -292,15 +294,22 @@ void MakeStepConfigWidget::buildTargetsChanged()
|
||||
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration();
|
||||
ProjectExplorer::ToolChain *tc = bc->toolChain();
|
||||
if (tc) {
|
||||
QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->m_buildTargets);
|
||||
Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());
|
||||
|
||||
CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration();
|
||||
ProjectExplorer::ToolChain *tc = bc->toolChain();
|
||||
if (tc)
|
||||
m_summaryText = tr("<b>Make:</b> %1 %2").arg(tc->makeCommand(), arguments);
|
||||
else
|
||||
ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setEnvironment(bc->environment());
|
||||
param.setWorkingDirectory(bc->buildDirectory());
|
||||
param.setCommand(tc->makeCommand());
|
||||
param.setArguments(arguments);
|
||||
m_summaryText = param.summary(displayName());
|
||||
} else {
|
||||
m_summaryText = tr("<b>Unknown Toolchain</b>");
|
||||
}
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,16 +104,14 @@ bool GenericMakeStep::init()
|
||||
GenericBuildConfiguration *bc = genericBuildConfiguration();
|
||||
|
||||
setEnabled(true);
|
||||
QString buildDir = bc->buildDirectory();
|
||||
Utils::expandMacros(&buildDir, Core::VariableManager::instance()->macroExpander());
|
||||
setWorkingDirectory(buildDir);
|
||||
ProjectExplorer::ProcessParameters *pp = processParameters();
|
||||
pp->setMacroExpander(bc->macroExpander());
|
||||
pp->setWorkingDirectory(bc->buildDirectory());
|
||||
pp->setEnvironment(bc->environment());
|
||||
pp->setCommand(makeCommand());
|
||||
pp->setArguments(allArguments());
|
||||
|
||||
setCommand(makeCommand());
|
||||
setArguments(replacedArguments());
|
||||
|
||||
setEnvironment(bc->environment());
|
||||
|
||||
setOutputParser(new ProjectExplorer::GnuMakeParser(buildDir));
|
||||
setOutputParser(new ProjectExplorer::GnuMakeParser(pp->effectiveWorkingDirectory()));
|
||||
if (bc->genericTarget()->genericProject()->toolChain())
|
||||
appendOutputParser(bc->genericTarget()->genericProject()->toolChain()->outputParser());
|
||||
|
||||
@@ -139,13 +137,11 @@ bool GenericMakeStep::fromMap(const QVariantMap &map)
|
||||
return BuildStep::fromMap(map);
|
||||
}
|
||||
|
||||
QString GenericMakeStep::replacedArguments() const
|
||||
QString GenericMakeStep::allArguments() const
|
||||
{
|
||||
QString replacedArguments = m_makeArguments;
|
||||
Utils::QtcProcess::addArgs(&replacedArguments, m_buildTargets);
|
||||
Utils::QtcProcess::expandMacros(&replacedArguments,
|
||||
Core::VariableManager::instance()->macroExpander());
|
||||
return replacedArguments;
|
||||
QString args = m_makeArguments;
|
||||
Utils::QtcProcess::addArgs(&args, m_buildTargets);
|
||||
return args;
|
||||
}
|
||||
|
||||
QString GenericMakeStep::makeCommand() const
|
||||
@@ -257,8 +253,15 @@ void GenericMakeStepConfigWidget::init()
|
||||
|
||||
void GenericMakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
m_summaryText = tr("<b>Make:</b> %1 %2")
|
||||
.arg(m_makeStep->makeCommand(), m_makeStep->replacedArguments());
|
||||
GenericBuildConfiguration *bc = m_makeStep->genericBuildConfiguration();
|
||||
|
||||
ProjectExplorer::ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setWorkingDirectory(bc->buildDirectory());
|
||||
param.setEnvironment(bc->environment());
|
||||
param.setCommand(m_makeStep->makeCommand());
|
||||
param.setArguments(m_makeStep->allArguments());
|
||||
m_summaryText = param.summary(displayName());
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
virtual bool immutable() const;
|
||||
bool buildsTarget(const QString &target) const;
|
||||
void setBuildTarget(const QString &target, bool on);
|
||||
QString replacedArguments() const;
|
||||
QString allArguments() const;
|
||||
QString makeCommand() const;
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
@@ -66,21 +66,6 @@ AbstractProcessStep::~AbstractProcessStep()
|
||||
delete m_outputParserChain;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setCommand(const QString &cmd)
|
||||
{
|
||||
m_command = cmd;
|
||||
}
|
||||
|
||||
QString AbstractProcessStep::command() const
|
||||
{
|
||||
return m_command;
|
||||
}
|
||||
|
||||
QString AbstractProcessStep::workingDirectory() const
|
||||
{
|
||||
return m_workingDirectory;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setOutputParser(ProjectExplorer::IOutputParser *parser)
|
||||
{
|
||||
delete m_outputParserChain;
|
||||
@@ -109,36 +94,11 @@ ProjectExplorer::IOutputParser *AbstractProcessStep::outputParser() const
|
||||
return m_outputParserChain;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setWorkingDirectory(const QString &workingDirectory)
|
||||
{
|
||||
m_workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setArguments(const QString &arguments)
|
||||
{
|
||||
m_arguments = arguments;
|
||||
}
|
||||
|
||||
QString AbstractProcessStep::arguments() const
|
||||
{
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setEnabled(bool b)
|
||||
{
|
||||
m_enabled = b;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setIgnoreReturnValue(bool b)
|
||||
{
|
||||
m_ignoreReturnValue = b;
|
||||
}
|
||||
|
||||
void AbstractProcessStep::setEnvironment(Utils::Environment env)
|
||||
{
|
||||
m_environment = env;
|
||||
}
|
||||
|
||||
bool AbstractProcessStep::init()
|
||||
{
|
||||
return true;
|
||||
@@ -151,13 +111,13 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
||||
fi.reportResult(true);
|
||||
return;
|
||||
}
|
||||
QDir wd(m_environment.expandVariables(m_workingDirectory));
|
||||
QDir wd(m_param.effectiveWorkingDirectory());
|
||||
if (!wd.exists())
|
||||
wd.mkpath(wd.absolutePath());
|
||||
|
||||
m_process = new Utils::QtcProcess();
|
||||
m_process->setWorkingDirectory(wd.absolutePath());
|
||||
m_process->setEnvironment(m_environment);
|
||||
m_process->setEnvironment(m_param.environment());
|
||||
|
||||
connect(m_process, SIGNAL(readyReadStandardOutput()),
|
||||
this, SLOT(processReadyReadStdOutput()),
|
||||
@@ -170,7 +130,7 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
||||
this, SLOT(slotProcessFinished(int, QProcess::ExitStatus)),
|
||||
Qt::DirectConnection);
|
||||
|
||||
m_process->setCommand(expandedCommand(), m_arguments);
|
||||
m_process->setCommand(m_param.effectiveCommand(), m_param.effectiveArguments());
|
||||
m_process->start();
|
||||
if (!m_process->waitForStarted()) {
|
||||
processStartupFailed();
|
||||
@@ -212,13 +172,14 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
||||
void AbstractProcessStep::processStarted()
|
||||
{
|
||||
emit addOutput(tr("Starting: \"%1\" %2\n")
|
||||
.arg(QDir::toNativeSeparators(expandedCommand()), expandedArguments()),
|
||||
.arg(QDir::toNativeSeparators(m_param.effectiveCommand()),
|
||||
m_param.prettyArguments()),
|
||||
BuildStep::MessageOutput);
|
||||
}
|
||||
|
||||
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
||||
{
|
||||
QString command = QDir::toNativeSeparators(expandedCommand());
|
||||
QString command = QDir::toNativeSeparators(m_param.effectiveCommand());
|
||||
if (status == QProcess::NormalExit && exitCode == 0) {
|
||||
emit addOutput(tr("The process \"%1\" exited normally.").arg(command),
|
||||
BuildStep::MessageOutput);
|
||||
@@ -234,7 +195,8 @@ void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus sta
|
||||
void AbstractProcessStep::processStartupFailed()
|
||||
{
|
||||
emit addOutput(tr("Could not start process \"%1\" %2")
|
||||
.arg(QDir::toNativeSeparators(expandedCommand()), expandedArguments()),
|
||||
.arg(QDir::toNativeSeparators(m_param.effectiveCommand()),
|
||||
m_param.prettyArguments()),
|
||||
BuildStep::ErrorMessageOutput);
|
||||
}
|
||||
|
||||
@@ -350,30 +312,3 @@ void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
||||
|
||||
m_eventLoop->exit(0);
|
||||
}
|
||||
|
||||
QString AbstractProcessStep::expandedCommand() const
|
||||
{
|
||||
QString command = m_environment.searchInPath(
|
||||
m_command, QStringList() << m_environment.expandVariables(m_workingDirectory));
|
||||
if (command.isEmpty())
|
||||
command = m_command;
|
||||
return command;
|
||||
}
|
||||
|
||||
QString AbstractProcessStep::expandedArguments() const
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QString args;
|
||||
#else
|
||||
QStringList args;
|
||||
#endif
|
||||
Utils::QtcProcess::SplitError err;
|
||||
args = Utils::QtcProcess::prepareArgs(m_arguments, &err, &m_environment);
|
||||
if (err != Utils::QtcProcess::SplitOk)
|
||||
return m_arguments; // Sorry, too complex - just fall back.
|
||||
#ifdef Q_OS_WIN
|
||||
return args;
|
||||
#else
|
||||
return Utils::QtcProcess::joinArgs(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define ABSTRACTPROCESSSTEP_H
|
||||
|
||||
#include "buildstep.h"
|
||||
#include "processparameters.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
|
||||
@@ -52,7 +53,7 @@ class IOutputParser;
|
||||
It should be used as a base class if your buildstep just needs to run a process.
|
||||
|
||||
Usage:
|
||||
Use setCommand(), setArguments(), setWorkingDirectory() to specify the process you want to run
|
||||
Use processParameters() to configure the process you want to run
|
||||
(you need to do that before calling AbstractProcessStep::init()).
|
||||
Inside YourBuildStep::init() call AbstractProcessStep::init().
|
||||
Inside YourBuildStep::run() call AbstractProcessStep::run(), which automatically starts the proces
|
||||
@@ -83,34 +84,19 @@ public:
|
||||
virtual BuildStepConfigWidget *createConfigWidget() = 0;
|
||||
virtual bool immutable() const = 0;
|
||||
|
||||
/// setCommand() sets the executable to run in the \p buildConfiguration
|
||||
/// should be called from init()
|
||||
void setCommand(const QString &cmd);
|
||||
QString command() const;
|
||||
|
||||
/// sets the workingDirectory for the process for a buildConfiguration
|
||||
/// should be called from init()
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
|
||||
/// sets the command line arguments used by the process for a \p buildConfiguration
|
||||
/// should be called from init()
|
||||
void setArguments(const QString &arguments);
|
||||
QString arguments() const;
|
||||
|
||||
/// enables or disables a BuildStep
|
||||
/// Disabled BuildSteps immediately return true from their run method
|
||||
/// should be called from init()
|
||||
void setEnabled(bool b);
|
||||
void setEnabled(bool b) { m_enabled = b; }
|
||||
|
||||
/// obtain a reference to the parameters for the actual process to run.
|
||||
/// should be used in init()
|
||||
ProcessParameters *processParameters() { return &m_param; }
|
||||
|
||||
/// If ignoreReturnValue is set to true, then the abstractprocess step will
|
||||
/// return success even if the return value indicates otherwise
|
||||
/// should be called from init
|
||||
void setIgnoreReturnValue(bool b);
|
||||
/// Set the Environment for running the command
|
||||
/// should be called from init()
|
||||
void setEnvironment(Utils::Environment env);
|
||||
|
||||
QString workingDirectory() const;
|
||||
|
||||
// derived classes needs to call this function
|
||||
/// Delete all existing output parsers and start a new chain with the
|
||||
@@ -124,11 +110,6 @@ protected:
|
||||
AbstractProcessStep(BuildStepList *bsl, const QString &id);
|
||||
AbstractProcessStep(BuildStepList *bsl, AbstractProcessStep *bs);
|
||||
|
||||
/// Get the fully expanded command name to run:
|
||||
QString expandedCommand() const;
|
||||
/// Get the fully expanded command line args. This is for display purposes only!
|
||||
QString expandedArguments() const;
|
||||
|
||||
/// Called after the process is started
|
||||
/// the default implementation adds a process started message to the output message
|
||||
virtual void processStarted();
|
||||
@@ -158,18 +139,15 @@ private slots:
|
||||
void taskAdded(const ProjectExplorer::Task &task);
|
||||
|
||||
void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
|
||||
private:
|
||||
|
||||
private:
|
||||
QTimer *m_timer;
|
||||
QFutureInterface<bool> *m_futureInterface;
|
||||
QString m_workingDirectory;
|
||||
QString m_command;
|
||||
QString m_arguments;
|
||||
ProcessParameters m_param;
|
||||
bool m_enabled;
|
||||
bool m_ignoreReturnValue;
|
||||
Utils::QtcProcess *m_process;
|
||||
QEventLoop *m_eventLoop;
|
||||
Utils::Environment m_environment;
|
||||
ProjectExplorer::IOutputParser *m_outputParserChain;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "applicationrunconfiguration.h"
|
||||
#include "buildconfiguration.h"
|
||||
|
||||
#include <coreplugin/variablemanager.h>
|
||||
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -47,4 +52,26 @@ LocalApplicationRunConfiguration::~LocalApplicationRunConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class VarManMacroExpander : public Utils::AbstractQtcMacroExpander {
|
||||
public:
|
||||
virtual bool resolveMacro(const QString &name, QString *ret)
|
||||
{
|
||||
*ret = Core::VariableManager::instance()->value(name);
|
||||
return !ret->isEmpty();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander() const
|
||||
{
|
||||
if (BuildConfiguration *bc = activeBuildConfiguration())
|
||||
return bc->macroExpander();
|
||||
|
||||
static Internal::VarManMacroExpander mx;
|
||||
return &mx;
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "applicationlauncher.h"
|
||||
|
||||
namespace Utils {
|
||||
class AbstractMacroExpander;
|
||||
class Environment;
|
||||
}
|
||||
|
||||
@@ -63,6 +64,8 @@ public:
|
||||
protected:
|
||||
explicit LocalApplicationRunConfiguration(Target *target, const QString &id);
|
||||
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
|
||||
|
||||
Utils::AbstractMacroExpander *macroExpander() const;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "target.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <coreplugin/variablemanager.h>
|
||||
|
||||
#include <QtCore/QProcess>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -51,7 +53,8 @@ const char * const USER_ENVIRONMENT_CHANGES_KEY("ProjectExplorer.BuildConfigurat
|
||||
|
||||
BuildConfiguration::BuildConfiguration(Target *target, const QString &id) :
|
||||
ProjectConfiguration(target, id),
|
||||
m_clearSystemEnvironment(false)
|
||||
m_clearSystemEnvironment(false),
|
||||
m_macroExpander(this)
|
||||
{
|
||||
Q_ASSERT(target);
|
||||
BuildStepList *bsl = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_BUILD));
|
||||
@@ -67,7 +70,8 @@ BuildConfiguration::BuildConfiguration(Target *target, const QString &id) :
|
||||
BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) :
|
||||
ProjectConfiguration(target, source),
|
||||
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
|
||||
m_userEnvironmentChanges(source->m_userEnvironmentChanges)
|
||||
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
|
||||
m_macroExpander(this)
|
||||
{
|
||||
Q_ASSERT(target);
|
||||
// Do not clone stepLists here, do that in the derived constructor instead
|
||||
@@ -148,10 +152,6 @@ Utils::Environment BuildConfiguration::baseEnvironment() const
|
||||
Utils::Environment result;
|
||||
if (useSystemEnvironment())
|
||||
result = Utils::Environment(QProcess::systemEnvironment());
|
||||
|
||||
result.set(QLatin1String("BUILDDIR"), QDir::toNativeSeparators(target()->project()->projectDirectory()));
|
||||
result.set(QLatin1String("SOURCEDIR"), QDir::toNativeSeparators(target()->project()->projectDirectory()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -207,6 +207,20 @@ void BuildConfiguration::cloneSteps(BuildConfiguration *source)
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildConfigMacroExpander::resolveMacro(const QString &name, QString *ret)
|
||||
{
|
||||
if (name == QLatin1String("sourceDir")) {
|
||||
*ret = QDir::toNativeSeparators(m_bc->target()->project()->projectDirectory());
|
||||
return true;
|
||||
}
|
||||
if (name == QLatin1String("buildDir")) {
|
||||
*ret = QDir::toNativeSeparators(m_bc->buildDirectory());
|
||||
return true;
|
||||
}
|
||||
*ret = Core::VariableManager::instance()->value(name);
|
||||
return !ret->isEmpty();
|
||||
}
|
||||
|
||||
///
|
||||
// IBuildConfigurationFactory
|
||||
///
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "projectexplorer_export.h"
|
||||
#include "projectconfiguration.h"
|
||||
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/environment.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
@@ -42,10 +43,19 @@
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class BuildConfiguration;
|
||||
class BuildStepList;
|
||||
class Target;
|
||||
class IOutputParser;
|
||||
|
||||
class BuildConfigMacroExpander : public Utils::AbstractQtcMacroExpander {
|
||||
public:
|
||||
BuildConfigMacroExpander(BuildConfiguration *bc) : m_bc(bc) {}
|
||||
virtual bool resolveMacro(const QString &name, QString *ret);
|
||||
private:
|
||||
BuildConfiguration *m_bc;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT BuildConfiguration : public ProjectConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -79,6 +89,8 @@ public:
|
||||
|
||||
Target *target() const;
|
||||
|
||||
Utils::AbstractMacroExpander *macroExpander() { return &m_macroExpander; }
|
||||
|
||||
signals:
|
||||
void environmentChanged();
|
||||
void buildDirectoryChanged();
|
||||
@@ -95,6 +107,7 @@ private:
|
||||
bool m_clearSystemEnvironment;
|
||||
QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
|
||||
QList<BuildStepList *> m_stepLists;
|
||||
BuildConfigMacroExpander m_macroExpander;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory :
|
||||
@@ -127,4 +140,7 @@ signals:
|
||||
|
||||
Q_DECLARE_METATYPE(ProjectExplorer::BuildConfiguration *);
|
||||
|
||||
// Default directory to run custom (build) commands in.
|
||||
#define DEFAULT_WORKING_DIR "%{buildDir}"
|
||||
|
||||
#endif // BUILDCONFIGURATION_H
|
||||
|
||||
@@ -256,7 +256,7 @@ void CustomExecutableConfigurationWidget::changed()
|
||||
return;
|
||||
|
||||
m_executableChooser->setPath(m_runConfiguration->rawExecutable());
|
||||
m_commandLineArgumentsLineEdit->setText(m_runConfiguration->commandLineArguments());
|
||||
m_commandLineArgumentsLineEdit->setText(m_runConfiguration->rawCommandLineArguments());
|
||||
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
|
||||
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == LocalApplicationRunConfiguration::Console);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <projectexplorer/debugginghelper.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QLabel>
|
||||
@@ -56,12 +58,6 @@ const char * const WORKING_DIRECTORY_KEY("ProjectExplorer.CustomExecutableRunCon
|
||||
const char * const USE_TERMINAL_KEY("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal");
|
||||
const char * const USER_ENVIRONMENT_CHANGES_KEY("ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges");
|
||||
const char * const BASE_ENVIRONMENT_BASE_KEY("ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase");
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
const char * const DEFAULT_WORKING_DIR("%BUILDDIR%");
|
||||
#else
|
||||
const char * const DEFAULT_WORKING_DIR("$BUILDDIR");
|
||||
#endif
|
||||
}
|
||||
|
||||
void CustomExecutableRunConfiguration::ctor()
|
||||
@@ -121,7 +117,8 @@ void CustomExecutableRunConfiguration::activeBuildConfigurationChanged()
|
||||
QString CustomExecutableRunConfiguration::executable() const
|
||||
{
|
||||
Utils::Environment env = environment();
|
||||
QString exec = env.searchInPath(m_executable, QStringList() << workingDirectory());
|
||||
QString exec = env.searchInPath(Utils::expandMacros(m_executable, macroExpander()),
|
||||
QStringList() << workingDirectory());
|
||||
|
||||
if (exec.isEmpty() || !QFileInfo(exec).exists()) {
|
||||
// Oh the executable doesn't exists, ask the user.
|
||||
@@ -154,7 +151,7 @@ QString CustomExecutableRunConfiguration::executable() const
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
return exec;
|
||||
return QDir::cleanPath(exec);
|
||||
}
|
||||
|
||||
QString CustomExecutableRunConfiguration::rawExecutable() const
|
||||
@@ -174,7 +171,8 @@ LocalApplicationRunConfiguration::RunMode CustomExecutableRunConfiguration::runM
|
||||
|
||||
QString CustomExecutableRunConfiguration::workingDirectory() const
|
||||
{
|
||||
return environment().expandVariables(baseWorkingDirectory());
|
||||
return QDir::cleanPath(environment().expandVariables(
|
||||
Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
|
||||
}
|
||||
|
||||
QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
|
||||
@@ -184,6 +182,11 @@ QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
|
||||
|
||||
|
||||
QString CustomExecutableRunConfiguration::commandLineArguments() const
|
||||
{
|
||||
return Utils::QtcProcess::expandMacros(m_cmdArguments, macroExpander());
|
||||
}
|
||||
|
||||
QString CustomExecutableRunConfiguration::rawCommandLineArguments() const
|
||||
{
|
||||
return m_cmdArguments;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
* ask the user if none is specified
|
||||
*/
|
||||
QString executable() const;
|
||||
QString rawExecutable() const;
|
||||
|
||||
/** Returns whether this runconfiguration ever was configured with a executable
|
||||
*/
|
||||
@@ -108,9 +107,11 @@ private:
|
||||
QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
|
||||
|
||||
void setExecutable(const QString &executable);
|
||||
QString rawExecutable() const;
|
||||
void setCommandLineArguments(const QString &commandLineArguments);
|
||||
QString baseWorkingDirectory() const;
|
||||
QString rawCommandLineArguments() const;
|
||||
void setBaseWorkingDirectory(const QString &workingDirectory);
|
||||
QString baseWorkingDirectory() const;
|
||||
void setUserName(const QString &name);
|
||||
void setRunMode(RunMode runMode);
|
||||
|
||||
|
||||
149
src/plugins/projectexplorer/processparameters.cpp
Normal file
149
src/plugins/projectexplorer/processparameters.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "processparameters.h"
|
||||
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
ProcessParameters::ProcessParameters() :
|
||||
m_macroExpander(0),
|
||||
m_commandMissing(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessParameters::setCommand(const QString &cmd)
|
||||
{
|
||||
m_command = cmd;
|
||||
m_effectiveCommand.clear();
|
||||
}
|
||||
|
||||
void ProcessParameters::setArguments(const QString &arguments)
|
||||
{
|
||||
m_arguments = arguments;
|
||||
m_effectiveArguments.clear();
|
||||
}
|
||||
|
||||
void ProcessParameters::setWorkingDirectory(const QString &workingDirectory)
|
||||
{
|
||||
m_workingDirectory = workingDirectory;
|
||||
m_effectiveWorkingDirectory.clear();
|
||||
}
|
||||
|
||||
QString ProcessParameters::effectiveWorkingDirectory() const
|
||||
{
|
||||
if (m_effectiveWorkingDirectory.isEmpty()) {
|
||||
QString wds = m_workingDirectory;
|
||||
if (m_macroExpander)
|
||||
Utils::expandMacros(&wds, m_macroExpander);
|
||||
m_effectiveWorkingDirectory = QDir::cleanPath(m_environment.expandVariables(wds));
|
||||
}
|
||||
return m_effectiveWorkingDirectory;
|
||||
}
|
||||
|
||||
QString ProcessParameters::effectiveCommand() const
|
||||
{
|
||||
if (m_effectiveCommand.isEmpty()) {
|
||||
QString cmd = m_command;
|
||||
if (m_macroExpander)
|
||||
Utils::expandMacros(&cmd, m_macroExpander);
|
||||
m_effectiveCommand = QDir::cleanPath(m_environment.searchInPath(
|
||||
cmd, QStringList() << effectiveWorkingDirectory()));
|
||||
m_commandMissing = m_effectiveCommand.isEmpty();
|
||||
if (m_commandMissing)
|
||||
m_effectiveCommand = cmd;
|
||||
}
|
||||
return m_effectiveCommand;
|
||||
}
|
||||
|
||||
bool ProcessParameters::commandMissing() const
|
||||
{
|
||||
effectiveCommand();
|
||||
return m_commandMissing;
|
||||
}
|
||||
|
||||
QString ProcessParameters::effectiveArguments() const
|
||||
{
|
||||
if (m_effectiveArguments.isEmpty()) {
|
||||
m_effectiveArguments = m_arguments;
|
||||
if (m_macroExpander)
|
||||
Utils::expandMacros(&m_effectiveArguments, m_macroExpander);
|
||||
}
|
||||
return m_effectiveArguments;
|
||||
}
|
||||
|
||||
QString ProcessParameters::prettyCommand() const
|
||||
{
|
||||
QString cmd = m_command;
|
||||
if (m_macroExpander)
|
||||
Utils::expandMacros(&cmd, m_macroExpander);
|
||||
return QFileInfo(cmd).fileName();
|
||||
}
|
||||
|
||||
QString ProcessParameters::prettyArguments() const
|
||||
{
|
||||
QString margs = effectiveArguments();
|
||||
QString workDir = effectiveWorkingDirectory();
|
||||
#ifdef Q_OS_WIN
|
||||
QString args;
|
||||
#else
|
||||
QStringList args;
|
||||
#endif
|
||||
Utils::QtcProcess::SplitError err;
|
||||
args = Utils::QtcProcess::prepareArgs(margs, &err, &m_environment, &workDir);
|
||||
if (err != Utils::QtcProcess::SplitOk)
|
||||
return margs; // Sorry, too complex - just fall back.
|
||||
#ifdef Q_OS_WIN
|
||||
return args;
|
||||
#else
|
||||
return Utils::QtcProcess::joinArgs(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString ProcessParameters::summary(const QString &displayName) const
|
||||
{
|
||||
return QString::fromLatin1("<b>%1:</b> %2 %3")
|
||||
.arg(displayName,
|
||||
Utils::QtcProcess::quoteArg(prettyCommand()),
|
||||
prettyArguments());
|
||||
}
|
||||
|
||||
QString ProcessParameters::summaryInWorkdir(const QString &displayName) const
|
||||
{
|
||||
return QString::fromLatin1("<b>%1:</b> %2 %3 in %4")
|
||||
.arg(displayName,
|
||||
Utils::QtcProcess::quoteArg(prettyCommand()),
|
||||
prettyArguments(),
|
||||
QDir::toNativeSeparators(effectiveWorkingDirectory()));
|
||||
}
|
||||
109
src/plugins/projectexplorer/processparameters.h
Normal file
109
src/plugins/projectexplorer/processparameters.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef PROCESSPARAMETERS_H
|
||||
#define PROCESSPARAMETERS_H
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
|
||||
namespace Utils {
|
||||
class AbstractMacroExpander;
|
||||
};
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
/*!
|
||||
ProcessParameters aggregates all parameters needed to start a process.
|
||||
|
||||
It offers a set of functions which expand macros and environment variables
|
||||
inside the raw parameters to obtain final values for starting a process
|
||||
or for display purposes.
|
||||
*/
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ProcessParameters
|
||||
{
|
||||
public:
|
||||
ProcessParameters();
|
||||
|
||||
/// setCommand() sets the executable to run
|
||||
void setCommand(const QString &cmd);
|
||||
QString command() const { return m_command; }
|
||||
|
||||
/// sets the command line arguments used by the process
|
||||
void setArguments(const QString &arguments);
|
||||
QString arguments() const { return m_arguments; }
|
||||
|
||||
/// sets the workingDirectory for the process for a buildConfiguration
|
||||
/// should be called from init()
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
QString workingDirectory() const { return m_workingDirectory; }
|
||||
|
||||
/// Set the Environment for running the command
|
||||
/// should be called from init()
|
||||
void setEnvironment(const Utils::Environment &env) { m_environment = env; }
|
||||
Utils::Environment environment() const { return m_environment; }
|
||||
|
||||
/// Set the macro expander to use on the command, arguments and working dir.
|
||||
/// Note that the caller retains ownership of the object.
|
||||
void setMacroExpander(Utils::AbstractMacroExpander *mx) { m_macroExpander = mx; }
|
||||
Utils::AbstractMacroExpander *macroExpander() const { return m_macroExpander; }
|
||||
|
||||
/// Get the fully expanded working directory:
|
||||
QString effectiveWorkingDirectory() const;
|
||||
/// Get the fully expanded command name to run:
|
||||
QString effectiveCommand() const;
|
||||
/// Get the fully expanded arguments to use:
|
||||
QString effectiveArguments() const;
|
||||
|
||||
/// True if effectiveCommand() would return only a fallback
|
||||
bool commandMissing() const;
|
||||
|
||||
QString prettyCommand() const;
|
||||
QString prettyArguments() const;
|
||||
QString summary(const QString &displayName) const;
|
||||
QString summaryInWorkdir(const QString &displayName) const;
|
||||
|
||||
private:
|
||||
QString m_workingDirectory;
|
||||
QString m_command;
|
||||
QString m_arguments;
|
||||
Utils::Environment m_environment;
|
||||
Utils::AbstractMacroExpander *m_macroExpander;
|
||||
|
||||
mutable QString m_effectiveWorkingDirectory;
|
||||
mutable QString m_effectiveCommand;
|
||||
mutable QString m_effectiveArguments;
|
||||
mutable bool m_commandMissing;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
#endif // PROCESSPARAMETERS_H
|
||||
@@ -49,12 +49,6 @@ const char * const PROCESS_COMMAND_KEY("ProjectExplorer.ProcessStep.Command");
|
||||
const char * const PROCESS_WORKINGDIRECTORY_KEY("ProjectExplorer.ProcessStep.WorkingDirectory");
|
||||
const char * const PROCESS_ARGUMENTS_KEY("ProjectExplorer.ProcessStep.Arguments");
|
||||
const char * const PROCESS_ENABLED_KEY("ProjectExplorer.ProcessStep.Enabled");
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
const char * const DEFAULT_WORKING_DIR("%BUILDDIR%");
|
||||
#else
|
||||
const char * const DEFAULT_WORKING_DIR("$BUILDDIR");
|
||||
#endif
|
||||
}
|
||||
|
||||
ProcessStep::ProcessStep(BuildStepList *bsl) :
|
||||
@@ -95,12 +89,13 @@ ProcessStep::~ProcessStep()
|
||||
bool ProcessStep::init()
|
||||
{
|
||||
BuildConfiguration *bc = buildConfiguration();
|
||||
setEnvironment(bc->environment());
|
||||
|
||||
AbstractProcessStep::setWorkingDirectory(workingDirectory());
|
||||
AbstractProcessStep::setCommand(m_command);
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setMacroExpander(bc->macroExpander());
|
||||
pp->setEnvironment(bc->environment());
|
||||
pp->setWorkingDirectory(workingDirectory());
|
||||
pp->setCommand(m_command);
|
||||
pp->setArguments(m_arguments);
|
||||
AbstractProcessStep::setEnabled(m_enabled);
|
||||
AbstractProcessStep::setArguments(m_arguments);
|
||||
setOutputParser(bc->createOutputParser());
|
||||
return AbstractProcessStep::init();
|
||||
}
|
||||
@@ -274,12 +269,18 @@ void ProcessStepConfigWidget::updateDetails()
|
||||
{
|
||||
QString displayName = m_step->displayName();
|
||||
if (displayName.isEmpty())
|
||||
displayName = "Custom Process Step";
|
||||
m_summaryText = tr("<b>%1</b> %2 %3 %4")
|
||||
.arg(displayName,
|
||||
m_step->command(),
|
||||
m_step->arguments(),
|
||||
m_step->enabled() ? QString() : tr("(disabled)"));
|
||||
displayName = tr("Custom Process Step");
|
||||
ProcessParameters param;
|
||||
param.setMacroExpander(m_step->buildConfiguration()->macroExpander());
|
||||
param.setEnvironment(m_step->buildConfiguration()->environment());
|
||||
param.setWorkingDirectory(m_step->workingDirectory());
|
||||
param.setCommand(m_step->command());
|
||||
param.setArguments(m_step->arguments());
|
||||
m_summaryText = param.summary(displayName);
|
||||
if (!m_step->enabled()) {
|
||||
//: %1 is the custom process step summary
|
||||
m_summaryText = tr("%1 (disabled)").arg(m_summaryText);
|
||||
}
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ HEADERS += projectexplorer.h \
|
||||
outputformatter.h \
|
||||
runconfigurationmodel.h \
|
||||
buildconfigurationmodel.h \
|
||||
processparameters.h \
|
||||
abstractprocessstep.h \
|
||||
taskhub.h \
|
||||
localapplicationruncontrol.h \
|
||||
@@ -173,6 +174,7 @@ SOURCES += projectexplorer.cpp \
|
||||
runconfigurationmodel.cpp \
|
||||
buildconfigurationmodel.cpp \
|
||||
taskhub.cpp \
|
||||
processparameters.cpp \
|
||||
localapplicationruncontrol.cpp \
|
||||
customexecutableconfigurationwidget.cpp \
|
||||
sessionnodeimpl.cpp
|
||||
|
||||
@@ -123,29 +123,23 @@ bool MakeStep::fromMap(const QVariantMap &map)
|
||||
bool MakeStep::init()
|
||||
{
|
||||
Qt4BuildConfiguration *bc = qt4BuildConfiguration();
|
||||
ProjectExplorer::ProcessParameters *pp = processParameters();
|
||||
pp->setMacroExpander(bc->macroExpander());
|
||||
|
||||
Utils::Environment environment = bc->environment();
|
||||
setEnvironment(environment);
|
||||
pp->setEnvironment(environment);
|
||||
|
||||
QString workingDirectory;
|
||||
if (bc->subNodeBuild())
|
||||
workingDirectory = bc->subNodeBuild()->buildDir();
|
||||
else
|
||||
workingDirectory = bc->buildDirectory();
|
||||
setWorkingDirectory(workingDirectory);
|
||||
pp->setWorkingDirectory(workingDirectory);
|
||||
|
||||
QString makeCmd = bc->makeCommand();
|
||||
if (!m_makeCmd.isEmpty())
|
||||
makeCmd = m_makeCmd;
|
||||
if (!QFileInfo(makeCmd).isAbsolute()) {
|
||||
// Try to detect command in environment
|
||||
const QString tmp = environment.searchInPath(makeCmd);
|
||||
if (tmp.isEmpty()) {
|
||||
emit addOutput(tr("Could not find make command: %1 in the build environment").arg(makeCmd), BuildStep::ErrorOutput);
|
||||
return false;
|
||||
}
|
||||
makeCmd = tmp;
|
||||
}
|
||||
setCommand(makeCmd);
|
||||
pp->setCommand(makeCmd);
|
||||
|
||||
// If we are cleaning, then make can fail with a error code, but that doesn't mean
|
||||
// we should stop the clean queue
|
||||
@@ -187,7 +181,7 @@ bool MakeStep::init()
|
||||
}
|
||||
|
||||
setEnabled(true);
|
||||
setArguments(args);
|
||||
pp->setArguments(args);
|
||||
|
||||
m_gnuMakeParser = 0;
|
||||
|
||||
@@ -298,22 +292,20 @@ void MakeStepConfigWidget::updateMakeOverrideLabel()
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
Qt4BuildConfiguration *bc = m_makeStep->qt4BuildConfiguration();
|
||||
QString workingDirectory = bc->buildDirectory();
|
||||
|
||||
ProjectExplorer::ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setWorkingDirectory(bc->buildDirectory());
|
||||
param.setEnvironment(bc->environment());
|
||||
QString makeCmd = bc->makeCommand();
|
||||
if (!m_makeStep->m_makeCmd.isEmpty())
|
||||
makeCmd = m_makeStep->m_makeCmd;
|
||||
if (!QFileInfo(makeCmd).isAbsolute()) {
|
||||
Utils::Environment environment = bc->environment();
|
||||
// Try to detect command in environment
|
||||
const QString tmp = environment.searchInPath(makeCmd);
|
||||
if (tmp.isEmpty()) {
|
||||
param.setCommand(makeCmd);
|
||||
if (param.commandMissing()) {
|
||||
m_summaryText = tr("<b>Make:</b> %1 not found in the environment.").arg(makeCmd);
|
||||
emit updateSummary();
|
||||
return;
|
||||
}
|
||||
makeCmd = tmp;
|
||||
}
|
||||
// -w option enables "Enter"/"Leaving directory" messages, which we need for detecting the
|
||||
// absolute file path
|
||||
// FIXME doing this without the user having a way to override this is rather bad
|
||||
@@ -328,8 +320,8 @@ void MakeStepConfigWidget::updateDetails()
|
||||
if (m_makeStep->m_makeCmd.isEmpty())
|
||||
Utils::QtcProcess::addArg(&args, QLatin1String("-w"));
|
||||
}
|
||||
m_summaryText = tr("<b>Make:</b> %1 %2 in %3").arg(QFileInfo(makeCmd).fileName(), args,
|
||||
QDir::toNativeSeparators(workingDirectory));
|
||||
param.setArguments(args);
|
||||
m_summaryText = param.summaryInWorkdir(displayName());
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
|
||||
@@ -209,10 +209,12 @@ bool QMakeStep::init()
|
||||
}
|
||||
|
||||
setEnabled(m_needToRunQMake);
|
||||
setWorkingDirectory(workingDirectory);
|
||||
setCommand(program);
|
||||
setArguments(args);
|
||||
setEnvironment(qt4bc->environment());
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setMacroExpander(qt4bc->macroExpander());
|
||||
pp->setWorkingDirectory(workingDirectory);
|
||||
pp->setCommand(program);
|
||||
pp->setArguments(args);
|
||||
pp->setEnvironment(qt4bc->environment());
|
||||
|
||||
setOutputParser(new QMakeParser);
|
||||
|
||||
|
||||
@@ -213,10 +213,6 @@ Utils::Environment Qt4BuildConfiguration::baseEnvironment() const
|
||||
Utils::Environment env = BuildConfiguration::baseEnvironment();
|
||||
qtVersion()->addToEnvironment(env);
|
||||
|
||||
// We can't call buildDirectory() since that uses environment() to expand,
|
||||
// thus calling baseEnvironment() again
|
||||
env.set(QLatin1String("BUILDDIR"), QDir::toNativeSeparators(env.expandVariables(rawBuildDirectory())));
|
||||
|
||||
ToolChain *tc = toolChain();
|
||||
if (tc)
|
||||
tc->addToEnvironment(env);
|
||||
|
||||
@@ -221,7 +221,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
|
||||
toplayout->addRow(tr("Executable:"), m_executableLineEdit);
|
||||
|
||||
QLabel *argumentsLabel = new QLabel(tr("Arguments:"), this);
|
||||
m_argumentsLineEdit = new QLineEdit(qt4RunConfiguration->commandLineArguments(), this);
|
||||
m_argumentsLineEdit = new QLineEdit(qt4RunConfiguration->rawCommandLineArguments(), this);
|
||||
argumentsLabel->setBuddy(m_argumentsLineEdit);
|
||||
toplayout->addRow(argumentsLabel, m_argumentsLineEdit);
|
||||
|
||||
@@ -557,7 +557,8 @@ void Qt4RunConfiguration::setUsingDyldImageSuffix(bool state)
|
||||
|
||||
QString Qt4RunConfiguration::workingDirectory() const
|
||||
{
|
||||
return environment().expandVariables(baseWorkingDirectory());
|
||||
return QDir::cleanPath(environment().expandVariables(
|
||||
Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
|
||||
}
|
||||
|
||||
QString Qt4RunConfiguration::baseWorkingDirectory() const
|
||||
@@ -575,6 +576,11 @@ QString Qt4RunConfiguration::baseWorkingDirectory() const
|
||||
}
|
||||
|
||||
QString Qt4RunConfiguration::commandLineArguments() const
|
||||
{
|
||||
return Utils::QtcProcess::expandMacros(m_commandLineArguments, macroExpander());
|
||||
}
|
||||
|
||||
QString Qt4RunConfiguration::rawCommandLineArguments() const
|
||||
{
|
||||
return m_commandLineArguments;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ private:
|
||||
void setBaseWorkingDirectory(const QString &workingDirectory);
|
||||
QString baseWorkingDirectory() const;
|
||||
void setCommandLineArguments(const QString &argumentsString);
|
||||
QString rawCommandLineArguments() const;
|
||||
enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
|
||||
SystemEnvironmentBase = 1,
|
||||
BuildEnvironmentBase = 2 };
|
||||
|
||||
Reference in New Issue
Block a user