diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 44f7b94295..63a977bba2 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,152 +1,153 @@ # BEGIN: Analyzers add_subdirectory(cppcheck) if(UNIX AND NOT (APPLE OR CYGWIN)) add_subdirectory(heaptrack) endif() # END: Analyzers # BEGIN: Debuggers if(NOT WIN32) # TODO: Make compile under Windows add_subdirectory(debuggercommon) add_subdirectory(lldb) add_subdirectory(gdb) endif() # END: Debuggers # BEGIN: Documentation find_package(Qt5Help CONFIG) set_package_properties(Qt5Help PROPERTIES PURPOSE "The Help module for the Qt toolkit, needed for the qthelp plugin" URL "https://www.qt.io/" TYPE OPTIONAL) if(Qt5Help_FOUND) ecm_optional_add_subdirectory(qthelp) endif() ecm_optional_add_subdirectory(manpage) # END: Documentation # BEGIN: Formatters add_subdirectory(astyle) add_subdirectory(customscript) # END: Formatters # BEGIN: Languages ecm_optional_add_subdirectory(custom-definesandincludes) ecm_optional_add_subdirectory(qmljs) find_package(Clang 3.8) set(clangSearchHint "") if (NOT CLANG_FOUND) set(clangSearchHint "Please install a package providing libclang. Either pass -DLLVM_ROOT=/path/to/llvm-prefix or install the 'llvm-config' command-line utility for auto-detection.") endif() set_package_properties(Clang PROPERTIES DESCRIPTION "Clang libraries from the LLVM project. ${clangSearchHint}" PURPOSE "Used for KDevelop's C++/C support plugin." TYPE REQUIRED ) if (CLANG_FOUND) if (NOT CLANG_LIBCLANG_LIB) message(FATAL_ERROR "Could not find the Clang C library: libclang") endif() ecm_optional_add_subdirectory(clang) endif() # END: Languages # BEGIN: Project builders add_subdirectory(makebuilder) add_subdirectory(ninjabuilder) ecm_optional_add_subdirectory(cmakebuilder) if (KDevelop-PG-Qt_FOUND) ecm_optional_add_subdirectory(qmakebuilder) endif() # END: Project builders # BEGIN: Project managers ecm_optional_add_subdirectory(cmake) ecm_optional_add_subdirectory(custommake) ecm_optional_add_subdirectory(custom-buildsystem) if (KDevelop-PG-Qt_FOUND) ecm_optional_add_subdirectory(qmakemanager) endif() ecm_optional_add_subdirectory(genericprojectmanager) # END: Project managers # BEGIN: Runtimes add_subdirectory(android) if (UNIX) add_subdirectory(docker) add_subdirectory(flatpak) endif() # END: Runtimes # BEGIN: VCS ecm_optional_add_subdirectory(bazaar) ecm_optional_add_subdirectory(cvs) ecm_optional_add_subdirectory(git) ecm_optional_add_subdirectory(perforce) find_package(SubversionLibrary) set_package_properties(SubversionLibrary PROPERTIES PURPOSE "Support for Subversion integration" URL "http://subversion.tigris.org" TYPE OPTIONAL) if(SubversionLibrary_FOUND) ecm_optional_add_subdirectory(subversion) endif() add_subdirectory(vcschangesview) # END: VCS # BEGIN: Others add_subdirectory(appwizard) add_subdirectory(codeutils) add_subdirectory(contextbrowser) add_subdirectory(documentswitcher) add_subdirectory(documentview) add_subdirectory(execute) add_subdirectory(executescript) add_subdirectory(externalscript) add_subdirectory(filemanager) add_subdirectory(filetemplates) add_subdirectory(grepview) add_subdirectory(openwith) add_subdirectory(outlineview) add_subdirectory(patchreview) add_subdirectory(problemreporter) add_subdirectory(projectfilter) add_subdirectory(projectmanagerview) add_subdirectory(quickopen) add_subdirectory(sourceformatter) add_subdirectory(standardoutputview) add_subdirectory(switchtobuddy) add_subdirectory(testview) +add_subdirectory(meson) ecm_optional_add_subdirectory(classbrowser) ecm_optional_add_subdirectory(executeplasmoid) ecm_optional_add_subdirectory(ghprovider) ecm_optional_add_subdirectory(kdeprovider) ecm_optional_add_subdirectory(konsole) if (Qt5QuickWidgets_FOUND) add_subdirectory(welcomepage) endif() find_package(OktetaKastenControllers 0.3.1) set_package_properties(OktetaKastenControllers PROPERTIES PURPOSE "Required for building Okteta KDevelop plugin." URL "http://kde.org/" TYPE OPTIONAL) if (OktetaKastenControllers_FOUND) find_package( KastenControllers ) set_package_properties(KastenControllers PROPERTIES PURPOSE "Required for building Okteta KDevelop plugin." URL "http://kde.org/" TYPE OPTIONAL) endif() if (OktetaKastenControllers_FOUND AND KastenControllers_FOUND) add_subdirectory(okteta) endif() # END: Others diff --git a/plugins/meson/CMakeLists.txt b/plugins/meson/CMakeLists.txt new file mode 100644 index 0000000000..9e16a4e711 --- /dev/null +++ b/plugins/meson/CMakeLists.txt @@ -0,0 +1,19 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"kdevmesonmanager\") + +ecm_qt_declare_logging_category(mesoncommon_LOG_SRCS + HEADER debug.h + IDENTIFIER KDEV_Meson + CATEGORY_NAME "kdevelop.plugins.meson" +) + +kdevplatform_add_plugin(kdevmesonmanager + JSON kdevmesonmanager.json + SOURCES mesonmanager.cpp mesonbuilder.cpp mesonconfig.cpp mesonimportjob.cpp) + +target_link_libraries(kdevmesonmanager + Qt5::Concurrent + KDev::Interfaces + KDev::Project + KDev::Util + KDev::OutputView +) diff --git a/plugins/meson/Messages.sh b/plugins/meson/Messages.sh new file mode 100644 index 0000000000..0a9213a91a --- /dev/null +++ b/plugins/meson/Messages.sh @@ -0,0 +1,4 @@ +#!/bin/sh +$EXTRACTRC `find . -name \*.rc -o -name \*.ui | grep -v '/tests/'` >>rc.cpp +$XGETTEXT `find . -name \*.cc -o -name \*.cpp -o -name \*.h | grep -v '/tests/'` -o $podir/kdevmesonmanager.pot +rm -f rc.cpp diff --git a/plugins/meson/kdevmesonmanager.json b/plugins/meson/kdevmesonmanager.json new file mode 100644 index 0000000000..9b22174942 --- /dev/null +++ b/plugins/meson/kdevmesonmanager.json @@ -0,0 +1,68 @@ +{ + "KPlugin": { + "Category": "Project Management", + "Description": "Imports and edits Meson projects", + "Description[ca@valencia]": "Importa i edita projectes del Meson", + "Description[ca]": "Importa i edita projectes del Meson", + "Description[cs]": "Importuje a upravuje vlastní projekty Meson", + "Description[de]": "Import und Bearbeitung von benutzerdefinierten Meson-Projekten", + "Description[es]": "Importa y edita proyectos Meson", + "Description[et]": "Meson'i projektide import ja muutmine", + "Description[fi]": "Tuo ja muokkaa Meson-projekteja", + "Description[fr]": "Importe et édite des projet Meson", + "Description[gl]": "Importa e edita proxectos Meson.", + "Description[it]": "Importa e modifica i progetti Meson", + "Description[nl]": "Importeert en bewerkt Meson-projecten", + "Description[pl]": "Importuje i edytuje projekty Meson", + "Description[pt]": "Importa e edita os projectos do Meson", + "Description[pt_BR]": "Importa e edita os projetos do Meson", + "Description[sk]": "Importuje a upravuje projekty Meson", + "Description[sl]": "Uvozi in ureja projekte po meri temelječe na Meson", + "Description[sv]": "Importerar och redigerar Meson-projekt", + "Description[tr]": "Meson projelerini içeriye aktarır ve düzenler", + "Description[uk]": "Імпортує і дає змогу редагувати проекти Meson", + "Description[x-test]": "xxImports and edits Meson projectsxx", + "Description[zh_CN]": "导入并编辑 Meson 工程", + "Icon": "qtlogo", + "Id": "KDevMesonManager", + "Name": "Meson Project Manager", + "Name[ca@valencia]": "Gestor de projectes Meson", + "Name[ca]": "Gestor de projectes Meson", + "Name[cs]": "Správce projektů Meson", + "Name[de]": "Meson-Projektverwaltung", + "Name[es]": "Gestor de proyectos Meson", + "Name[et]": "Meson'i projektihaldur", + "Name[fi]": "Meson-projektinhallinta", + "Name[fr]": "Gestionnaire de projet Meson", + "Name[gl]": "Xestor de proxectos Meson", + "Name[it]": "Gestore progetto Meson", + "Name[nl]": "Meson-projectbeheerder", + "Name[pl]": "Zarządzanie projektem Meson", + "Name[pt]": "Gestor de Projectos Meson", + "Name[pt_BR]": "Gerenciador de projetos do Meson", + "Name[sk]": "Správca projektov Meson", + "Name[sl]": "Upravljalnik projektov Meson", + "Name[sv]": "Meson-projekthantering", + "Name[tr]": "Meson Proje Yöneticisi", + "Name[uk]": "Керування проектами Meson", + "Name[x-test]": "xxMeson Project Managerxx", + "Name[zh_CN]": "Meson 工程管理器", + "ServiceTypes": [ + "KDevelop/Plugin" + ] + }, + "X-KDevelop-Category": "Project", + "X-KDevelop-FileManager": "Meson", + "X-KDevelop-IRequired": [ + "org.kdevelop.IMesonBuilder" + ], + "X-KDevelop-Interfaces": [ + "org.kdevelop.IBuildSystemManager", + "org.kdevelop.IProjectFileManager" + ], + "X-KDevelop-Mode": "NoGUI", + "X-KDevelop-ProjectFilesFilter": [ + "*.pro" + ], + "X-KDevelop-ProjectFilesFilterDescription": "Meson Project Files" +} diff --git a/plugins/meson/mesonbuilder.cpp b/plugins/meson/mesonbuilder.cpp new file mode 100644 index 0000000000..10297e1533 --- /dev/null +++ b/plugins/meson/mesonbuilder.cpp @@ -0,0 +1,71 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include "mesonbuilder.h" +#include "mesonconfig.h" + +MesonBuilder::MesonBuilder(QObject* parent) + : QObject(parent) +{ + auto p = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IProjectBuilder"), QStringLiteral("KDevNinjaBuilder")); + if (p) { + m_ninjaBuilder = p->extension(); + if (m_ninjaBuilder) { + connect(p, SIGNAL(built(KDevelop::ProjectBaseItem*)), this, + SIGNAL(built(KDevelop::ProjectBaseItem*))); + connect(p, SIGNAL(cleaned(KDevelop::ProjectBaseItem*)), this, + SIGNAL(cleaned(KDevelop::ProjectBaseItem*))); + connect(p, SIGNAL(installed(KDevelop::ProjectBaseItem*)), this, + SIGNAL(installed(KDevelop::ProjectBaseItem*))); + connect(p, SIGNAL(failed(KDevelop::ProjectBaseItem*)), this, + SIGNAL(failed(KDevelop::ProjectBaseItem*))); + connect(p, SIGNAL(makeTargetBuilt(KDevelop::ProjectBaseItem*,QString)), this, + SIGNAL(pruned(KDevelop::ProjectBaseItem*))); + } + } +} + +KJob * MesonBuilder::configure(KDevelop::IProject* project) +{ + auto job = new KDevelop::OutputExecuteJob(); + *job << "meson" << project->path().toLocalFile(); + job->setWorkingDirectory(Meson::buildDirectory(project)); + return job; +} + +KJob * MesonBuilder::build(KDevelop::ProjectBaseItem* item) +{ + //TODO: probably want to make sure it's configured first + return m_ninjaBuilder->install(item); +} + +KJob * MesonBuilder::clean(KDevelop::ProjectBaseItem* item) +{ + return m_ninjaBuilder->clean(item); +} + +KJob * MesonBuilder::install(KDevelop::ProjectBaseItem* dom, const QUrl& installPath) +{ + return m_ninjaBuilder->install(dom, installPath); +} diff --git a/plugins/meson/mesonbuilder.h b/plugins/meson/mesonbuilder.h new file mode 100644 index 0000000000..a4679e636f --- /dev/null +++ b/plugins/meson/mesonbuilder.h @@ -0,0 +1,42 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MESONBUILDER_H +#define MESONBUILDER_H + +#include + +class MesonBuilder : public QObject, public KDevelop::IProjectBuilder +{ + Q_OBJECT + Q_INTERFACES(KDevelop::IProjectBuilder) +public: + explicit MesonBuilder(QObject* parent); + + KJob* build(KDevelop::ProjectBaseItem* item) override; + KJob* clean(KDevelop::ProjectBaseItem* item) override; + KJob* install(KDevelop::ProjectBaseItem* dom, const QUrl& installPath) override; + + KJob* configure(KDevelop::IProject* project) override; + +private: + KDevelop::IProjectBuilder* m_ninjaBuilder = nullptr; +}; + +#endif // MESONBUILDER_H diff --git a/plugins/meson/mesonconfig.cpp b/plugins/meson/mesonconfig.cpp new file mode 100644 index 0000000000..343adec405 --- /dev/null +++ b/plugins/meson/mesonconfig.cpp @@ -0,0 +1,41 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "mesonconfig.h" +#include +#include +#include + +using namespace KDevelop; + +namespace Meson +{ + +KConfigGroup projectGroup(KDevelop::IProject* project) +{ + return project->projectConfiguration()->group(RootConfig); +} + +QUrl buildDirectory(KDevelop::IProject* project) +{ + KDevelop::IBuildSystemManager* bsm = project->buildSystemManager(); + return bsm->buildDirectory(project->projectItem()).toUrl(); +} + +} diff --git a/plugins/meson/mesonconfig.h b/plugins/meson/mesonconfig.h new file mode 100644 index 0000000000..eb5c376cd8 --- /dev/null +++ b/plugins/meson/mesonconfig.h @@ -0,0 +1,37 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MESONCONFIG_H +#define MESONCONFIG_H + +#include + +namespace KDevelop { class IProject; } + +//TODO: you probably want to be able to keep settings for different build directories +namespace Meson +{ + static const QString RootConfig = QStringLiteral("BuildDirecory"); + static const QString BuildDirectory = QStringLiteral("BuildDirecory"); + + KConfigGroup projectGroup(KDevelop::IProject* project); + QUrl buildDirectory(KDevelop::IProject* project); +} + +#endif diff --git a/plugins/meson/mesonimportjob.cpp b/plugins/meson/mesonimportjob.cpp new file mode 100644 index 0000000000..bcaf8f2c0b --- /dev/null +++ b/plugins/meson/mesonimportjob.cpp @@ -0,0 +1,77 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "mesonimportjob.h" +#include "mesonconfig.h" +#include "mesonmanager.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace KDevelop; + +MesonImportJob::MesonImportJob(MesonManager* manager, KDevelop::IProject* project, QObject* parent) + : KJob(parent) + , m_project(project) + , m_manager(manager) +{ + connect(&m_futureWatcher, &QFutureWatcher::finished, this, &MesonImportJob::importFinished); +} + +//TODO: probably want to process the object in this function (e.g. see CMakeImportJsonJob) +QJsonObject import(const KDevelop::Path &commandsFile, const KDevelop::Path &sourcePath, const KDevelop::Path &builddir) +{ + QFile f(commandsFile.toLocalFile()); + if (!f.open(QFile::ReadOnly)) { + return {}; + } + + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &error); + if (error.error) { + qDebug() << "error parsing" << commandsFile << error.errorString(); + return {}; + } + return doc.object(); +} + +void MesonImportJob::start() +{ + const Path currentBuildDir(Meson::buildDirectory(m_project)); + const Path commandsFile(currentBuildDir, QLatin1String("compile_commands.json")); + const auto sourceDir = m_project->path(); + + auto rt = ICore::self()->runtimeController()->currentRuntime(); + auto future = QtConcurrent::run(import, commandsFile, sourceDir, rt->pathInRuntime(currentBuildDir)); + m_futureWatcher.setFuture(future); +} + +void MesonImportJob::importFinished() +{ + auto future = m_futureWatcher.future(); + auto data = future.result(); + m_manager->setProjectData(m_project, data); +} diff --git a/plugins/meson/mesonimportjob.h b/plugins/meson/mesonimportjob.h new file mode 100644 index 0000000000..c451587ca4 --- /dev/null +++ b/plugins/meson/mesonimportjob.h @@ -0,0 +1,47 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MESONIMPORTJOB_H +#define MESONIMPORTJOB_H + +#include +#include +#include +#include + +class MesonManager; + +class MesonImportJob : public KJob +{ + Q_OBJECT + +public: + MesonImportJob(MesonManager* manager, KDevelop::IProject* project, QObject* parent); + + void start() override; + +private: + void importFinished(); + + KDevelop::IProject* m_project; + QFutureWatcher m_futureWatcher; + MesonManager* m_manager; +}; + +#endif // MESONIMPORTJOB_H diff --git a/plugins/meson/mesonmanager.cpp b/plugins/meson/mesonmanager.cpp new file mode 100644 index 0000000000..df1f0914e7 --- /dev/null +++ b/plugins/meson/mesonmanager.cpp @@ -0,0 +1,92 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "mesonmanager.h" +#include "mesonbuilder.h" +#include "mesonconfig.h" +#include "mesonimportjob.h" +#include +#include +#include + +#include +#include +#include +#include + +#include "debug.h" + +using namespace KDevelop; + +K_PLUGIN_FACTORY_WITH_JSON(MesonSupportFactory, "kdevmesonmanager.json", registerPlugin();) + +MesonManager::MesonManager( QObject* parent, const QVariantList& args ) + : AbstractFileManagerPlugin( QStringLiteral( "kdevmesonmanager" ), parent, args ) + , m_builder(new MesonBuilder(this)) +{ +} + +KJob * MesonManager::createImportJob(KDevelop::ProjectFolderItem* item) +{ + auto project = item->project(); + + auto job = new MesonImportJob(this, project, this); + connect(job, &KJob::result, this, [this, job, project](){ + if (job->error() != 0) { + qCWarning(KDEV_Meson) << "couldn't load project successfully" << project->name(); + m_projects.remove(project); + } + }); + + const QList jobs = { + builder()->configure(project), + job, + KDevelop::AbstractFileManagerPlugin::createImportJob(item) // generate the file system listing + }; + + Q_ASSERT(!jobs.contains(nullptr)); + auto composite = new KDevelop::ExecuteCompositeJob(this, jobs); +// even if the cmake call failed, we want to load the project so that the project can be worked on + composite->setAbortOnError(false); + return composite; +} + +KDevelop::Path MesonManager::buildDirectory(KDevelop::ProjectBaseItem* item) const +{ + KConfigGroup projectGroup = Meson::projectGroup(item->project()); + Path builddir(projectGroup.readEntry(Meson::BuildDirectory, QString())); + if (builddir.isEmpty()) { + const QString path = QFileDialog::getExistingDirectory(nullptr, i18n("Choose a build directory")); + builddir = Path(path); + projectGroup.writeEntry(Meson::BuildDirectory, path); + } + return builddir; +} + +KDevelop::IProjectBuilder * MesonManager::builder() const +{ + return m_builder; +} + +void MesonManager::setProjectData(KDevelop::IProject* project, const QJsonObject& data) +{ + m_projects[project] = data; +} + +#include "mesonmanager.moc" diff --git a/plugins/meson/mesonmanager.h b/plugins/meson/mesonmanager.h new file mode 100644 index 0000000000..366dba2cd5 --- /dev/null +++ b/plugins/meson/mesonmanager.h @@ -0,0 +1,64 @@ +/* This file is part of KDevelop + Copyright 2017 Aleix Pol Gonzalez + + This library 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 library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KDEVPLATFORM_PLUGIN_MESONMANAGER_H +#define KDEVPLATFORM_PLUGIN_MESONMANAGER_H + +#include +#include + +class MesonBuilder; + +class MesonManager: public KDevelop::AbstractFileManagerPlugin, public KDevelop::IBuildSystemManager +{ + Q_OBJECT + Q_INTERFACES( KDevelop::IBuildSystemManager ) + +public: + explicit MesonManager( QObject* parent = nullptr, const QVariantList& args = QVariantList() ); + + KDevelop::IProjectBuilder* builder() const override; + + KJob * createImportJob(KDevelop::ProjectFolderItem * item) override; + void setProjectData(KDevelop::IProject* project, const QJsonObject &data); + + // FIXME now: should use compile_commands.json for these (i.e. m_projects) + KDevelop::Path::List includeDirectories(KDevelop::ProjectBaseItem*) const override { return {}; } + KDevelop::Path::List frameworkDirectories(KDevelop::ProjectBaseItem*) const override { return {}; } + QHash defines(KDevelop::ProjectBaseItem*) const override { return {}; } + QString extraArguments(KDevelop::ProjectBaseItem* /*item*/) const override { return {}; } + bool hasBuildInfo(KDevelop::ProjectBaseItem* /*item*/) const override { return false; } + + KDevelop::Path buildDirectory(KDevelop::ProjectBaseItem*) const override; + + // fill if&when we have targets + QList targets(KDevelop::ProjectFolderItem*) const override { return {}; } + + // you can ignore these for now I guess, but TODO + KDevelop::ProjectTargetItem* createTarget(const QString& /*target*/, KDevelop::ProjectFolderItem */*parent*/) override { return nullptr; } + bool removeTarget(KDevelop::ProjectTargetItem */*target*/) override { return false; } + bool addFilesToTarget(const QList &/*files*/, KDevelop::ProjectTargetItem */*target*/) override { return false; } + bool removeFilesFromTargets(const QList &/*files*/) override { return false; } + +private: + MesonBuilder* m_builder; + QHash m_projects; +}; + +#endif