diff --git a/projectbuilders/cmakebuilder/CMakeLists.txt b/projectbuilders/cmakebuilder/CMakeLists.txt index 07807ed4a9..f9ac570ed0 100644 --- a/projectbuilders/cmakebuilder/CMakeLists.txt +++ b/projectbuilders/cmakebuilder/CMakeLists.txt @@ -1,53 +1,52 @@ project(cmakebuilder) add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9032 ) include_directories( ${cmakebuilder_SOURCE_DIR} ${KDevelop_SOURCE_DIR}/projectmanagers/cmake ) ########### next target ############### set(cmakebuilder_LIB_SRCS cmakebuilder.cpp cmakejob.cpp - configureandbuildjob.cpp ) kde4_add_kcfg_files( cmakebuilder_LIB_SRCS cmakebuilderconfig.kcfgc ) kde4_add_plugin(kdevcmakebuilder ${cmakebuilder_LIB_SRCS}) target_link_libraries( kdevcmakebuilder kdev4cmakecommon ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} ${KDEVPLATFORM_INTERFACES_LIBRARIES} ${KDEVPLATFORM_OUTPUTVIEW_LIBRARIES} ${KDEVPLATFORM_UTIL_LIBRARIES} ${KDEVPLATFORM_PROJECT_LIBRARIES} ) install(TARGETS kdevcmakebuilder DESTINATION ${PLUGIN_INSTALL_DIR} ) install( FILES kdevcmakebuilder.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) ########### next target ############### set( cmakebuilder_cfg_SRCS cmakebuilderpreferences.cpp ) set( cmakebuilder_cfg_UI cmakebuildersettings.ui ) kde4_add_ui_files( cmakebuilder_cfg_SRCS ${cmakebuilder_cfg_UI} ) kde4_add_kcfg_files( cmakebuilder_cfg_SRCS cmakebuilderconfig.kcfgc ) kde4_add_plugin( kcm_kdev_cmakebuilder ${cmakebuilder_cfg_SRCS} ) target_link_libraries( kcm_kdev_cmakebuilder ${KDE4_KIO_LIBS} ${KDEVPLATFORM_INTERFACES_LIBRARIES} ${KDEVPLATFORM_PROJECT_LIBRARIES} ${KDEVPLATFORM_UTIL_LIBRARIES} ) install( TARGETS kcm_kdev_cmakebuilder DESTINATION ${PLUGIN_INSTALL_DIR} ) install( FILES kcm_kdev_cmakebuilder.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) ########### install files ############### install( FILES data.kdev4 DESTINATION ${DATA_INSTALL_DIR}/kdevcmakebuilder ) diff --git a/projectbuilders/cmakebuilder/cmakebuilder.cpp b/projectbuilders/cmakebuilder/cmakebuilder.cpp index 557a18d475..2ad9d74567 100644 --- a/projectbuilders/cmakebuilder/cmakebuilder.cpp +++ b/projectbuilders/cmakebuilder/cmakebuilder.cpp @@ -1,260 +1,260 @@ /* KDevelop CMake Support * * Copyright 2006-2007 Andreas Pakulat * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include "cmakebuilder.h" #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #include #include #include #include -#include "configureandbuildjob.h" #include "cmakejob.h" #include "cmakeutils.h" #include K_PLUGIN_FACTORY(CMakeBuilderFactory, registerPlugin(); ) K_EXPORT_PLUGIN(CMakeBuilderFactory(KAboutData("kdevcmakebuilder","kdevcmakebuilder", ki18n("CMake Builder"), "0.1", ki18n("Support for building CMake projects"), KAboutData::License_GPL))) CMakeBuilder::CMakeBuilder(QObject *parent, const QVariantList &) : KDevelop::IPlugin(CMakeBuilderFactory::componentData(), parent) { KDEV_USE_EXTENSION_INTERFACE( KDevelop::IProjectBuilder ) addBuilder("Makefile", QStringList("Unix Makefiles") << "NMake Makefiles", core()->pluginController()->pluginForExtension("org.kdevelop.IMakeBuilder")); addBuilder("build.ninja", QStringList("Ninja"), core()->pluginController()->pluginForExtension("org.kdevelop.IProjectBuilder", "KDevNinjaBuilder")); } CMakeBuilder::~CMakeBuilder() { } void CMakeBuilder::addBuilder(const QString& neededfile, const QStringList& generators, KDevelop::IPlugin* i) { if( i ) { IProjectBuilder* b = i->extension(); if( b ) { m_builders[neededfile] = b; foreach(const QString& gen, generators) { m_buildersForGenerator[gen] = b; } connect(i, SIGNAL(built(KDevelop::ProjectBaseItem*)), this, SLOT(buildFinished(KDevelop::ProjectBaseItem*))); connect(i, SIGNAL(failed(KDevelop::ProjectBaseItem*)), this, SLOT(buildFinished(KDevelop::ProjectBaseItem*))); connect(i, SIGNAL(built(KDevelop::ProjectBaseItem*)), this, SIGNAL(built(KDevelop::ProjectBaseItem*))); connect(i, SIGNAL(failed(KDevelop::ProjectBaseItem*)), this, SIGNAL(failed(KDevelop::ProjectBaseItem*))); connect(i, SIGNAL(cleaned(KDevelop::ProjectBaseItem*)), this, SIGNAL(cleaned(KDevelop::ProjectBaseItem*))); connect(i, SIGNAL(installed(KDevelop::ProjectBaseItem*)), this, SIGNAL(installed(KDevelop::ProjectBaseItem*))); kDebug() << "Added builder " << i->metaObject()->className() << "for" << neededfile; } else kWarning() << "Couldn't add " << i->metaObject()->className() << i->extensions(); } } void CMakeBuilder::buildFinished(KDevelop::ProjectBaseItem* it) { if(m_deleteWhenDone.remove(it)) { delete it->parent(); } } KJob* CMakeBuilder::build(KDevelop::ProjectBaseItem *dom) { KDevelop::ProjectBaseItem* builditem = dom; KDevelop::IProject* p = dom->project(); IProjectBuilder* builder = builderForProject(p); if( builder ) { if(dom->file()) { KDevelop::ProjectFileItem* file = dom->file(); int lastDot = file->text().lastIndexOf('.'); QString target = file->text().mid(0, lastDot)+".o"; CMakeFolderItem *fldr = new CMakeFolderItem(p, dom->url().upUrl(), KUrl::relativeUrl(p->folder(), file->url().upUrl()), 0); KDevelop::ProjectTargetItem *it = new KDevelop::ProjectTargetItem(p, target); fldr->appendRow(it); builditem=it; m_deleteWhenDone << it; } KJob* configure = 0; if( CMake::checkForNeedingConfigure(dom) ) { kDebug() << "Needing configure, adding item and setting job"; configure = this->configure(p); } else if( CMake::currentBuildDir(p).isEmpty() ) { KMessageBox::error(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("No Build Directory configured, cannot build"), i18n("Aborting build") ); return 0; } kDebug(9032) << "Building with make"; KJob* build = builder->build(builditem); if( configure ) { kDebug() << "creating composite job"; - build = new ConfigureAndBuildJob( configure, build ); + build = new SequentiallyRunJobs( configure, build ); } return build; } return 0; } KJob* CMakeBuilder::clean(KDevelop::ProjectBaseItem *dom) { IProjectBuilder* builder = builderForProject(dom->project()); if( builder ) { KDevelop::ProjectBaseItem* item = dom; if(dom->file()) //It doesn't work to compile a file item=(KDevelop::ProjectBaseItem*) dom->parent(); KJob* configure = 0; if( CMake::checkForNeedingConfigure(item) ) { configure = this->configure(item->project()); } else if( CMake::currentBuildDir( item->project() ).isEmpty() ) { KMessageBox::error(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("No Build Directory configured, cannot clean"), i18n("Aborting clean") ); return 0; } kDebug(9032) << "Cleaning with make"; KJob* clean = builder->clean(item); if( configure ) { - clean = new ConfigureAndBuildJob( configure, clean ); + clean = new SequentiallyRunJobs( configure, clean ); } return clean; } return 0; } KJob* CMakeBuilder::install(KDevelop::ProjectBaseItem *dom) { IProjectBuilder* builder = builderForProject(dom->project()); if( builder ) { KDevelop::ProjectBaseItem* item = dom; if(dom->file()) item=(KDevelop::ProjectBaseItem*) dom->parent(); KJob* configure = 0; if( CMake::checkForNeedingConfigure(item) ) { configure = this->configure(item->project()); } else if( CMake::currentBuildDir( item->project() ).isEmpty() ) { KMessageBox::error(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("No Build Directory configured, cannot install"), i18n("Aborting install") ); return 0; } kDebug(9032) << "Installing with make"; KJob* install = builder->install(item); if( configure ) { - install = new ConfigureAndBuildJob( configure, install ); + install = new SequentiallyRunJobs( configure, install ); } return install; } return 0; } KJob* CMakeBuilder::configure( KDevelop::IProject* project ) { if( CMake::currentBuildDir( project ).isEmpty() ) { KMessageBox::error(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("No Build Directory configured, cannot configure"), i18n("Aborting configure") ); return 0; } CMakeJob* job = new CMakeJob(this); job->setProject(project); return job; } KJob* CMakeBuilder::prune( KDevelop::IProject* project ) { KUrl builddir = CMake::currentBuildDir( project ); if( builddir.isEmpty() ) { KMessageBox::information(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("No Build Directory configured, cannot clear builddir"), i18n("No clearing of builddir possible") ); return 0; } else if (!builddir.isLocalFile() || QDir(builddir.toLocalFile()).exists("CMakeLists.txt")) { KMessageBox::information(KDevelop::ICore::self()->uiController()->activeMainWindow(), i18n("Wrong build directory, cannot clear the build directory"), i18n("No clearing of builddir possible") ); return 0; } QDir d( builddir.toLocalFile() ); KUrl::List urls; foreach( const QString& entry, d.entryList( QDir::NoDotAndDotDot | QDir::AllEntries ) ) { KUrl tmp = builddir; tmp.addPath( entry ); urls << tmp; } return KIO::del( urls ); } KDevelop::IProjectBuilder* CMakeBuilder::builderForProject(KDevelop::IProject* p) { QString builddir = CMake::currentBuildDir( p ).toLocalFile(); QMap::const_iterator it = m_builders.constBegin(), itEnd = m_builders.constEnd(); for(; it!=itEnd; ++it) { if(QFile::exists(builddir+'/'+it.key())) return it.value(); } //It means that it still has to be generated, so use the builder for //the generator we use return m_buildersForGenerator[CMakeBuilderSettings::self()->generator()]; } #include "cmakebuilder.moc" diff --git a/projectbuilders/cmakebuilder/configureandbuildjob.cpp b/projectbuilders/cmakebuilder/configureandbuildjob.cpp deleted file mode 100644 index 49c6e1da27..0000000000 --- a/projectbuilders/cmakebuilder/configureandbuildjob.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * This file is part of KDevelop * - * Copyright 2007 Andreas Pakulat * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "configureandbuildjob.h" - -#include -#include -#include -#include -#include - -ConfigureAndBuildJob::ConfigureAndBuildJob( KJob* configureJob, KJob* buildJob ) -{ - addSubjob( configureJob ); - addSubjob( buildJob ); - setObjectName(i18n("'%1' + '%2'", configureJob->objectName(), buildJob->objectName())); - kDebug() << "added job" << hasSubjobs(); -} - -void ConfigureAndBuildJob::start() -{ - // Automatically save all documents before starting to build - // might need an option to turn off at some point - // Also should be moved into the builder and there try to find target(s) for the given item and then just save the documents of that target -> list?? - KDevelop::ICore::self()->documentController()->saveAllDocuments( KDevelop::IDocument::Silent ); - - kDebug() << "configure and build, have subjobs?" << hasSubjobs(); - if(hasSubjobs()) - KDevelop::ICore::self()->runController()->registerJob( subjobs().first() ); - else - emitResult(); -} - -void ConfigureAndBuildJob::slotResult( KJob* job ) -{ - //call parent implementation for default behaviour - KCompositeJob::slotResult( job ); - if( !error() && hasSubjobs() ) - { - // start next build; - KDevelop::ICore::self()->runController()->registerJob( subjobs().first() ); - } else - { - emitResult(); - } -} -#include "configureandbuildjob.moc" diff --git a/projectbuilders/cmakebuilder/configureandbuildjob.h b/projectbuilders/cmakebuilder/configureandbuildjob.h index 325ee62190..e69de29bb2 100644 --- a/projectbuilders/cmakebuilder/configureandbuildjob.h +++ b/projectbuilders/cmakebuilder/configureandbuildjob.h @@ -1,37 +0,0 @@ -/*************************************************************************** - * This file is part of KDevelop * - * Copyright 2009 Andreas Pakulat * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef CONFIGUREANDBUILDJOB_H -#define CONFIGUREANDBUILDJOB_H - -#include - -class ConfigureAndBuildJob : public KCompositeJob -{ - Q_OBJECT -public: - ConfigureAndBuildJob( KJob* configureJob, KJob* buildJob ); - void start(); -private: - void slotResult( KJob* ); -}; - -#endif -