Commit adc7a720 authored by dt's avatar dt
Browse files

Use the environment specified for the current build configuration to

rebuild the cbp file

I think that makes sense, we'll see.
parent 14a79dad
......@@ -55,10 +55,11 @@ using namespace CMakeProjectManager::Internal;
// |--> Already existing cbp file (and new enough) --> Page: Ready to load the project
// |--> Page: Ask for cmd options, run generator
CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory)
CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const ProjectExplorer::Environment &env)
: m_cmakeManager(cmakeManager),
m_sourceDirectory(sourceDirectory),
m_creatingCbpFiles(false)
m_creatingCbpFiles(false),
m_environment(env)
{
int startid;
if (hasInSourceBuild()) {
......@@ -80,10 +81,12 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
}
CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory,
const QString &buildDirectory, CMakeOpenProjectWizard::Mode mode)
const QString &buildDirectory, CMakeOpenProjectWizard::Mode mode,
const ProjectExplorer::Environment &env)
: m_cmakeManager(cmakeManager),
m_sourceDirectory(sourceDirectory),
m_creatingCbpFiles(true)
m_creatingCbpFiles(true),
m_environment(env)
{
if (mode == CMakeOpenProjectWizard::NeedToCreate)
addPage(new CMakeRunPage(this, CMakeRunPage::Recreate, buildDirectory));
......@@ -94,10 +97,12 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
}
CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory,
const QString &oldBuildDirectory)
const QString &oldBuildDirectory,
const ProjectExplorer::Environment &env)
: m_cmakeManager(cmakeManager),
m_sourceDirectory(sourceDirectory),
m_creatingCbpFiles(true)
m_creatingCbpFiles(true),
m_environment(env)
{
m_buildDirectory = oldBuildDirectory;
addPage(new ShadowBuildPage(this, true));
......@@ -177,6 +182,11 @@ void CMakeOpenProjectWizard::setArguments(const QStringList &args)
m_arguments = args;
}
ProjectExplorer::Environment CMakeOpenProjectWizard::environment() const
{
return m_environment;
}
InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard)
: QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
......@@ -304,7 +314,7 @@ void CMakeRunPage::runCMake()
m_argumentsLineEdit->setEnabled(false);
QStringList arguments = ProjectExplorer::Environment::parseCombinedArgString(m_argumentsLineEdit->text());
CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory);
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, m_cmakeWizard->environment());
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
}
......
......@@ -30,6 +30,8 @@
#ifndef CMAKEOPENPROJECTWIZARD_H
#define CMAKEOPENPROJECTWIZARD_H
#include <projectexplorer/environment.h>
#include <QtCore/QProcess>
#include <QtGui/QPushButton>
#include <QtGui/QLineEdit>
......@@ -66,11 +68,11 @@ public:
};
// used at importing a project without a .user file
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory);
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const ProjectExplorer::Environment &env);
// used to update if we have already a .user file
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode);
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode, const ProjectExplorer::Environment &env);
// used to change the build directory of one buildconfiguration
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory);
CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory, const ProjectExplorer::Environment &env);
virtual int nextId() const;
QString buildDirectory() const;
......@@ -79,6 +81,7 @@ public:
CMakeManager *cmakeManager() const;
QStringList arguments() const;
void setArguments(const QStringList &args);
ProjectExplorer::Environment environment() const;
private:
bool existsUpToDateXmlFile() const;
bool hasInSourceBuild() const;
......@@ -87,6 +90,7 @@ private:
QString m_sourceDirectory;
QStringList m_arguments;
bool m_creatingCbpFiles;
ProjectExplorer::Environment m_environment;
};
class InSourceBuildPage : public QWizardPage
......
......@@ -104,7 +104,11 @@ void CMakeProject::slotActiveBuildConfiguration()
mode = CMakeOpenProjectWizard::Nothing;
if (mode != CMakeOpenProjectWizard::Nothing) {
CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), buildDirectory(activeBuildConfiguration()), mode);
CMakeOpenProjectWizard copw(m_manager,
sourceFileInfo.absolutePath(),
buildDirectory(activeBuildConfiguration()),
mode,
environment(activeBuildConfiguration()));
copw.exec();
}
// reparse
......@@ -501,7 +505,7 @@ QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets()
// Default to all
makeStep()->setBuildTarget(buildConfiguration, "all", true);
CMakeOpenProjectWizard copw(projectManager(), sourceDirectory(), buildDirectory(buildConfiguration));
CMakeOpenProjectWizard copw(projectManager(), sourceDirectory(), buildDirectory(buildConfiguration), environment(buildConfiguration));
if (copw.exec() == QDialog::Accepted) {
setValue(buildConfiguration, "buildDirectory", copw.buildDirectory());
parseCMakeLists();
......@@ -544,7 +548,7 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
// Ask the user for where he wants to build it
// and the cmake command line
CMakeOpenProjectWizard copw(m_manager, sourceDirectory());
CMakeOpenProjectWizard copw(m_manager, sourceDirectory(), ProjectExplorer::Environment::systemEnvironment());
copw.exec();
// TODO handle cancel....
......@@ -581,7 +585,11 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
mode = CMakeOpenProjectWizard::NeedToUpdate;
if (mode != CMakeOpenProjectWizard::Nothing) {
CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), buildDirectory(activeBuildConfiguration()), mode);
CMakeOpenProjectWizard copw(m_manager,
sourceFileInfo.absolutePath(),
buildDirectory(activeBuildConfiguration()),
mode,
environment(activeBuildConfiguration()));
copw.exec();
}
}
......@@ -692,7 +700,10 @@ void CMakeBuildSettingsWidget::init(const QString &buildConfiguration)
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
CMakeOpenProjectWizard copw(m_project->projectManager(), m_project->sourceDirectory(), m_project->buildDirectory(m_buildConfiguration));
CMakeOpenProjectWizard copw(m_project->projectManager(),
m_project->sourceDirectory(),
m_project->buildDirectory(m_buildConfiguration),
m_project->environment(m_buildConfiguration));
if (copw.exec() == QDialog::Accepted) {
m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
m_pathLineEdit->setText(m_project->buildDirectory(m_buildConfiguration));
......
......@@ -96,7 +96,7 @@ QString CMakeManager::cmakeExecutable() const
// we probably want the process instead of this function
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
// sounds like a plan
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory)
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env)
{
// We create a cbp file, only if we didn't find a cbp file in the base directory
// Yet that can still override cbp files in subdirectories
......@@ -113,6 +113,7 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin
QProcess *cmake = new QProcess;
cmake->setWorkingDirectory(buildDirectoryPath);
cmake->setProcessChannelMode(QProcess::MergedChannels);
cmake->setEnvironment(env.toStringList());
#ifdef Q_OS_WIN
const QString generator = QLatin1String("-GCodeBlocks - MinGW Makefiles");
......
......@@ -59,7 +59,10 @@ public:
virtual QString mimeType() const;
QString cmakeExecutable() const;
QProcess* createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
QProcess* createXmlFile(const QStringList &arguments,
const QString &sourceDirectory,
const QDir &buildDirectory,
const ProjectExplorer::Environment &env);
static QString findCbpFile(const QDir &);
static QString findDumperLibrary(const ProjectExplorer::Environment &env);
......
Markdown is supported
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