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