forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -1,119 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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();
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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
|
||||
@@ -1,95 +0,0 @@
|
||||
<?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,20 +108,29 @@ 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;
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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()
|
||||
{
|
||||
}
|
||||
|
||||
bool CMakeStep::init(const QString &buildConfiguration)
|
||||
{
|
||||
setEnabled(buildConfiguration, true);
|
||||
setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(buildConfiguration));
|
||||
|
||||
CMakeManager *cmakeProjectManager = static_cast<CMakeManager *>(m_pro->projectManager());
|
||||
|
||||
setCommand(buildConfiguration, cmakeProjectManager->cmakeExecutable());
|
||||
|
||||
QString sourceDir = QFileInfo(m_pro->file()->fileName()).absolutePath();
|
||||
setArguments(buildConfiguration,
|
||||
QStringList()
|
||||
<< sourceDir
|
||||
<< "-GUnix Makefiles"
|
||||
<< value(buildConfiguration, "userArguments").toStringList()); // TODO
|
||||
|
||||
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
|
||||
return AbstractProcessStep::init(buildConfiguration);
|
||||
}
|
||||
|
||||
void CMakeStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
// TODO we want to only run cmake if the command line arguments or
|
||||
// the CmakeLists.txt has actually changed
|
||||
// And we want all of them to share the SAME command line arguments
|
||||
// Shadow building ruins this, hmm, hmm
|
||||
//
|
||||
AbstractProcessStep::run(fi);
|
||||
}
|
||||
|
||||
QString CMakeStep::name()
|
||||
{
|
||||
return Constants::CMAKESTEP;
|
||||
}
|
||||
|
||||
QString CMakeStep::displayName()
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *CMakeStep::createConfigWidget()
|
||||
{
|
||||
return new CMakeBuildStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool CMakeStep::immutable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList CMakeStep::userArguments(const QString &buildConfiguration) const
|
||||
{
|
||||
return value(buildConfiguration, "userArguments").toStringList();
|
||||
}
|
||||
|
||||
void CMakeStep::setUserArguments(const QString &buildConfiguration, const QStringList &arguments)
|
||||
{
|
||||
setValue(buildConfiguration, "userArguments", arguments);
|
||||
}
|
||||
|
||||
//
|
||||
// CMakeBuildStepConfigWidget
|
||||
//
|
||||
|
||||
CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeStep *cmakeStep)
|
||||
: m_cmakeStep(cmakeStep)
|
||||
{
|
||||
QFormLayout *fl = new QFormLayout(this);
|
||||
setLayout(fl);
|
||||
m_arguments = new QLineEdit(this);
|
||||
fl->addRow("Additional arguments", m_arguments);
|
||||
connect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
}
|
||||
|
||||
QString CMakeBuildStepConfigWidget::displayName() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
disconnect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
m_arguments->setText(ProjectExplorer::Environment::joinArgumentList(m_cmakeStep->userArguments(buildConfiguration)));
|
||||
connect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::argumentsLineEditChanged()
|
||||
{
|
||||
m_cmakeStep->setUserArguments(m_buildConfiguration, ProjectExplorer::Environment::parseCombinedArgString(m_arguments->text()));
|
||||
}
|
||||
|
||||
//
|
||||
// CMakeBuildStepFactory
|
||||
//
|
||||
|
||||
bool CMakeBuildStepFactory::canCreate(const QString &name) const
|
||||
{
|
||||
return (Constants::CMAKESTEP == name);
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep *CMakeBuildStepFactory::create(ProjectExplorer::Project *project, const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name == Constants::CMAKESTEP);
|
||||
CMakeProject *pro = qobject_cast<CMakeProject *>(project);
|
||||
Q_ASSERT(pro);
|
||||
return new CMakeStep(pro);
|
||||
}
|
||||
|
||||
QStringList CMakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project * /* pro */) const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QString CMakeBuildStepFactory::displayNameForName(const QString & /* name */) const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 CMAKESTEP_H
|
||||
#define CMAKESTEP_H
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeProject;
|
||||
|
||||
class CMakeBuildStepConfigWidget;
|
||||
|
||||
class CMakeStep : public ProjectExplorer::AbstractProcessStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeStep(CMakeProject *pro);
|
||||
~CMakeStep();
|
||||
virtual bool init(const QString &buildConfiguration);
|
||||
|
||||
virtual void run(QFutureInterface<bool> &fi);
|
||||
|
||||
virtual QString name();
|
||||
virtual QString displayName();
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
virtual bool immutable() const;
|
||||
|
||||
void setUserArguments(const QString &buildConfiguration, const QStringList &arguments);
|
||||
QStringList userArguments(const QString &buildConfiguration) const;
|
||||
private:
|
||||
CMakeProject *m_pro;
|
||||
};
|
||||
|
||||
class CMakeBuildStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeBuildStepConfigWidget(CMakeStep *cmakeStep);
|
||||
virtual QString displayName() const;
|
||||
virtual void init(const QString &buildConfiguration);
|
||||
private slots:
|
||||
void argumentsLineEditChanged();
|
||||
private:
|
||||
CMakeStep *m_cmakeStep;
|
||||
QString m_buildConfiguration;
|
||||
QLineEdit *m_arguments;
|
||||
};
|
||||
|
||||
class CMakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory
|
||||
{
|
||||
virtual bool canCreate(const QString &name) const;
|
||||
virtual ProjectExplorer::BuildStep *create(ProjectExplorer::Project *pro, const QString &name) const;
|
||||
virtual QStringList canCreateForProject(ProjectExplorer::Project *pro) const;
|
||||
virtual QString displayNameForName(const QString &name) const;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif // CMAKESTEP_H
|
||||
@@ -803,10 +803,7 @@ void MainWindow::openFiles(const QStringList &fileNames)
|
||||
void MainWindow::setFocusToEditor()
|
||||
{
|
||||
QWidget *focusWidget = qApp->focusWidget();
|
||||
// ### Duplicated code from EditMode::makeSureEditorManagerVisible
|
||||
IMode *currentMode = m_coreImpl->modeManager()->currentMode();
|
||||
if (currentMode && currentMode->uniqueModeName() != QLatin1String(Constants::MODE_EDIT) &&
|
||||
currentMode->uniqueModeName() != QLatin1String("GdbDebugger.Mode.Debug"))
|
||||
if (!EditorManager::instance()->isVisible())
|
||||
{
|
||||
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
}
|
||||
@@ -814,11 +811,23 @@ void MainWindow::setFocusToEditor()
|
||||
if (IEditor *editor = m_editorManager->currentEditor())
|
||||
editor->widget()->setFocus();
|
||||
|
||||
if (focusWidget && focusWidget == qApp->focusWidget()) {
|
||||
if (FindToolBarPlaceHolder::getCurrent())
|
||||
FindToolBarPlaceHolder::getCurrent()->hide();
|
||||
OutputPaneManager::instance()->slotHide();
|
||||
RightPaneWidget::instance()->setShown(false);
|
||||
bool focusWasAlreadyInEditor = (focusWidget && focusWidget == qApp->focusWidget());
|
||||
if (focusWasAlreadyInEditor) {
|
||||
bool stuffVisible =
|
||||
(FindToolBarPlaceHolder::getCurrent() &&
|
||||
FindToolBarPlaceHolder::getCurrent()->isVisible())
|
||||
|| (OutputPanePlaceHolder::getCurrent() &&
|
||||
OutputPanePlaceHolder::getCurrent()->isVisible())
|
||||
|| (RightPanePlaceHolder::current() &&
|
||||
RightPanePlaceHolder::current()->isVisible());
|
||||
if (stuffVisible) {
|
||||
if (FindToolBarPlaceHolder::getCurrent())
|
||||
FindToolBarPlaceHolder::getCurrent()->hide();
|
||||
OutputPaneManager::instance()->slotHide();
|
||||
RightPaneWidget::instance()->setShown(false);
|
||||
} else {
|
||||
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,5 +88,5 @@ DEFINES += USE_MODEL_TEST=1
|
||||
|
||||
win32 {
|
||||
include(win/win.pri)
|
||||
CONFIG(cdbdebugger):include(cdb\cdb.pri)
|
||||
CONFIG(cdbdebugger):include(cdb/cdb.pri)
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ void MSVCToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
||||
tf.flush();
|
||||
tf.waitForBytesWritten(30000);
|
||||
|
||||
QProcess run;
|
||||
QProcess run; // TODO run in the environment we want to add to...
|
||||
QString cmdPath = env.searchInPath("cmd");
|
||||
run.start(cmdPath, QStringList()<<"/c"<<filename);
|
||||
run.waitForFinished();
|
||||
|
||||
@@ -198,12 +198,18 @@ public:
|
||||
bool m_invertNext;
|
||||
int m_skipLevel;
|
||||
bool m_cumulative;
|
||||
bool m_isFirstVariableValue;
|
||||
QString m_lastVarName;
|
||||
ProVariable::VariableOperator m_variableOperator;
|
||||
QString m_origfile;
|
||||
QString m_oldPath; // To restore the current path to the path
|
||||
QStack<ProFile*> m_profileStack; // To handle 'include(a.pri), so we can track back to 'a.pro' when finished with 'a.pri'
|
||||
|
||||
// we need the following two variables for handling
|
||||
// CONFIG = foo bar $$CONFIG
|
||||
QHash<QString, QStringList> m_tempValuemap; // used while evaluating (variable operator value1 value2 ...)
|
||||
QHash<const ProFile*, QHash<QString, QStringList> > m_tempFilevaluemap; // used while evaluating (variable operator value1 value2 ...)
|
||||
|
||||
QHash<QString, QStringList> m_valuemap; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
||||
QHash<const ProFile*, QHash<QString, QStringList> > m_filevaluemap; // Variables per include file
|
||||
QHash<QString, QString> m_properties;
|
||||
@@ -229,6 +235,7 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
|
||||
m_condition = ConditionFalse;
|
||||
m_invertNext = false;
|
||||
m_skipLevel = 0;
|
||||
m_isFirstVariableValue = true;
|
||||
}
|
||||
|
||||
bool ProFileEvaluator::Private::read(ProFile *pro)
|
||||
@@ -556,12 +563,17 @@ bool ProFileEvaluator::Private::visitBeginProVariable(ProVariable *variable)
|
||||
{
|
||||
m_lastVarName = variable->variable();
|
||||
m_variableOperator = variable->variableOperator();
|
||||
m_isFirstVariableValue = true;
|
||||
m_tempValuemap = m_valuemap;
|
||||
m_tempFilevaluemap = m_filevaluemap;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProFileEvaluator::Private::visitEndProVariable(ProVariable *variable)
|
||||
{
|
||||
Q_UNUSED(variable);
|
||||
m_valuemap = m_tempValuemap;
|
||||
m_filevaluemap = m_tempFilevaluemap;
|
||||
m_lastVarName.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -702,8 +714,8 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value)
|
||||
if (varName == QLatin1String("TARGET")
|
||||
&& m_lineNo == m_prevLineNo
|
||||
&& currentProFile() == m_prevProFile) {
|
||||
QStringList targets = m_valuemap.value(QLatin1String("TARGET"));
|
||||
m_valuemap.remove(QLatin1String("TARGET"));
|
||||
QStringList targets = m_tempValuemap.value(QLatin1String("TARGET"));
|
||||
m_tempValuemap.remove(QLatin1String("TARGET"));
|
||||
QStringList lastTarget(targets.takeLast());
|
||||
lastTarget << v.join(QLatin1String(" "));
|
||||
targets.push_back(lastTarget.join(QLatin1String(" ")));
|
||||
@@ -740,25 +752,30 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value)
|
||||
case ProVariable::SetOperator: // =
|
||||
if (!m_cumulative) {
|
||||
if (!m_skipLevel) {
|
||||
m_valuemap[varName] = v;
|
||||
m_filevaluemap[currentProFile()][varName] = v;
|
||||
if (m_isFirstVariableValue) {
|
||||
m_tempValuemap[varName] = v;
|
||||
m_tempFilevaluemap[currentProFile()][varName] = v;
|
||||
} else { // handle lines "CONFIG = foo bar"
|
||||
m_tempValuemap[varName] += v;
|
||||
m_tempFilevaluemap[currentProFile()][varName] += v;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We are greedy for values.
|
||||
m_valuemap[varName] += v;
|
||||
m_filevaluemap[currentProFile()][varName] += v;
|
||||
m_tempValuemap[varName] += v;
|
||||
m_tempFilevaluemap[currentProFile()][varName] += v;
|
||||
}
|
||||
break;
|
||||
case ProVariable::UniqueAddOperator: // *=
|
||||
if (!m_skipLevel || m_cumulative) {
|
||||
insertUnique(&m_valuemap, varName, v);
|
||||
insertUnique(&m_filevaluemap[currentProFile()], varName, v);
|
||||
insertUnique(&m_tempValuemap, varName, v);
|
||||
insertUnique(&m_tempFilevaluemap[currentProFile()], varName, v);
|
||||
}
|
||||
break;
|
||||
case ProVariable::AddOperator: // +=
|
||||
if (!m_skipLevel || m_cumulative) {
|
||||
m_valuemap[varName] += v;
|
||||
m_filevaluemap[currentProFile()][varName] += v;
|
||||
m_tempValuemap[varName] += v;
|
||||
m_tempFilevaluemap[currentProFile()][varName] += v;
|
||||
}
|
||||
break;
|
||||
case ProVariable::RemoveOperator: // -=
|
||||
@@ -766,16 +783,16 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value)
|
||||
if (!m_skipLevel) {
|
||||
// the insertUnique is a hack for the moment to fix the
|
||||
// CONFIG -= app_bundle problem on Mac (add it to a variable -CONFIG as was done before)
|
||||
if (removeEach(&m_valuemap, varName, v) == 0)
|
||||
insertUnique(&m_valuemap, QString("-%1").arg(varName), v);
|
||||
if (removeEach(&m_filevaluemap[currentProFile()], varName, v) == 0)
|
||||
insertUnique(&m_filevaluemap[currentProFile()], QString("-%1").arg(varName), v);
|
||||
if (removeEach(&m_tempValuemap, varName, v) == 0)
|
||||
insertUnique(&m_tempValuemap, QString("-%1").arg(varName), v);
|
||||
if (removeEach(&m_tempFilevaluemap[currentProFile()], varName, v) == 0)
|
||||
insertUnique(&m_tempFilevaluemap[currentProFile()], QString("-%1").arg(varName), v);
|
||||
}
|
||||
} else if (!m_skipLevel) {
|
||||
// the insertUnique is a hack for the moment to fix the
|
||||
// CONFIG -= app_bundle problem on Mac (add it to a variable -CONFIG as was done before)
|
||||
insertUnique(&m_valuemap, QString("-%1").arg(varName), v);
|
||||
insertUnique(&m_filevaluemap[currentProFile()], QString("-%1").arg(varName), v);
|
||||
insertUnique(&m_tempValuemap, QString("-%1").arg(varName), v);
|
||||
insertUnique(&m_tempFilevaluemap[currentProFile()], QString("-%1").arg(varName), v);
|
||||
} else {
|
||||
// We are stingy with our values, too.
|
||||
}
|
||||
@@ -812,13 +829,14 @@ bool ProFileEvaluator::Private::visitProValue(ProValue *value)
|
||||
if (!m_skipLevel || m_cumulative) {
|
||||
// We could make a union of modified and unmodified values,
|
||||
// but this will break just as much as it fixes, so leave it as is.
|
||||
replaceInList(&m_valuemap[varName], regexp, replace, global);
|
||||
replaceInList(&m_filevaluemap[currentProFile()][varName], regexp, replace, global);
|
||||
replaceInList(&m_tempValuemap[varName], regexp, replace, global);
|
||||
replaceInList(&m_tempFilevaluemap[currentProFile()][varName], regexp, replace, global);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
m_isFirstVariableValue = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user