1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef BUILDMANAGER_H
6#define BUILDMANAGER_H
7
8#include "services/builder/builderglobals.h"
9#include "services/builder/task.h"
10#include "services/project/projectinfo.h"
11#include "common/widget/outputpane.h"
12
13#include <QObject>
14#include <QSharedPointer>
15#include <QMutex>
16
17namespace dpfservice {
18class WindowService;
19}
20
21class CompileOutputPane;
22class ProblemOutputPane;
23class BuildManagerPrivate;
24class BuildManager : public QObject
25{
26 Q_OBJECT
27public:
28 static BuildManager *instance();
29
30 CompileOutputPane *getCompileOutputPane() const;
31 ProblemOutputPane *getProblemOutputPane() const;
32
33 void setActivedProjectInfo(const QString &kitName, const QString &workingDir);
34 void clearActivedProjectInfo();
35
36 bool handleCommand(const QList<BuildCommandInfo> &info, bool isSynchronous);
37
38signals:
39 void sigOutputCompileInfo(const QString &content, const OutputPane::OutputFormat format);
40 void sigOutputProblemInfo(const QString &content);
41 void sigBuildState(const BuildState &buildstate);
42 void sigOutputNotify(const BuildState &state, const BuildCommandInfo &commandInfo);
43 void sigResetBuildUI();
44
45public slots:
46 void slotOutputCompileInfo(const QString &content, const OutputPane::OutputFormat format);
47 void slotOutputProblemInfo(const QString &content);
48 void addOutput(const QString &content, const OutputPane::OutputFormat format);
49 void buildProject();
50 void rebuildProject();
51 void cleanProject();
52 void cancelBuild();
53 void slotBuildState(const BuildState &buildstate);
54 void slotOutputNotify(const BuildState &state, const BuildCommandInfo &commandInfo);
55 void slotResetBuildUI();
56
57private:
58 explicit BuildManager(QObject *parent = nullptr);
59 virtual ~BuildManager();
60
61 void addMenu();
62
63 void outputLog(const QString &content, const OutputPane::OutputFormat format);
64 void outputError(const QString &content);
65 void outputNotify(const BuildState &state, const BuildCommandInfo &commandInfo);
66
67 bool execCommands(const QList<BuildCommandInfo> &commandList, bool isSynchronous);
68 bool execCommand(const BuildCommandInfo &info);
69
70 void execBuildStep(QList<BuildMenuType> menuTypelist);
71 void outBuildState(const BuildState &buildState);
72 bool canStartBuild();
73 void disconnectSignals();
74
75 QMutex releaseMutex;
76
77 BuildManagerPrivate *const d;
78};
79
80#endif // BUILDMANAGER_H
81
82