1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/************************************************************************
* KDevelop4 Custom Buildsystem Support *
* *
* Copyright 2010 Andreas Pakulat <apaku@gmx.de> *
* *
* 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 or version 3 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, see <http://www.gnu.org/licenses/>. *
************************************************************************/
#include "custombuildsystemplugin.h"
#include <KPluginFactory>
#include <KLocalizedString>
#include <project/projectmodel.h>
#include <interfaces/iproject.h>
#include "configconstants.h"
#include "kcm_custombuildsystem.h"
#include "custombuildjob.h"
using KDevelop::ProjectTargetItem;
using KDevelop::ProjectFolderItem;
using KDevelop::ProjectBuildFolderItem;
using KDevelop::ProjectBaseItem;
using KDevelop::ProjectFileItem;
using KDevelop::IPlugin;
using KDevelop::ICore;
using KDevelop::IOutputView;
using KDevelop::IProjectFileManager;
using KDevelop::IProjectBuilder;
using KDevelop::IProject;
using KDevelop::Path;
K_PLUGIN_FACTORY_WITH_JSON(CustomBuildSystemFactory, "kdevcustombuildsystem.json", registerPlugin<CustomBuildSystem>(); )
CustomBuildSystem::CustomBuildSystem( QObject *parent, const QVariantList & )
: AbstractFileManagerPlugin( QStringLiteral("kdevcustombuildsystem"), parent )
{
}
CustomBuildSystem::~CustomBuildSystem()
{
}
bool CustomBuildSystem::addFilesToTarget( const QList<ProjectFileItem*>&, ProjectTargetItem* )
{
return false;
}
bool CustomBuildSystem::hasBuildInfo( ProjectBaseItem* ) const
{
return false;
}
KJob* CustomBuildSystem::build( ProjectBaseItem* dom )
{
return new CustomBuildJob( this, dom, CustomBuildSystemTool::Build );
}
Path CustomBuildSystem::buildDirectory( ProjectBaseItem* item ) const
{
Path p;
if( item->folder() ) {
p = item->path();
} else {
ProjectBaseItem* parent = item;
while( !parent->folder() ) {
parent = parent->parent();
}
p = parent->path();
}
const QString relative = item->project()->path().relativePath(p);
KConfigGroup grp = configuration( item->project() );
if(!grp.isValid()) {
return Path();
}
Path builddir(grp.readEntry(ConfigConstants::buildDirKey(), QUrl()));
if(!builddir.isValid() ) // set builddir to default if project contains a buildDirKey that does not have a value
{
builddir = item->project()->path();
}
builddir.addPath( relative );
return builddir;
}
IProjectBuilder* CustomBuildSystem::builder() const
{
return const_cast<IProjectBuilder*>(dynamic_cast<const IProjectBuilder*>(this));
}
KJob* CustomBuildSystem::clean( ProjectBaseItem* dom )
{
return new CustomBuildJob( this, dom, CustomBuildSystemTool::Clean );
}
KJob* CustomBuildSystem::configure( IProject* project )
{
return new CustomBuildJob( this, project->projectItem(), CustomBuildSystemTool::Configure );
}
ProjectTargetItem* CustomBuildSystem::createTarget( const QString&, ProjectFolderItem* )
{
return nullptr;
}
QHash<QString, QString> CustomBuildSystem::defines( ProjectBaseItem* ) const
{
return {};
}
IProjectFileManager::Features CustomBuildSystem::features() const
{
return IProjectFileManager::Files | IProjectFileManager::Folders;
}
ProjectFolderItem* CustomBuildSystem::createFolderItem( IProject* project,
const Path& path, ProjectBaseItem* parent )
{
return new ProjectBuildFolderItem( project, path, parent );
}
Path::List CustomBuildSystem::includeDirectories( ProjectBaseItem* ) const
{
return {};
}
Path::List CustomBuildSystem::frameworkDirectories( ProjectBaseItem* ) const
{
return {};
}
QString CustomBuildSystem::extraArguments(KDevelop::ProjectBaseItem*) const
{
return {};
}
KJob* CustomBuildSystem::install( KDevelop::ProjectBaseItem* item, const QUrl &installPrefix )
{
auto job = new CustomBuildJob( this, item, CustomBuildSystemTool::Install );
job->setInstallPrefix(installPrefix);
return job;
}
KJob* CustomBuildSystem::prune( IProject* project )
{
return new CustomBuildJob( this, project->projectItem(), CustomBuildSystemTool::Prune );
}
bool CustomBuildSystem::removeFilesFromTargets( const QList<ProjectFileItem*>& )
{
return false;
}
bool CustomBuildSystem::removeTarget( ProjectTargetItem* )
{
return false;
}
QList<ProjectTargetItem*> CustomBuildSystem::targets( ProjectFolderItem* ) const
{
return QList<ProjectTargetItem*>();
}
KConfigGroup CustomBuildSystem::configuration( IProject* project ) const
{
KConfigGroup grp = project->projectConfiguration()->group(ConfigConstants::customBuildSystemGroup());
if (grp.isValid() && grp.hasKey(ConfigConstants::currentConfigKey()))
return grp.group(grp.readEntry(ConfigConstants::currentConfigKey()));
else
return KConfigGroup();
}
int CustomBuildSystem::perProjectConfigPages() const
{
return 1;
}
KDevelop::ConfigPage* CustomBuildSystem::perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent)
{
if (number == 0) {
return new CustomBuildSystemKCModule(this, options, parent);
}
return nullptr;
}
KDevelop::Path CustomBuildSystem::compiler(KDevelop::ProjectTargetItem* item) const
{
Q_UNUSED(item);
return {};
}
#include "custombuildsystemplugin.moc"
|