Commit 0ef7f31a authored by mae's avatar mae
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents ba4dd001 de6d6150
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cmakeconfigurewidget.h"
#include "cmakeprojectmanager.h"
#include <projectexplorer/environment.h>
#include <QtGui/QVBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QSpacerItem>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeConfigureWidget::CMakeConfigureWidget(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory)
: QWidget(parent), m_configureSucceded(false), m_cmakeManager(manager), m_sourceDirectory(sourceDirectory)
{
m_ui.setupUi(this);
m_ui.buildDirectoryLineEdit->setPath(sourceDirectory + "/qtcreator-build");
connect(m_ui.configureButton, SIGNAL(clicked()), this, SLOT(runCMake()));
// TODO make the configure button do stuff
// TODO set initial settings
// TODO note if there's already a build in that directory
// detect which generators we have
// let the user select generator
}
QString CMakeConfigureWidget::buildDirectory()
{
return m_ui.buildDirectoryLineEdit->path();
}
QStringList CMakeConfigureWidget::arguments()
{
return ProjectExplorer::Environment::parseCombinedArgString(m_ui.cmakeArgumentsLineEdit->text());
}
bool CMakeConfigureWidget::configureSucceded()
{
return m_configureSucceded;
}
void CMakeConfigureWidget::runCMake()
{
// TODO run project createCbp()
// get output and display it
// TODO analyse wheter this worked out
m_ui.cmakeOutput->setPlainText(tr("Waiting for cmake..."));
QString string = m_cmakeManager->createXmlFile(arguments(), m_sourceDirectory, buildDirectory());
m_ui.cmakeOutput->setPlainText(string);
}
//////
// CMakeConfigureDialog
/////
CMakeConfigureDialog::CMakeConfigureDialog(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory)
: QDialog(parent)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
setLayout(vbox);
m_cmakeConfigureWidget = new CMakeConfigureWidget(this, manager, sourceDirectory);
vbox->addWidget(m_cmakeConfigureWidget);
QHBoxLayout *hboxlayout = new QHBoxLayout(this);
hboxlayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
QPushButton *okButton = new QPushButton(this);
okButton->setText(tr("Ok"));
okButton->setDefault(true);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
hboxlayout->addWidget(okButton);
vbox->addLayout(hboxlayout);
}
QString CMakeConfigureDialog::buildDirectory()
{
return m_cmakeConfigureWidget->buildDirectory();
}
QStringList CMakeConfigureDialog::arguments()
{
return m_cmakeConfigureWidget->arguments();
}
bool CMakeConfigureDialog::configureSucceded()
{
return m_cmakeConfigureWidget->configureSucceded();
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef CMAKECONFIGUREWIDGET_H
#define CMAKECONFIGUREWIDGET_H
#include "ui_cmakeconfigurewidget.h"
#include <QtGui/QWidget>
#include <QtGui/QDialog>
namespace CMakeProjectManager {
namespace Internal {
class CMakeManager;
class CMakeConfigureWidget : public QWidget
{
Q_OBJECT
public:
CMakeConfigureWidget(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory);
Ui::CMakeConfigureWidget m_ui;
QString buildDirectory();
QStringList arguments();
bool configureSucceded();
private slots:
void runCMake();
private:
bool m_configureSucceded;
CMakeManager *m_cmakeManager;
QString m_sourceDirectory;
};
class CMakeConfigureDialog : public QDialog
{
public:
CMakeConfigureDialog(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory);
QString buildDirectory();
QStringList arguments();
bool configureSucceded();
private:
CMakeConfigureWidget *m_cmakeConfigureWidget;
};
}
}
#endif // CMAKECONFIGUREWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CMakeProjectManager::Internal::CMakeConfigureWidget</class>
<widget class="QWidget" name="CMakeProjectManager::Internal::CMakeConfigureWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>662</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelCommandArguments">
<property name="text">
<string>CMake Arguments:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="cmakeArgumentsLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Builddirectory:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Core::Utils::PathChooser" name="buildDirectoryLineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="configureButton">
<property name="text">
<string>Run cmake</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="cmakeOutput"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QLineEdit</extends>
<header location="global">utils/pathchooser.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -28,13 +28,11 @@
**************************************************************************/
#include "cmakeproject.h"
#include "ui_cmakeconfigurewidget.h"
#include "cmakeconfigurewidget.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectnodes.h"
#include "cmakerunconfiguration.h"
#include "cmakestep.h"
#include "makestep.h"
#include "cmakeopenprojectwizard.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
......@@ -84,9 +82,8 @@ void CMakeProject::parseCMakeLists()
{
ProjectExplorer::ToolChain *newToolChain = 0;
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration()));
QString cbpFile = findCbpFile(buildDirectory(activeBuildConfiguration()));
QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration()));
CMakeCbpParser cbpparser;
qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
......@@ -161,6 +158,8 @@ void CMakeProject::parseCMakeLists()
QString CMakeProject::buildParser(const QString &buildConfiguration) const
{
// TODO this is actually slightly wrong, but do i care?
// this should call toolchain(buildConfiguration)
if (!m_toolChain)
return QString::null;
if (m_toolChain->type() == ProjectExplorer::ToolChain::GCC
......@@ -182,20 +181,6 @@ QStringList CMakeProject::targets() const
return results;
}
QString CMakeProject::findCbpFile(const QDir &directory)
{
// Find the cbp file
// TODO the cbp file is named like the project() command in the CMakeList.txt file
// so this method below could find the wrong cbp file, if the user changes the project()
// name
foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(".cbp"))
return directory.path() + "/" + cbpFile;
}
return QString::null;
}
void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list)
{
//m_rootNode->addFileNodes(fileList, m_rootNode);
......@@ -324,47 +309,39 @@ MakeStep *CMakeProject::makeStep() const
return 0;
}
CMakeStep *CMakeProject::cmakeStep() const
{
foreach (ProjectExplorer::BuildStep *bs, buildSteps()) {
if (CMakeStep *cs = qobject_cast<CMakeStep *>(bs))
return cs;
}
return 0;
}
void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
// TODO
Project::restoreSettingsImpl(reader);
bool hasUserFile = !buildConfigurations().isEmpty();
if (!hasUserFile) {
// Ask the user for where he wants to build it
// and the cmake command line
// TODO check wheter there's already a CMakeCache.txt in the src directory,
// then we don't need to ask, we simply need to build in the src directory
CMakeOpenProjectWizard copw(m_manager, QFileInfo(m_fileName).absolutePath());
copw.exec();
// TODO handle cancel....
CMakeConfigureDialog ccd(Core::ICore::instance()->mainWindow(), m_manager, QFileInfo(m_fileName).absolutePath());
ccd.exec();
qDebug()<<"ccd.buildDirectory()"<<ccd.buildDirectory();
qDebug()<<"ccd.buildDirectory()"<<copw.buildDirectory();
// Now create a standard build configuration
CMakeStep *cmakeStep = new CMakeStep(this);
MakeStep *makeStep = new MakeStep(this);
insertBuildStep(0, cmakeStep);
insertBuildStep(1, makeStep);
insertBuildStep(0, makeStep);
addBuildConfiguration("all");
setActiveBuildConfiguration("all");
makeStep->setBuildTarget("all", "all", true);
if (!ccd.buildDirectory().isEmpty())
setValue("all", "buildDirectory", ccd.buildDirectory());
cmakeStep->setUserArguments("all", ccd.arguments());
if (!copw.buildDirectory().isEmpty())
setValue("all", "buildDirectory", copw.buildDirectory());
//TODO save arguments somewhere copw.arguments()
} else {
// We have a user file, but we could still be missing the cbp file
// TODO check that we have a cbp file and if not, open up a dialog ?
// or simply run createXml with the saved settings
}
parseCMakeLists(); // Gets the directory from the active buildconfiguration
if (!hasUserFile) {
......
......@@ -33,7 +33,6 @@
#include "cmakeprojectmanager.h"
#include "cmakeprojectnodes.h"
#include "makestep.h"
#include "cmakestep.h"
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
......@@ -99,13 +98,11 @@ public:
virtual QStringList files(FilesMode fileMode) const;
MakeStep *makeStep() const;
CMakeStep *cmakeStep() const;
QStringList targets() const;
QString buildParser(const QString &buildConfiguration) const;
private:
void parseCMakeLists();
QString findCbpFile(const QDir &);
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
......
......@@ -35,7 +35,6 @@ namespace Constants {
const char * const PROJECTCONTEXT = "CMakeProject.ProjectContext";
const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is correct
const char * const CMAKESTEP = "CMakeProjectManager.CMakeStep";
const char * const MAKESTEP = "CMakeProjectManager.MakeStep";
const char * const CMAKERUNCONFIGURATION = "CMakeProjectManager.CMakeRunConfiguration";
......
......@@ -94,7 +94,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
QString CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory)
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory)
{
// 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
......@@ -108,21 +108,30 @@ QString CMakeManager::createXmlFile(const QStringList &arguments, const QString
QString buildDirectoryPath = buildDirectory.absolutePath();
qDebug()<<"Creating cbp file in"<<buildDirectoryPath;
buildDirectory.mkpath(buildDirectoryPath);
QProcess cmake;
cmake.setWorkingDirectory(buildDirectoryPath);
QProcess * cmake = new QProcess;
cmake->setWorkingDirectory(buildDirectoryPath);
QString generator = "-GCodeBlocks - Unix Makefiles";
cmake.start(cmakeExecutable(), QStringList() << sourceDirectory << arguments << generator);
qDebug()<<cmakeExecutable()<<sourceDirectory << arguments;
cmake.waitForFinished(-1);
cmake.setProcessChannelMode(QProcess::MergedChannels);
QString output = cmake.readAll();
qDebug()<<"cmake output: \n"<<output;
return output;
qDebug()<<cmakeExecutable()<<sourceDirectory << arguments<<generator;
cmake->start(cmakeExecutable(), QStringList() << sourceDirectory << arguments << generator);
return cmake;
}
QString CMakeManager::findCbpFile(const QDir &directory)
{
// Find the cbp file
// TODO the cbp file is named like the project() command in the CMakeList.txt file
// so this method below could find the wrong cbp file, if the user changes the project()
// 2name
foreach (const QString &cbpFile , directory.entryList()) {
if (cbpFile.endsWith(".cbp"))
return directory.path() + "/" + cbpFile;
}
return QString::null;
}
/////
// CMakeRunner
////
......
......@@ -37,6 +37,8 @@
#include <QtCore/QStringList>
#include <QtCore/QDir>
QT_FORWARD_DECLARE_CLASS(QProcess)
namespace CMakeProjectManager {
namespace Internal {
......@@ -56,7 +58,8 @@ public:
virtual QString mimeType() const;
QString cmakeExecutable() const;
QString createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
QProcess* createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
static QString findCbpFile(const QDir &);
private:
int m_projectContext;
int m_projectLanguage;
......
......@@ -7,17 +7,15 @@ HEADERS = cmakeproject.h \
cmakeprojectmanager.h \
cmakeprojectconstants.h \
cmakeprojectnodes.h \
cmakestep.h \
makestep.h \
cmakerunconfiguration.h \
cmakeconfigurewidget.h
cmakeopenprojectwizard.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
cmakeprojectmanager.cpp \
cmakeprojectnodes.cpp \
cmakestep.cpp \
makestep.cpp \
cmakerunconfiguration.cpp \
cmakeconfigurewidget.cpp
cmakeopenprojectwizard.cpp
RESOURCES += cmakeproject.qrc
FORMS += cmakeconfigurewidget.ui
FORMS +=
......@@ -30,7 +30,6 @@
#include "cmakeprojectplugin.h"
#include "cmakeprojectmanager.h"
#include "cmakerunconfiguration.h"
#include "cmakestep.h"
#include "makestep.h"
#include <coreplugin/icore.h>
......@@ -58,7 +57,6 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
CMakeSettingsPage *cmp = new CMakeSettingsPage();
addAutoReleasedObject(cmp);
addAutoReleasedObject(new CMakeManager(cmp));
addAutoReleasedObject(new CMakeBuildStepFactory());
addAutoReleasedObject(new MakeBuildStepFactory());
addAutoReleasedObject(new CMakeRunConfigurationFactory());
return true;
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cmakestep.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include <projectexplorer/environment.h>
#include <utils/qtcassert.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeStep::CMakeStep(CMakeProject *pro)
: AbstractProcessStep(pro), m_pro(pro)
{
}
CMakeStep::~CMakeStep()
{