From ef1693e9a3142f4ced3db9885cf5873192a3f9d0 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Mon, 9 Mar 2009 18:13:19 +0100 Subject: [PATCH] Fixes: Add a smarter cmake open project wizard. Details: That fixes a few bugs, while still having a few missing things. Don't allow the user to set a shadow build directory, if there is already a in source build. Detect if a cbp file is already existing and recent enough, don't rerun cmake then. Ensure that the user runs cmake with the cbp generator on opening the project. Show the output of the cmake generator while running. Remove the unecessary cmake step. --- .../cmakeconfigurewidget.cpp | 119 ------------ .../cmakeconfigurewidget.h | 77 -------- .../cmakeconfigurewidget.ui | 95 ---------- .../cmakeprojectmanager/cmakeproject.cpp | 59 ++---- .../cmakeprojectmanager/cmakeproject.h | 3 - .../cmakeprojectconstants.h | 1 - .../cmakeprojectmanager.cpp | 31 ++-- .../cmakeprojectmanager/cmakeprojectmanager.h | 5 +- .../cmakeprojectmanager.pro | 8 +- .../cmakeprojectplugin.cpp | 2 - src/plugins/cmakeprojectmanager/cmakestep.cpp | 170 ------------------ src/plugins/cmakeprojectmanager/cmakestep.h | 94 ---------- src/plugins/projectexplorer/toolchain.cpp | 2 +- 13 files changed, 46 insertions(+), 620 deletions(-) delete mode 100644 src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp delete mode 100644 src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h delete mode 100644 src/plugins/cmakeprojectmanager/cmakeconfigurewidget.ui delete mode 100644 src/plugins/cmakeprojectmanager/cmakestep.cpp delete mode 100644 src/plugins/cmakeprojectmanager/cmakestep.h diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp deleted file mode 100644 index cec6c29cf64..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp +++ /dev/null @@ -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(); -} diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h deleted file mode 100644 index ef9c19708e9..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h +++ /dev/null @@ -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 diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.ui b/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.ui deleted file mode 100644 index cdca9035e6f..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakeconfigurewidget.ui +++ /dev/null @@ -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> diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index d3cd433bbde..05ae4c52b44 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -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) { diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 5712b7957dc..1627356d8e7 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -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); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h index ce1c8508b20..a81340fc7b1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h @@ -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"; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 1a8e2fd49a7..4032b142336 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -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 //// diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index 9d8be1c0f4f..f4c18f906ad 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -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; diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index c6f238c822c..c5e260b8e9b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -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 += diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 1a7d41c17db..de077c2dc94 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -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; diff --git a/src/plugins/cmakeprojectmanager/cmakestep.cpp b/src/plugins/cmakeprojectmanager/cmakestep.cpp deleted file mode 100644 index 7c95e082821..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakestep.cpp +++ /dev/null @@ -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"; -} - diff --git a/src/plugins/cmakeprojectmanager/cmakestep.h b/src/plugins/cmakeprojectmanager/cmakestep.h deleted file mode 100644 index 768fe49306d..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakestep.h +++ /dev/null @@ -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 diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 32125bb1007..2d0fcc5dc25 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -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(); -- GitLab