This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
kdevkernelplugin.h
115 lines (98 loc) · 4.42 KB
/
kdevkernelplugin.h
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
/*
* Copyright (C) 2011, 2012 Alexandre Courbot <[email protected]>
*
* 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 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/>.
*/
#ifndef KDEVKERNELPLUGIN_H
#define KDEVKERNELPLUGIN_H
#include <project/interfaces/ibuildsystemmanager.h>
#include <project/interfaces/iprojectbuilder.h>
#include <project/abstractfilemanagerplugin.h>
#include <make/imakebuilder.h>
#include <QVariant>
#include <QSet>
#include <QMap>
#include <QHash>
#include <QDateTime>
class KJob;
class IMakeBuilder;
namespace KDevelop
{
class ProjectBaseItem;
class ProjectTargetItem;
class ProjectFileItem;
class ProjectFolderItem;
class IProject;
class Path;
}
struct ValidFilesList
{
QDateTime lastUpdate;
QSet<QString> validFiles;
};
class KDevKernelPlugin : public KDevelop::AbstractFileManagerPlugin, public KDevelop::IBuildSystemManager, public KDevelop::IProjectBuilder
{
Q_OBJECT
Q_INTERFACES(KDevelop::IProjectBuilder)
Q_INTERFACES(KDevelop::IProjectFileManager)
Q_INTERFACES(KDevelop::IBuildSystemManager)
private:
IMakeBuilder *_builder;
mutable QMap<KDevelop::IProject *, QMap<KUrl, ValidFilesList > > _validFiles;
mutable QMap<KDevelop::IProject *, QStringList> _machDirs;
mutable QMap<KDevelop::IProject *, QHash<QString, QString> > _defines;
/**
* Parse the given configuration file and set the kernel definitions accordingly.
*/
void parseDotConfig(KDevelop::IProject *project, const KUrl &dotconfig, QHash<QString, QString> &_defs);
/**
* Parse the Makefiles and build the list of files we need to include according
* to the definitions that have been parsed by parseDotConfig.
*/
void parseMakefile(const KUrl &dir, KDevelop::IProject *project) const;
public:
KDevKernelPlugin(QObject *parent, const QVariantList &args);
// AbstractFileManagerPlugin interface
virtual KDevelop::ProjectFolderItem *import(KDevelop::IProject *project);
// IBuildSystemManager interface
virtual KDevelop::IProjectBuilder *builder() const;
virtual KDevelop::Path::List includeDirectories(KDevelop::ProjectBaseItem *item) const;
virtual KUrl::List includeDirectories(KDevelop::IProject *project) const;
virtual QHash<QString, QString> defines(KDevelop::ProjectBaseItem *item) const;
virtual KDevelop::ProjectTargetItem *createTarget(const QString &target, KDevelop::ProjectFolderItem *parent);
virtual bool removeTarget(KDevelop::ProjectTargetItem *target);
virtual QList<KDevelop::ProjectTargetItem *> targets(KDevelop::ProjectFolderItem *item) const;
virtual bool addFilesToTarget(const QList<KDevelop::ProjectFileItem *> &files, KDevelop::ProjectTargetItem *target);
virtual bool removeFilesFromTargets(const QList<KDevelop::ProjectFileItem *> &files);
/**
* A file is valid if it belongs to the list of files that are enabled through the kernel configuration.
* A directory is valid if it contains any file we are interested in.
*/
virtual bool isValid(const KDevelop::Path &url, const bool isFolder, KDevelop::IProject *project) const;
virtual KDevelop::Path buildDirectory(KDevelop::ProjectBaseItem *item) const;
// IProjectBuilder interface
virtual KJob *install(KDevelop::ProjectBaseItem *project);
virtual KJob *build(KDevelop::ProjectBaseItem *project);
virtual KJob *clean(KDevelop::ProjectBaseItem *project);
virtual KJob *configure(KDevelop::IProject *project);
virtual KJob *prune(KDevelop::IProject *project);
virtual QList<KDevelop::IProjectBuilder *> additionalBuilderPlugins(KDevelop::IProject *project) const;
virtual KJob *createDotConfig(KDevelop::IProject *project);
protected:
virtual MakeVariables makeVarsForProject(KDevelop::IProject *project);
virtual KJob *jobForTarget(KDevelop::IProject *project, const QStringList &targets);
private slots:
virtual void projectClosing(KDevelop::IProject *project);
};
#endif