File indexing completed on 2024-04-28 04:37:03
0001 /* 0002 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_BUILDERJOB_H 0008 #define KDEVPLATFORM_BUILDERJOB_H 0009 0010 #include "projectexport.h" 0011 0012 #include <util/executecompositejob.h> 0013 0014 namespace KDevelop 0015 { 0016 class ProjectBaseItem; 0017 class IProject; 0018 class BuilderJobPrivate; 0019 0020 /** 0021 * Allows to build a list of project items or projects sequentially, where 0022 * failing to build one item in the list will fail the whole job. 0023 */ 0024 class KDEVPLATFORMPROJECT_EXPORT BuilderJob : public ExecuteCompositeJob 0025 { 0026 Q_OBJECT 0027 public: 0028 /** 0029 * Defines what action to do on the Project builder 0030 */ 0031 enum BuildType 0032 { 0033 Build /**< Build the selected items */, 0034 Prune /**< Prune the selected items */, 0035 Configure /**< Configure the selected items */, 0036 Install /**< Install the selected items */, 0037 Clean /**< Clean the selected items */ 0038 }; 0039 0040 /** 0041 * Creates a Builder job 0042 */ 0043 BuilderJob(); 0044 0045 ~BuilderJob() override; 0046 0047 /** 0048 * Allows to easily schedule building a couple of @p items using the 0049 * method identified by @p type 0050 * 0051 * @param type the build method to use 0052 * @param items the project items to add 0053 */ 0054 void addItems( BuildType type, const QList<KDevelop::ProjectBaseItem*>& items ); 0055 0056 /** 0057 * Allows to easily schedule building a couple of @p projects using the 0058 * method identified by @p type 0059 * 0060 * @param type the build method to use 0061 * @param projects the projects to add 0062 */ 0063 void addProjects( BuildType type, const QList<KDevelop::IProject*>& projects ); 0064 0065 /** 0066 * Allows to add a single @p item to the end of the list. The item will be 0067 * built using the method identified by @p type 0068 * 0069 * @param item The item to add to the list 0070 * @param type The build method to be used for the item 0071 */ 0072 void addItem( BuildType type, ProjectBaseItem* item ); 0073 0074 /** 0075 * Allows to add a custom @p job to the end of the list. The build method specified by @p type 0076 * and (optionally) an item specified by @p item are needed to create a human-readable job name. 0077 * 0078 * @param type The build method which is represented by the @p job 0079 * @param job The job to add to the list 0080 * @param item The item which is build by the @p job 0081 */ 0082 void addCustomJob( BuildType type, KJob* job, ProjectBaseItem* item = nullptr ); 0083 0084 /** 0085 * Updates the job's name. 0086 * 0087 * Shall be called before registering this job in the run controller, but after 0088 * adding all required tasks to the job. 0089 */ 0090 void updateJobName(); 0091 0092 /** 0093 * Starts this job 0094 */ 0095 void start() override; 0096 0097 private: 0098 const QScopedPointer<class BuilderJobPrivate> d_ptr; 0099 Q_DECLARE_PRIVATE(BuilderJob) 0100 friend class BuilderJobPrivate; 0101 }; 0102 0103 } 0104 0105 #endif