Commit eadd51fa authored by dt's avatar dt
Browse files

Qt4ProjectBuildConfiguration: Handle env vars in working dir correctly.

Task-Nr: QTCREATORBUG-2618

Reviewed-By: hunger
parent 1e15e030
......@@ -175,11 +175,24 @@ void Qt4BuildConfiguration::ctor()
if (m_buildDirectory == target()->project()->projectDirectory())
m_shadowBuild = false;
m_lastEmmitedBuildDirectory = buildDirectory();
connect(this, SIGNAL(environmentChanged()),
this, SLOT(emitBuildDirectoryChanged()));
QtVersionManager *vm = QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
this, SLOT(qtVersionsChanged(QList<int>)));
}
void Qt4BuildConfiguration::emitBuildDirectoryChanged()
{
if (buildDirectory() != m_lastEmmitedBuildDirectory) {
m_lastEmmitedBuildDirectory = buildDirectory();
emit buildDirectoryChanged();
}
}
void Qt4BuildConfiguration::pickValidQtVersion()
{
QList<QtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(qt4Target()->id());
......@@ -198,7 +211,10 @@ Utils::Environment Qt4BuildConfiguration::baseEnvironment() const
{
Utils::Environment env = BuildConfiguration::baseEnvironment();
qtVersion()->addToEnvironment(env);
env.set(QLatin1String("BUILDDIR"), QDir::toNativeSeparators(buildDirectory()));
// 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)
......@@ -206,8 +222,8 @@ Utils::Environment Qt4BuildConfiguration::baseEnvironment() const
return env;
}
/// returns the build directory
QString Qt4BuildConfiguration::buildDirectory() const
/// returns the unexpanded build directory
QString Qt4BuildConfiguration::rawBuildDirectory() const
{
QString workingDirectory;
if (m_shadowBuild) {
......@@ -221,6 +237,12 @@ QString Qt4BuildConfiguration::buildDirectory() const
return workingDirectory;
}
/// returns the build directory
QString Qt4BuildConfiguration::buildDirectory() const
{
return QDir::cleanPath(environment().expandVariables(rawBuildDirectory()));
}
/// If only a sub tree should be build this function returns which sub node
/// should be build
/// \see Qt4BuildConfiguration::setSubNodeBuild
......@@ -261,7 +283,7 @@ QString Qt4BuildConfiguration::shadowBuildDirectory() const
void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory)
{
QtVersion *version = qtVersion();
QString directoryToSet = QDir::fromNativeSeparators(buildDirectory);
QString directoryToSet = buildDirectory;
bool toSet = (shadowBuild && version->isValid() && version->supportsShadowBuilds());
if (m_shadowBuild == toSet && m_buildDirectory == directoryToSet)
return;
......@@ -270,7 +292,7 @@ void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const Q
m_buildDirectory = directoryToSet;
emit environmentChanged();
emit buildDirectoryChanged();
emitBuildDirectoryChanged();
emit proFileEvaluateNeeded(this);
}
......@@ -346,6 +368,7 @@ void Qt4BuildConfiguration::setQtVersion(QtVersion *version)
emit proFileEvaluateNeeded(this);
emit qtVersionChanged();
emit environmentChanged();
emitBuildDirectoryChanged();
}
void Qt4BuildConfiguration::setToolChainType(ProjectExplorer::ToolChain::ToolChainType type)
......@@ -359,6 +382,7 @@ void Qt4BuildConfiguration::setToolChainType(ProjectExplorer::ToolChain::ToolCha
emit proFileEvaluateNeeded(this);
emit toolChainTypeChanged();
emit environmentChanged();
emitBuildDirectoryChanged();
}
ProjectExplorer::ToolChain::ToolChainType Qt4BuildConfiguration::toolChainType() const
......
......@@ -133,6 +133,7 @@ signals:
private slots:
void qtVersionsChanged(const QList<int> &changedVersions);
void emitBuildDirectoryChanged();
protected:
Qt4BuildConfiguration(Qt4Target *target, Qt4BuildConfiguration *source);
......@@ -142,9 +143,11 @@ protected:
private:
void ctor();
void pickValidQtVersion();
QString rawBuildDirectory() const;
bool m_shadowBuild;
QString m_buildDirectory;
QString m_lastEmmitedBuildDirectory;
int m_qtVersionId;
int m_toolChainType;
QtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration;
......
......@@ -100,6 +100,9 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()),
this, SLOT(manageQtVersions()));
connect(project, SIGNAL(environmentChanged()),
this, SLOT(environmentChanged()));
connect(project, SIGNAL(buildDirectoryInitialized()),
this, SLOT(updateImportLabel()));
}
......@@ -135,6 +138,11 @@ void Qt4ProjectConfigWidget::updateDetails()
}
}
void Qt4ProjectConfigWidget::environmentChanged()
{
m_ui->shadowBuildDirEdit->setEnvironment(m_buildConfiguration->environment());
}
void Qt4ProjectConfigWidget::updateShadowBuildUi()
{
m_ui->shadowBuildCheckBox->setEnabled(m_buildConfiguration->qtVersion()->supportsShadowBuilds());
......@@ -173,6 +181,7 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc)
this, SLOT(toolChainTypeChanged()));
}
m_buildConfiguration = static_cast<Qt4BuildConfiguration *>(bc);
m_ui->shadowBuildDirEdit->setEnvironment(m_buildConfiguration->environment());
connect(m_buildConfiguration, SIGNAL(buildDirectoryChanged()),
this, SLOT(buildDirectoryChanged()));
......@@ -268,7 +277,7 @@ void Qt4ProjectConfigWidget::shadowBuildClicked(bool checked)
bool b = m_ui->shadowBuildCheckBox->isChecked();
m_ignoreChange = true;
m_buildConfiguration->setShadowBuildAndDirectory(b, QDir::cleanPath(m_ui->shadowBuildDirEdit->path()));
m_buildConfiguration->setShadowBuildAndDirectory(b, m_ui->shadowBuildDirEdit->rawPath());
m_ignoreChange = false;
updateDetails();
......@@ -277,11 +286,10 @@ void Qt4ProjectConfigWidget::shadowBuildClicked(bool checked)
void Qt4ProjectConfigWidget::shadowBuildEdited()
{
if (m_buildConfiguration->shadowBuildDirectory() == m_ui->shadowBuildDirEdit->path())
if (m_buildConfiguration->shadowBuildDirectory() == m_ui->shadowBuildDirEdit->rawPath())
return;
m_ignoreChange = true;
m_buildConfiguration->setShadowBuildAndDirectory(m_buildConfiguration->shadowBuild(),
QDir::cleanPath(m_ui->shadowBuildDirEdit->path()));
m_buildConfiguration->setShadowBuildAndDirectory(m_buildConfiguration->shadowBuild(), m_ui->shadowBuildDirEdit->rawPath());
m_ignoreChange = false;
// if the directory already exists
......
......@@ -77,6 +77,7 @@ private slots:
void buildDirectoryChanged();
void toolChainTypeChanged();
void updateImportLabel();
void environmentChanged();
private:
void updateDetails();
void updateToolChainCombo();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment