From db20c44d4099ebafb053455634befec7df083099 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 21 Jan 2009 16:25:21 +0100 Subject: [PATCH 1/6] Fixes: Add a settings page to the cmake plugin. Details: There's a linedit on there, we restore and save the settings, only thing missing is actually using it. --- .../cmakeprojectmanager/cmakeproject.h | 1 + .../cmakeprojectmanager.cpp | 105 +++++++++++++++++- .../cmakeprojectmanager/cmakeprojectmanager.h | 30 ++++- .../cmakeprojectmanager.pro | 1 + .../cmakeprojectplugin.cpp | 4 +- src/plugins/projectexplorer/environment.cpp | 4 - 6 files changed, 138 insertions(+), 7 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index a71ca7c8b00..e07c4106d4b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -105,6 +105,7 @@ public: CMakeStep *cmakeStep() const; QStringList targets() const; + private: void parseCMakeLists(const QDir &directory); QString findCbpFile(const QDir &); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 966c0144355..fb19dbdbf9b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -39,16 +39,25 @@ #include #include #include +#include +#include +#include using namespace CMakeProjectManager::Internal; -CMakeManager::CMakeManager() +CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) + : m_settingsPage(cmakeSettingsPage) { Core::ICore *core = Core::ICore::instance(); m_projectContext = core->uniqueIDManager()->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT); m_projectLanguage = core->uniqueIDManager()->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX); } +CMakeSettingsPage::~CMakeSettingsPage() +{ + +} + int CMakeManager::projectContext() const { return m_projectContext; @@ -62,6 +71,14 @@ int CMakeManager::projectLanguage() const ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName) { // TODO check wheter this project is already opened + // Check that we have a cmake executable first + // Look at the settings first + QString cmakeExecutable = m_settingsPage->cmakeExecutable(); + if (cmakeExecutable.isNull()) + m_settingsPage->askUserForCMakeExecutable(); + cmakeExecutable = m_settingsPage->cmakeExecutable(); + if (cmakeExecutable.isNull()) + return 0; return new CMakeProject(this, fileName); } @@ -69,3 +86,89 @@ QString CMakeManager::mimeType() const { return Constants::CMAKEMIMETYPE; } + +///// +// CMakeSettingsPage +//// + +CMakeSettingsPage::CMakeSettingsPage() +{ + Core::ICore *core = Core::ICore::instance(); + QSettings * settings = core->settings(); + settings->beginGroup("CMakeSettings"); + m_cmakeExecutable = settings->value("cmakeExecutable").toString(); + settings->endGroup(); +} + +QString CMakeSettingsPage::findCmakeExecutable() const +{ + ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment(); + return env.searchInPath("cmake"); +} + + +QString CMakeSettingsPage::name() const +{ + return "CMake"; +} + +QString CMakeSettingsPage::category() const +{ + return "CMake"; +} + +QString CMakeSettingsPage::trCategory() const +{ + return tr("CMake"); +} + +QWidget *CMakeSettingsPage::createPage(QWidget *parent) +{ + QWidget *w = new QWidget(parent); + QFormLayout *fl = new QFormLayout(w); + m_pathchooser = new Core::Utils::PathChooser(w); + m_pathchooser->setExpectedKind(Core::Utils::PathChooser::Command); + fl->addRow("CMake executable", m_pathchooser); + m_pathchooser->setPath(cmakeExecutable()); + return w; +} + +void CMakeSettingsPage::saveSettings() const +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup("CMakeSettings"); + settings->setValue("cmakeExecutable", m_cmakeExecutable); + settings->endGroup(); +} + +void CMakeSettingsPage::apply() +{ + m_cmakeExecutable = m_pathchooser->path(); + saveSettings(); +} + +void CMakeSettingsPage::finish() +{ + +} + +QString CMakeSettingsPage::cmakeExecutable() const +{ + if (m_cmakeExecutable.isEmpty()) { + m_cmakeExecutable = findCmakeExecutable(); + if (!m_cmakeExecutable.isEmpty()) { + saveSettings(); + } + } + return m_cmakeExecutable; +} + +void CMakeSettingsPage::askUserForCMakeExecutable() +{ + // TODO implement + // That is ideally add a label to the settings page, which says something + // to the effect: please configure the cmake executable + // and show the settings page + // ensure that we rehide the label in the finish() function + // But to test that i need an environment without cmake, e.g. windows +} diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index 34d97f1cc7c..f0481c51498 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -34,16 +34,20 @@ #ifndef CMAKEPROJECTMANAGER_H #define CMAKEPROJECTMANAGER_H +#include #include +#include namespace CMakeProjectManager { namespace Internal { +class CMakeSettingsPage; + class CMakeManager : public ProjectExplorer::IProjectManager { Q_OBJECT public: - CMakeManager(); + CMakeManager(CMakeSettingsPage *cmakeSettingsPage); virtual int projectContext() const; virtual int projectLanguage() const; @@ -55,6 +59,30 @@ public: private: int m_projectContext; int m_projectLanguage; + CMakeSettingsPage *m_settingsPage; +}; + +class CMakeSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + CMakeSettingsPage(); + virtual ~CMakeSettingsPage(); + virtual QString name() const; + virtual QString category() const; + virtual QString trCategory() const; + + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + + QString cmakeExecutable() const; + void askUserForCMakeExecutable(); +private: + void saveSettings() const; + QString findCmakeExecutable() const; + mutable QString m_cmakeExecutable; + Core::Utils::PathChooser *m_pathchooser; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 74f69fea4ab..688d16b0a97 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -18,3 +18,4 @@ SOURCES = cmakeproject.cpp \ makestep.cpp \ cmakerunconfiguration.cpp RESOURCES += cmakeproject.qrc +FORMS += cmakesettingspage.ui diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 29ad08ec5f1..4c16e0d997b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -59,7 +59,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage)) return false; - addAutoReleasedObject(new CMakeManager()); + CMakeSettingsPage *cmp = new CMakeSettingsPage(); + addAutoReleasedObject(cmp); + addAutoReleasedObject(new CMakeManager(cmp)); addAutoReleasedObject(new CMakeBuildStepFactory()); addAutoReleasedObject(new MakeBuildStepFactory()); addAutoReleasedObject(new CMakeRunConfigurationFactory()); diff --git a/src/plugins/projectexplorer/environment.cpp b/src/plugins/projectexplorer/environment.cpp index 7a767d75b2e..38f35af9727 100644 --- a/src/plugins/projectexplorer/environment.cpp +++ b/src/plugins/projectexplorer/environment.cpp @@ -183,10 +183,6 @@ void Environment::clear() m_values.clear(); } -// currently it returns the string that was passed in, except -// under windows and if the executable does not end in .exe -// then it returns executable appended with .exe -// that is clearly wrong QString Environment::searchInPath(QString executable) { // qDebug()<<"looking for "< Date: Wed, 21 Jan 2009 17:21:59 +0100 Subject: [PATCH 2/6] Fixes: Run cmake to get the version and check for the QtCreator generator Details: We don't act on that information yet. --- .../cmakeprojectmanager.cpp | 26 +++++++++++++++++++ .../cmakeprojectmanager/cmakeprojectmanager.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index fb19dbdbf9b..96170439d4e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -98,6 +98,30 @@ CMakeSettingsPage::CMakeSettingsPage() settings->beginGroup("CMakeSettings"); m_cmakeExecutable = settings->value("cmakeExecutable").toString(); settings->endGroup(); + updateCachedInformation(); +} + +void CMakeSettingsPage::updateCachedInformation() const +{ + // We find out two things: + // Does this cmake version support a QtCreator generator + // and the version + QFileInfo fi(m_cmakeExecutable); + if (!fi.exists()) { + m_version.clear(); + m_supportsQtCreator = false; + } + QProcess cmake; + cmake.start(m_cmakeExecutable, QStringList()<<"--help"); + cmake.waitForFinished(); + QString response = cmake.readAll(); + QRegExp versionRegexp("^cmake version ([*\\d\\.]*)-(|patch (\\d*))(|\\r)\\n"); + versionRegexp.indexIn(response); + + m_supportsQtCreator = response.contains("QtCreator"); + m_version = versionRegexp.cap(1); + if (!versionRegexp.capturedTexts().size()>3) + m_version += "." + versionRegexp.cap(3); } QString CMakeSettingsPage::findCmakeExecutable() const @@ -144,6 +168,7 @@ void CMakeSettingsPage::saveSettings() const void CMakeSettingsPage::apply() { m_cmakeExecutable = m_pathchooser->path(); + updateCachedInformation(); saveSettings(); } @@ -157,6 +182,7 @@ QString CMakeSettingsPage::cmakeExecutable() const if (m_cmakeExecutable.isEmpty()) { m_cmakeExecutable = findCmakeExecutable(); if (!m_cmakeExecutable.isEmpty()) { + updateCachedInformation(); saveSettings(); } } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index f0481c51498..49e6ac8846e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -79,9 +79,12 @@ public: QString cmakeExecutable() const; void askUserForCMakeExecutable(); private: + void updateCachedInformation() const; void saveSettings() const; QString findCmakeExecutable() const; mutable QString m_cmakeExecutable; + mutable QString m_version; + mutable bool m_supportsQtCreator; Core::Utils::PathChooser *m_pathchooser; }; From e97889c782b1ffc0983046bcaeeab992c07e902b Mon Sep 17 00:00:00 2001 From: dt Date: Thu, 22 Jan 2009 11:56:52 +0100 Subject: [PATCH 3/6] Fixes: Remove ui file from pro file. --- src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 688d16b0a97..74f69fea4ab 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -18,4 +18,3 @@ SOURCES = cmakeproject.cpp \ makestep.cpp \ cmakerunconfiguration.cpp RESOURCES += cmakeproject.qrc -FORMS += cmakesettingspage.ui From 874922edad6b16e912ca9f967287f2e01c638faa Mon Sep 17 00:00:00 2001 From: dt Date: Fri, 23 Jan 2009 16:48:06 +0100 Subject: [PATCH 4/6] Fixes: Make the run settings combo box adjust to contents. Details: Little tweak improves readeability for the cmake support, since that currently names the runconfigurations according to their full path. Which is suboptimal and will surely change. But adjusting to contents is better regardless. --- src/plugins/projectexplorer/runsettingspropertiespage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.ui b/src/plugins/projectexplorer/runsettingspropertiespage.ui index a973085873d..93070ce9da1 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.ui +++ b/src/plugins/projectexplorer/runsettingspropertiespage.ui @@ -6,7 +6,7 @@ 0 0 - 521 + 551 300 @@ -35,7 +35,7 @@ - QComboBox::AdjustToMinimumContentsLength + QComboBox::AdjustToContents 30 From e8e2e4f45d8a878eca8b3397cbeb1604da7f24e6 Mon Sep 17 00:00:00 2001 From: dt Date: Fri, 23 Jan 2009 16:57:38 +0100 Subject: [PATCH 5/6] Fixes: Progress to the cmake plugin Details: Add a dialog asking for command line options and build directory. This dialog pops up if you don't have a .user file. Note, though that it also pops up if there is already a in source build. (The build directory lineedit should be read only then.) The cmake button in that dialog and the output pane need more polish to make them better. With those changes you can now build and run marble from Qt Creator. (For marble you need to pass a few options to cmake.) Also add a configuration page to the Tools/Options dialog, where you can specify the cmake executable path. And add a class which runs cmake in the background to find out which version and wheter that cmake version has Qt Creator generator. (Which I did begin to write.) --- .../cmakeconfigurewidget.cpp | 90 ++++++++++ .../cmakeconfigurewidget.h | 48 ++++++ .../cmakeprojectmanager/cmakeproject.cpp | 59 +++---- .../cmakeprojectmanager/cmakeproject.h | 4 +- .../cmakeprojectmanager.cpp | 160 ++++++++++++++---- .../cmakeprojectmanager/cmakeprojectmanager.h | 34 +++- .../cmakeprojectmanager.pro | 7 +- src/plugins/cmakeprojectmanager/cmakestep.cpp | 18 +- src/plugins/cmakeprojectmanager/cmakestep.h | 4 +- 9 files changed, 342 insertions(+), 82 deletions(-) create mode 100644 src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp create mode 100644 src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp new file mode 100644 index 00000000000..41b6a7e0db5 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp @@ -0,0 +1,90 @@ +#include "cmakeconfigurewidget.h" +#include "cmakeprojectmanager.h" +#include +#include +#include +#include + +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(); +} diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h new file mode 100644 index 00000000000..f44444537bf --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h @@ -0,0 +1,48 @@ +#ifndef CMAKECONFIGUREWIDGET_H +#define CMAKECONFIGUREWIDGET_H + +#include "ui_cmakeconfigurewidget.h" +#include +#include + +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 diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index effe432e36a..34bc8fa7908 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -32,21 +32,24 @@ ***************************************************************************/ #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 #include +#include #include +#include #include #include #include #include +#include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; @@ -67,8 +70,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) : m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName)) { m_file = new CMakeFile(this, fileName); - QDir dir = QFileInfo(m_fileName).absoluteDir(); - parseCMakeLists(dir); } CMakeProject::~CMakeProject() @@ -78,12 +79,12 @@ CMakeProject::~CMakeProject() // TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated // TODO make this function work even if it is reparsing -void CMakeProject::parseCMakeLists(const QDir &directory) +void CMakeProject::parseCMakeLists() { - createCbpFile(buildDirectory(QString())); - - QString cbpFile = findCbpFile(buildDirectory(QString())); + QString sourceDirectory = QFileInfo(m_fileName).absolutePath(); + m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration())); + QString cbpFile = findCbpFile(buildDirectory(activeBuildConfiguration())); CMakeCbpParser cbpparser; qDebug()<<"Parsing file "< list) { @@ -300,8 +283,20 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader { // TODO Project::restoreSettingsImpl(reader); - if (buildConfigurations().isEmpty()) { - // No build configuration, adding those + 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 + + CMakeConfigureDialog ccd(Core::ICore::instance()->mainWindow(), m_manager, QFileInfo(m_fileName).absolutePath()); + ccd.exec(); + + qDebug()<<"ccd.buildDirectory()"<setBuildTarget("all", "all", true); + if (!ccd.buildDirectory().isEmpty()) + setValue("all", "buildDirectory", ccd.buildDirectory()); + cmakeStep->setUserArguments("all", ccd.arguments()); + } + parseCMakeLists(); // Gets the directory from the active buildconfiguration + + if (!hasUserFile) { // Create run configurations for m_targets qDebug()<<"Create run configurations of m_targets"; bool setActive = false; @@ -328,7 +330,6 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader } } - // Restoring is fine } diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index e07c4106d4b..5195cfb5735 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -105,11 +105,9 @@ public: CMakeStep *cmakeStep() const; QStringList targets() const; - private: - void parseCMakeLists(const QDir &directory); + void parseCMakeLists(); QString findCbpFile(const QDir &); - void createCbpFile(const QDir &); void buildTree(CMakeProjectNode *rootNode, QList list); ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index d8511011c36..6bed6c3aae8 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -36,11 +36,14 @@ #include "cmakeproject.h" #include "cmakeprojectconstants.h" +#include #include #include #include +#include +#include #include -#include +#include using namespace CMakeProjectManager::Internal; @@ -86,41 +89,131 @@ QString CMakeManager::mimeType() const return Constants::CMAKEMIMETYPE; } +QString CMakeManager::cmakeExecutable() const +{ + return m_settingsPage->cmakeExecutable(); +} + +// TODO need to refactor this out +// 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) +{ + // 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 + // And we are creating tons of files in the source directories + // All of that is not really nice. + // The mid term plan is to move away from the CodeBlocks Generator and use our own + // QtCreator generator, which actually can be very similar to the CodeBlock Generator + + + // TODO we need to pass on the same paremeters as the cmakestep + QString buildDirectoryPath = buildDirectory.absolutePath(); + qDebug()<<"Creating cbp file in"< &fi) +{ + m_mutex.lock(); + QString executable = m_executable; + m_mutex.unlock(); + QProcess cmake; + cmake.start(executable, QStringList()<<"--help"); + cmake.waitForFinished(); + QString response = cmake.readAll(); + QRegExp versionRegexp("^cmake version ([*\\d\\.]*)-(|patch (\\d*))(|\\r)\\n"); + versionRegexp.indexIn(response); + + m_mutex.lock(); + m_supportsQtCreator = response.contains("QtCreator"); + m_version = versionRegexp.cap(1); + if (!versionRegexp.capturedTexts().size()>3) + m_version += "." + versionRegexp.cap(3); + m_cacheUpToDate = true; + m_mutex.unlock(); + fi.reportFinished(); +} + +void CMakeRunner::setExecutable(const QString &executable) +{ + waitForUpToDate(); + m_mutex.lock(); + m_executable = executable; + m_cacheUpToDate = false; + m_mutex.unlock(); + m_future = QtConcurrent::run(&CMakeRunner::run, this); +} + +QString CMakeRunner::executable() const +{ + waitForUpToDate(); + m_mutex.lock(); + QString result = m_executable; + m_mutex.unlock(); + return result; +} + +QString CMakeRunner::version() const +{ + waitForUpToDate(); + m_mutex.lock(); + QString result = m_version; + m_mutex.unlock(); + return result; +} + +bool CMakeRunner::supportsQtCreator() const +{ + waitForUpToDate(); + m_mutex.lock(); + bool result = m_supportsQtCreator; + m_mutex.unlock(); + return result; +} + +void CMakeRunner::waitForUpToDate() const +{ + m_future.waitForFinished(); +} + ///// // CMakeSettingsPage //// + CMakeSettingsPage::CMakeSettingsPage() { Core::ICore *core = Core::ICore::instance(); QSettings * settings = core->settings(); settings->beginGroup("CMakeSettings"); - m_cmakeExecutable = settings->value("cmakeExecutable").toString(); + m_cmakeRunner.setExecutable(settings->value("cmakeExecutable").toString()); settings->endGroup(); - updateCachedInformation(); -} - -void CMakeSettingsPage::updateCachedInformation() const -{ - // We find out two things: - // Does this cmake version support a QtCreator generator - // and the version - QFileInfo fi(m_cmakeExecutable); - if (!fi.exists()) { - m_version.clear(); - m_supportsQtCreator = false; - } - QProcess cmake; - cmake.start(m_cmakeExecutable, QStringList()<<"--help"); - cmake.waitForFinished(); - QString response = cmake.readAll(); - QRegExp versionRegexp("^cmake version ([*\\d\\.]*)-(|patch (\\d*))(|\\r)\\n"); - versionRegexp.indexIn(response); - - m_supportsQtCreator = response.contains("QtCreator"); - m_version = versionRegexp.cap(1); - if (!versionRegexp.capturedTexts().size()>3) - m_version += "." + versionRegexp.cap(3); } QString CMakeSettingsPage::findCmakeExecutable() const @@ -160,14 +253,13 @@ void CMakeSettingsPage::saveSettings() const { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("CMakeSettings"); - settings->setValue("cmakeExecutable", m_cmakeExecutable); + settings->setValue("cmakeExecutable", m_cmakeRunner.executable()); settings->endGroup(); } void CMakeSettingsPage::apply() { - m_cmakeExecutable = m_pathchooser->path(); - updateCachedInformation(); + m_cmakeRunner.setExecutable(m_pathchooser->path()); saveSettings(); } @@ -178,14 +270,14 @@ void CMakeSettingsPage::finish() QString CMakeSettingsPage::cmakeExecutable() const { - if (m_cmakeExecutable.isEmpty()) { - m_cmakeExecutable = findCmakeExecutable(); - if (!m_cmakeExecutable.isEmpty()) { - updateCachedInformation(); + if (m_cmakeRunner.executable().isEmpty()) { + QString cmakeExecutable = findCmakeExecutable(); + if (!cmakeExecutable.isEmpty()) { + m_cmakeRunner.setExecutable(cmakeExecutable); saveSettings(); } } - return m_cmakeExecutable; + return m_cmakeRunner.executable(); } void CMakeSettingsPage::askUserForCMakeExecutable() diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index 49e6ac8846e..d8a61e6e802 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -37,11 +37,15 @@ #include #include #include +#include +#include +#include namespace CMakeProjectManager { namespace Internal { class CMakeSettingsPage; +class CMakeRunner; class CMakeManager : public ProjectExplorer::IProjectManager { @@ -52,16 +56,37 @@ public: virtual int projectContext() const; virtual int projectLanguage() const; - //virtual bool canOpenProject(const QString &fileName); virtual ProjectExplorer::Project *openProject(const QString &fileName); virtual QString mimeType() const; - //virtual QString fileFilter() const; + QString cmakeExecutable() const; + + QString createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory); private: int m_projectContext; int m_projectLanguage; CMakeSettingsPage *m_settingsPage; }; +class CMakeRunner +{ +public: + CMakeRunner(); + void run(QFutureInterface &fi); + void setExecutable(const QString &executable); + QString executable() const; + QString version() const; + bool supportsQtCreator() const; + void waitForUpToDate() const; + +private: + QString m_executable; + QString m_version; + bool m_supportsQtCreator; + bool m_cacheUpToDate; + mutable QFuture m_future; + mutable QMutex m_mutex; +}; + class CMakeSettingsPage : public Core::IOptionsPage { Q_OBJECT @@ -82,9 +107,8 @@ private: void updateCachedInformation() const; void saveSettings() const; QString findCmakeExecutable() const; - mutable QString m_cmakeExecutable; - mutable QString m_version; - mutable bool m_supportsQtCreator; + + mutable CMakeRunner m_cmakeRunner; Core::Utils::PathChooser *m_pathchooser; }; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 74f69fea4ab..c6f238c822c 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -9,12 +9,15 @@ HEADERS = cmakeproject.h \ cmakeprojectnodes.h \ cmakestep.h \ makestep.h \ - cmakerunconfiguration.h + cmakerunconfiguration.h \ + cmakeconfigurewidget.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ cmakeprojectmanager.cpp \ cmakeprojectnodes.cpp \ cmakestep.cpp \ makestep.cpp \ - cmakerunconfiguration.cpp + cmakerunconfiguration.cpp \ + cmakeconfigurewidget.cpp RESOURCES += cmakeproject.qrc +FORMS += cmakeconfigurewidget.ui diff --git a/src/plugins/cmakeprojectmanager/cmakestep.cpp b/src/plugins/cmakeprojectmanager/cmakestep.cpp index 9f114893fc4..3947f6c2792 100644 --- a/src/plugins/cmakeprojectmanager/cmakestep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakestep.cpp @@ -36,6 +36,7 @@ #include "cmakeproject.h" #include "cmakeprojectconstants.h" +#include #include #include #include @@ -56,7 +57,10 @@ bool CMakeStep::init(const QString &buildConfiguration) { setEnabled(buildConfiguration, true); setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(buildConfiguration)); - setCommand(buildConfiguration, "cmake"); // TODO give full path here? + + CMakeManager *cmakeProjectManager = static_cast(m_pro->projectManager()); + + setCommand(buildConfiguration, cmakeProjectManager->cmakeExecutable()); QString sourceDir = QFileInfo(m_pro->file()->fileName()).absolutePath(); setArguments(buildConfiguration, @@ -99,14 +103,14 @@ bool CMakeStep::immutable() const return true; } -QString CMakeStep::userArguments(const QString &buildConfiguration) const +QStringList CMakeStep::userArguments(const QString &buildConfiguration) const { - return ProjectExplorer::Environment::joinArgumentList(value(buildConfiguration, "userArguments").toStringList()); + return value(buildConfiguration, "userArguments").toStringList(); } -void CMakeStep::setUserArguments(const QString &buildConfiguration, const QString &arguments) +void CMakeStep::setUserArguments(const QString &buildConfiguration, const QStringList &arguments) { - setValue(buildConfiguration, "userArguments", ProjectExplorer::Environment::parseCombinedArgString(arguments)); + setValue(buildConfiguration, "userArguments", arguments); } // @@ -132,13 +136,13 @@ void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration) { m_buildConfiguration = buildConfiguration; disconnect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged())); - m_arguments->setText(m_cmakeStep->userArguments(buildConfiguration)); + 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, m_arguments->text()); + m_cmakeStep->setUserArguments(m_buildConfiguration, ProjectExplorer::Environment::parseCombinedArgString(m_arguments->text())); } // diff --git a/src/plugins/cmakeprojectmanager/cmakestep.h b/src/plugins/cmakeprojectmanager/cmakestep.h index c5006a3eadc..861ccec51d5 100644 --- a/src/plugins/cmakeprojectmanager/cmakestep.h +++ b/src/plugins/cmakeprojectmanager/cmakestep.h @@ -63,8 +63,8 @@ public: virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; - void setUserArguments(const QString &buildConfiguration, const QString &arguments); - QString userArguments(const QString &buildConfiguration) const; + void setUserArguments(const QString &buildConfiguration, const QStringList &arguments); + QStringList userArguments(const QString &buildConfiguration) const; private: CMakeProject *m_pro; }; From 54f6f814c87ce135fdad4e311cd8c8fd9cba2e3f Mon Sep 17 00:00:00 2001 From: goro Date: Fri, 23 Jan 2009 17:12:47 +0100 Subject: [PATCH 6/6] Extend version bump script, bump docs to 0.9.2 --- doc/qtcreator.qdoc | 2 +- doc/qtcreator.qdocconf | 10 +++++----- replaceVersion.sh | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 4f393ec9dc1..eb00ea835f7 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -11,7 +11,7 @@ Development Environment (IDE) to develop Qt projects. It is available for the Linux, Mac OS X and Windows platforms. - \note The current version of Qt Creator is 0.9.1 (Beta). It is + \note The current version of Qt Creator is 0.9.2 (Beta). It is possible to edit source code, compile, run and debug applications; other features are still under development. Please send bug reports and suggestions to qt-creator@trolltech.com. To subscribe, send a diff --git a/doc/qtcreator.qdocconf b/doc/qtcreator.qdocconf index b1a99f1319b..6daa5784d3d 100644 --- a/doc/qtcreator.qdocconf +++ b/doc/qtcreator.qdocconf @@ -17,15 +17,15 @@ sources.fileextensions = "qtcreator.qdoc" qhp.projects = QtCreator qhp.QtCreator.file = qtcreator.qhp -qhp.QtCreator.namespace = com.nokia.qtcreator.091 +qhp.QtCreator.namespace = com.nokia.qtcreator.092 qhp.QtCreator.virtualFolder = doc qhp.QtCreator.indexTitle = Qt Creator qhp.QtCreator.indexRoot = qhp.QtCreator.extraFiles = classic.css \ images/qt-logo.png -qhp.QtCreator.filterAttributes = qtcreator 0.9.1 -qhp.QtCreator.customFilters.QtCreator.name = Qt Creator 0.9.1 -qhp.QtCreator.customFilters.QtCreator.filterAttributes = qtcreator 0.9.1 +qhp.QtCreator.filterAttributes = qtcreator 0.9.2 +qhp.QtCreator.customFilters.QtCreator.name = Qt Creator 0.9.2 +qhp.QtCreator.customFilters.QtCreator.filterAttributes = qtcreator 0.9.2 # macros.qdocconf @@ -201,5 +201,5 @@ HTML.footer = "


\n" \ "\n" \ "\n" \ "\n" \ - "\n" \ + "\n" \ "
Copyright © 2008 Nokia 
Qt Creator 0.9.1
Qt Creator 0.9.2
" diff --git a/replaceVersion.sh b/replaceVersion.sh index 0bb38a68a94..3e1eff015bd 100755 --- a/replaceVersion.sh +++ b/replaceVersion.sh @@ -25,6 +25,12 @@ NEW_MINOR=`sed 's/^[0-9]\+\.\([0-9]\+\)\.[0-9]\+$/\1/' <<<"$2"` OLD_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$1"` NEW_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$2"` +OLD_THREE="${OLD_MAJOR}${OLD_MINOR}${OLD_RELEASE}" +NEW_THREE="${NEW_MAJOR}${NEW_MINOR}${NEW_RELEASE}" + +OLD_DOT_THREE="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}" +NEW_DOT_THREE="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}" + OLD_DOT_FOUR="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}\\.0" NEW_DOT_FOUR="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}\\.0" @@ -38,8 +44,10 @@ echo "# Major '${OLD_MAJOR}' -> '${NEW_MAJOR}'" echo "# Minor '${OLD_MINOR}' -> '${NEW_MINOR}'" echo "# Release '${OLD_RELEASE}' -> '${NEW_RELEASE}'" echo "#-----------------------------------------------" -echo "# Dots '${OLD_DOT_FOUR}' -> '${NEW_DOT_FOUR}'" -echo "# Comma '${OLD_COMMA_FOUR}' -> '${NEW_COMMA_FOUR}'" +echo "# 3 '${OLD_THREE}' -> '${NEW_THREE}'" +echo "# Dot 3 '${OLD_DOT_THREE}' -> '${NEW_DOT_THREE}'" +echo "# Dot 4 '${OLD_DOT_FOUR}' -> '${NEW_DOT_FOUR}'" +echo "# Comma 4 '${OLD_COMMA_FOUR}' -> '${NEW_COMMA_FOUR}'" echo "#===============================================" echo @@ -85,7 +93,7 @@ sed \ mv -f "${TMPFILE}" "${INSTALLER_RC}" -## Patch installer.rc +## Patch Info.plist TMPFILE=`mktemp` INFO_PLIST="${SCRIPT_DIR}/src/app/Info.plist" echo "Patching \`${INFO_PLIST}'" @@ -95,6 +103,27 @@ sed \ mv -f "${TMPFILE}" "${INFO_PLIST}" +## Patch qtcreator.qdocconf +TMPFILE=`mktemp` +QDOCCONF="${SCRIPT_DIR}/doc/qtcreator.qdocconf" +echo "Patching \`${QDOCCONF}'" +sed \ + -e "s/"${OLD_DOT_THREE}"/"${NEW_DOT_THREE}"/" \ + -e "s/"${OLD_THREE}"/"${NEW_THREE}"/" \ + "${QDOCCONF}" > "${TMPFILE}" +mv -f "${TMPFILE}" "${QDOCCONF}" + + +## Patch qtcreator.qdoc +TMPFILE=`mktemp` +QDOC="${SCRIPT_DIR}/doc/qtcreator.qdoc" +echo "Patching \`${QDOC}'" +sed \ + -e 's/\(The current version of Qt Creator is \)'${OLD_DOT_THREE}'/\1'${NEW_DOT_THREE}'/' \ + "${QDOC}" > "${TMPFILE}" +mv -f "${TMPFILE}" "${QDOC}" + + ## Go back to original $PWD echo "Leaving directory \`${SCRIPT_DIR}'" popd &>/dev/null || exit 1