File indexing completed on 2024-05-12 04:38:11

0001 /*
0002     SPDX-FileCopyrightText: 2006 Matt Rogers <mattr@kde.org>
0003     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
0004     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVPLATFORM_IBUILDSYSTEMMANAGER_H
0010 #define KDEVPLATFORM_IBUILDSYSTEMMANAGER_H
0011 
0012 #include "iprojectfilemanager.h"
0013 
0014 #include <project/projectexport.h>
0015 
0016 namespace KDevelop
0017 {
0018 
0019 class IProjectBuilder;
0020 class ProjectTargetItem;
0021 /**
0022  * Manages the build system of the project.
0023  *
0024  * Use/Implement the IProjectFileManager interface to manage files.
0025  *
0026  * @author Matt Rogers <mattr@kde.org>, Hamish Rodda <rodda@kde.org>
0027  */
0028 class KDEVPLATFORMPROJECT_EXPORT IBuildSystemManager : public virtual IProjectFileManager
0029 {
0030 public:
0031 
0032     ~IBuildSystemManager() override;
0033 
0034     enum BuildFeature
0035     {
0036         Includes /**< This project supports passing include directives to the compiler */,
0037         Defines  /**< This project supports passing preprocessor defines to compiler */
0038     };
0039     Q_DECLARE_FLAGS( BuildFeatures, BuildFeature )
0040 
0041     /**
0042      * Provide access to the builder. This method never returns
0043      * null, if it does that is a bug in the plugin. A BuildSystemManager
0044      * always has a project builder associated with it.
0045      */
0046     virtual IProjectBuilder* builder() const = 0;
0047 
0048     /**
0049      * Provide a list of include directories.
0050      */
0051     virtual Path::List includeDirectories(ProjectBaseItem*) const = 0;
0052 
0053     /**
0054      * Provide a list of framework directories.
0055      */
0056     virtual Path::List frameworkDirectories(ProjectBaseItem*) const = 0;
0057 
0058     /**
0059      * Provide a list of preprocessor defines for the project item
0060      */
0061     virtual QHash<QString,QString> defines(ProjectBaseItem*) const = 0;
0062 
0063     /**
0064      * Create a new target
0065      *
0066      * Creates the target specified by @p target to the folder @p parent and
0067      * modifies the underlying build system if needed
0068      */
0069     virtual ProjectTargetItem* createTarget(const QString& target, ProjectFolderItem *parent) = 0;
0070 
0071     /**
0072      * Remove a target
0073      *
0074      * Removes the target specified by @p target and
0075      * modifies the underlying build system if needed.
0076      */
0077     virtual bool removeTarget(ProjectTargetItem *target) = 0;
0078 
0079     /**
0080      * Get a list of all the targets in this project
0081      *
0082      * The list returned by this function should be checked to verify it is not
0083      * empty before using it
0084      *
0085      * @return The list of targets for this project
0086      * @todo implement
0087      */
0088     virtual QList<ProjectTargetItem*> targets(ProjectFolderItem*) const = 0;
0089 
0090     /**
0091      * Add a file to a target
0092      *
0093      * Adds the file specified by @p file to the target @p parent and modifies
0094      * the underlying build system if needed.
0095      */
0096     virtual bool addFilesToTarget(const QList<ProjectFileItem*> &files, ProjectTargetItem *target) = 0;
0097 
0098     /**
0099      * Remove files from targets
0100      *
0101      * Removes the files from the targets they are paired with (@p targetFiles)
0102      * Files are not removed from the folders or the filesystem.
0103      */
0104     virtual bool removeFilesFromTargets(const QList<KDevelop::ProjectFileItem*> &files) = 0;
0105 
0106     /**
0107      * Returns if the build system has information specific to @p item
0108      */
0109     virtual bool hasBuildInfo(ProjectBaseItem* item) const = 0;
0110 
0111     /**
0112      * Get the toplevel build directory for the project
0113      */
0114     virtual Path buildDirectory(ProjectBaseItem*) const = 0;
0115 
0116     /**
0117      * @returns the extra arguments that will be passed to the compiler when building @p item
0118      */
0119     virtual QString extraArguments(ProjectBaseItem* item) const = 0;
0120 
0121     /**
0122      * @returns the absolute path to the tool that will be used or an empty path if unknown
0123      */
0124     virtual Path compiler(KDevelop::ProjectTargetItem* p) const = 0;
0125 };
0126 
0127 Q_DECLARE_OPERATORS_FOR_FLAGS(IBuildSystemManager::BuildFeatures)
0128 }
0129 
0130 Q_DECLARE_INTERFACE( KDevelop::IBuildSystemManager, "org.kdevelop.IBuildSystemManager" )
0131 
0132 #endif