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:
Oswald Buddenhagen
2010-11-12 17:23:55 +01:00
parent 1e362b0f8b
commit 79be54ed8c
24 changed files with 457 additions and 215 deletions

View File

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

View File

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

View File

@@ -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()
{
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
if (tc) {
QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->m_buildTargets);
Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());
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();
}