Move most of the BuildConfiguration specific functions

Note: I didn't fix all the connects and there are a few missing things.
This compiles, more work is coming.
This commit is contained in:
dt
2009-11-25 18:50:20 +01:00
parent 7949d93a1a
commit a312206306
39 changed files with 714 additions and 695 deletions

View File

@@ -116,8 +116,8 @@ BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type)
CMakeOpenProjectWizard copw(m_project->projectManager(),
m_project->sourceDirectory(),
m_project->buildDirectory(bc),
m_project->environment(bc));
bc->buildDirectory(),
bc->environment());
if (copw.exec() != QDialog::Accepted) {
delete bc;
return false;
@@ -156,7 +156,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
m_fileName(fileName),
m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)),
m_rootNode(new CMakeProjectNode(m_fileName)),
m_toolChain(0),
m_insideFileChanged(false)
{
m_file = new CMakeFile(this, fileName);
@@ -165,7 +164,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
CMakeProject::~CMakeProject()
{
delete m_rootNode;
delete m_toolChain;
}
IBuildConfigurationFactory *CMakeProject::buildConfigurationFactory() const
@@ -179,7 +177,7 @@ void CMakeProject::slotActiveBuildConfiguration()
// Pop up a dialog asking the user to rerun cmake
QFileInfo sourceFileInfo(m_fileName);
QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBC)));
QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory()));
QFileInfo cbpFileFi(cbpFile);
CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing;
if (!cbpFileFi.exists()) {
@@ -196,9 +194,9 @@ void CMakeProject::slotActiveBuildConfiguration()
if (mode != CMakeOpenProjectWizard::Nothing) {
CMakeOpenProjectWizard copw(m_manager,
sourceFileInfo.absolutePath(),
buildDirectory(activeBC),
activeBC->buildDirectory(),
mode,
environment(activeBC));
activeBC->environment());
copw.exec();
activeBC->setValue("msvcVersion", copw.msvcVersion());
}
@@ -216,39 +214,6 @@ void CMakeProject::fileChanged(const QString &fileName)
m_insideFileChanged = false;
}
void CMakeProject::updateToolChain(const QString &compiler)
{
//qDebug()<<"CodeBlocks Compilername"<<compiler
ProjectExplorer::ToolChain *newToolChain = 0;
if (compiler == "gcc") {
#ifdef Q_OS_WIN
newToolChain = ProjectExplorer::ToolChain::createMinGWToolChain("gcc", QString());
#else
newToolChain = ProjectExplorer::ToolChain::createGccToolChain("gcc");
#endif
} else if (compiler == "msvc8") {
newToolChain = ProjectExplorer::ToolChain::createMSVCToolChain(activeBuildConfiguration()->value("msvcVersion").toString(), false);
} else {
// TODO other toolchains
qDebug()<<"Not implemented yet!!! Qt Creator doesn't know which toolchain to use for"<<compiler;
}
if (ProjectExplorer::ToolChain::equals(newToolChain, m_toolChain)) {
delete newToolChain;
newToolChain = 0;
} else {
delete m_toolChain;
m_toolChain = newToolChain;
}
}
ProjectExplorer::ToolChain *CMakeProject::toolChain(BuildConfiguration *configuration) const
{
if (configuration != activeBuildConfiguration())
qWarning()<<"CMakeProject asked for toolchain of a not active buildconfiguration";
return m_toolChain;
}
void CMakeProject::changeBuildDirectory(BuildConfiguration *configuration, const QString &newBuildDirectory)
{
configuration->setValue("buildDirectory", newBuildDirectory);
@@ -263,7 +228,8 @@ QString CMakeProject::sourceDirectory() const
bool CMakeProject::parseCMakeLists()
{
// Find cbp file
QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration()));
CMakeBuildConfiguration *activeCmakeBuildConfiguration = static_cast<CMakeBuildConfiguration *>(activeBuildConfiguration());
QString cbpFile = CMakeManager::findCbpFile(activeCmakeBuildConfiguration->buildDirectory());
// setFolderName
m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName());
@@ -272,7 +238,7 @@ bool CMakeProject::parseCMakeLists()
//qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
// ToolChain
updateToolChain(cbpparser.compilerName());
activeCmakeBuildConfiguration->updateToolChain(cbpparser.compilerName());
m_projectName = cbpparser.projectName();
m_rootNode->setFolderName(cbpparser.projectName());
@@ -325,7 +291,7 @@ bool CMakeProject::parseCMakeLists()
QStringList allIncludePaths;
QStringList allFrameworkPaths;
QList<ProjectExplorer::HeaderPath> allHeaderPaths = m_toolChain->systemHeaderPaths();
QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeCmakeBuildConfiguration->toolChain()->systemHeaderPaths();
foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) {
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path());
@@ -341,12 +307,12 @@ bool CMakeProject::parseCMakeLists()
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
if (pinfo.includePaths != allIncludePaths
|| pinfo.sourceFiles != m_files
|| pinfo.defines != m_toolChain->predefinedMacros()
|| pinfo.defines != activeCmakeBuildConfiguration->toolChain()->predefinedMacros()
|| pinfo.frameworkPaths != allFrameworkPaths) {
pinfo.includePaths = allIncludePaths;
// TODO we only want C++ files, not all other stuff that might be in the project
pinfo.sourceFiles = m_files;
pinfo.defines = m_toolChain->predefinedMacros(); // TODO this is to simplistic
pinfo.defines = activeCmakeBuildConfiguration->toolChain()->predefinedMacros(); // TODO this is to simplistic
pinfo.frameworkPaths = allFrameworkPaths;
modelmanager->updateProjectInfo(pinfo);
modelmanager->updateSourceFiles(pinfo.sourceFiles);
@@ -404,31 +370,12 @@ bool CMakeProject::parseCMakeLists()
} else {
// TODO report error
qDebug()<<"Parsing failed";
delete m_toolChain;
m_toolChain = 0;
activeCmakeBuildConfiguration->updateToolChain(QString::null);
return false;
}
return true;
}
QString CMakeProject::buildParser(BuildConfiguration *configuration) const
{
Q_UNUSED(configuration)
// TODO this is actually slightly wrong, but do i care?
// this should call toolchain(configuration)
if (!m_toolChain)
return QString::null;
if (m_toolChain->type() == ProjectExplorer::ToolChain::GCC
//|| m_toolChain->type() == ProjectExplorer::ToolChain::LinuxICC
|| m_toolChain->type() == ProjectExplorer::ToolChain::MinGW) {
return ProjectExplorer::Constants::BUILD_PARSER_GCC;
} else if (m_toolChain->type() == ProjectExplorer::ToolChain::MSVC
|| m_toolChain->type() == ProjectExplorer::ToolChain::WINCE) {
return ProjectExplorer::Constants::BUILD_PARSER_MSVC;
}
return QString::null;
}
QStringList CMakeProject::targets() const
{
QStringList results;
@@ -551,8 +498,6 @@ QString CMakeProject::name() const
return m_projectName;
}
Core::IFile *CMakeProject::file() const
{
return m_file;
@@ -573,56 +518,6 @@ bool CMakeProject::isApplication() const
return true;
}
ProjectExplorer::Environment CMakeProject::baseEnvironment(BuildConfiguration *configuration) const
{
Environment env = useSystemEnvironment(configuration) ? Environment(QProcess::systemEnvironment()) : Environment();
return env;
}
ProjectExplorer::Environment CMakeProject::environment(BuildConfiguration *configuration) const
{
Environment env = baseEnvironment(configuration);
env.modify(userEnvironmentChanges(configuration));
return env;
}
void CMakeProject::setUseSystemEnvironment(BuildConfiguration *configuration, bool b)
{
if (b == useSystemEnvironment(configuration))
return;
configuration->setValue("clearSystemEnvironment", !b);
emit environmentChanged(configuration);
}
bool CMakeProject::useSystemEnvironment(BuildConfiguration *configuration) const
{
bool b = !(configuration->value("clearSystemEnvironment").isValid() &&
configuration->value("clearSystemEnvironment").toBool());
return b;
}
QList<ProjectExplorer::EnvironmentItem> CMakeProject::userEnvironmentChanges(BuildConfiguration *configuration) const
{
return EnvironmentItem::fromStringList(configuration->value("userEnvironmentChanges").toStringList());
}
void CMakeProject::setUserEnvironmentChanges(BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff)
{
QStringList list = EnvironmentItem::toStringList(diff);
if (list == configuration->value("userEnvironmentChanges"))
return;
configuration->setValue("userEnvironmentChanges", list);
emit environmentChanged(configuration);
}
QString CMakeProject::buildDirectory(BuildConfiguration *configuration) const
{
QString buildDirectory = configuration->value("buildDirectory").toString();
if (buildDirectory.isEmpty())
buildDirectory = sourceDirectory() + "/qtcreator-build";
return buildDirectory;
}
ProjectExplorer::BuildConfigWidget *CMakeProject::createConfigWidget()
{
return new CMakeBuildSettingsWidget(this);
@@ -686,7 +581,7 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
// or simply run createXml with the saved settings
QFileInfo sourceFileInfo(m_fileName);
BuildConfiguration *activeBC = activeBuildConfiguration();
QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBC)));
QString cbpFile = CMakeManager::findCbpFile(QDir(activeBC->buildDirectory()));
QFileInfo cbpFileFi(cbpFile);
CMakeOpenProjectWizard::Mode mode = CMakeOpenProjectWizard::Nothing;
@@ -698,9 +593,9 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
if (mode != CMakeOpenProjectWizard::Nothing) {
CMakeOpenProjectWizard copw(m_manager,
sourceFileInfo.absolutePath(),
buildDirectory(activeBC),
activeBC->buildDirectory(),
mode,
environment(activeBC));
activeBC->environment());
if (copw.exec() != QDialog::Accepted)
return false;
activeBC->setValue("msvcVersion", copw.msvcVersion());
@@ -729,13 +624,6 @@ CMakeTarget CMakeProject::targetForTitle(const QString &title)
return CMakeTarget();
}
ProjectExplorer::ToolChain::ToolChainType CMakeProject::toolChainType() const
{
if (m_toolChain)
return m_toolChain->type();
return ProjectExplorer::ToolChain::UNKNOWN;
}
// CMakeFile
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
@@ -825,9 +713,9 @@ QString CMakeBuildSettingsWidget::displayName() const
void CMakeBuildSettingsWidget::init(BuildConfiguration *bc)
{
m_buildConfiguration = bc;
m_pathLineEdit->setText(m_project->buildDirectory(bc));
if (m_project->buildDirectory(bc) == m_project->sourceDirectory())
m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc);
m_pathLineEdit->setText(m_buildConfiguration->buildDirectory());
if (m_buildConfiguration->buildDirectory() == m_project->sourceDirectory())
m_changeButton->setEnabled(false);
else
m_changeButton->setEnabled(true);
@@ -837,11 +725,11 @@ void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
CMakeOpenProjectWizard copw(m_project->projectManager(),
m_project->sourceDirectory(),
m_project->buildDirectory(m_buildConfiguration),
m_project->environment(m_buildConfiguration));
m_buildConfiguration->buildDirectory(),
m_buildConfiguration->environment());
if (copw.exec() == QDialog::Accepted) {
m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
m_pathLineEdit->setText(m_project->buildDirectory(m_buildConfiguration));
m_pathLineEdit->setText(m_buildConfiguration->buildDirectory());
}
}