RedPanda-CPP/RedPandaIDE/compiler/compilermanager.h

66 lines
1.9 KiB
C
Raw Normal View History

2021-04-20 22:24:33 +08:00
#ifndef COMPILERMANAGER_H
#define COMPILERMANAGER_H
#include <QObject>
#include <QMutex>
#include "../utils.h"
#include "../common.h"
2021-04-20 22:24:33 +08:00
class ExecutableRunner;
class Compiler;
2021-09-12 22:45:00 +08:00
class Project;
2021-04-20 22:24:33 +08:00
class CompilerManager : public QObject
{
Q_OBJECT
public:
explicit CompilerManager(QObject *parent = nullptr);
bool compiling();
bool backgroundSyntaxChecking();
2021-06-25 12:40:11 +08:00
bool running();
2021-04-20 22:24:33 +08:00
2021-06-25 12:40:11 +08:00
void compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent=false,bool onlyCheckSyntax=false);
2021-09-13 22:45:50 +08:00
void compileProject(std::shared_ptr<Project> project, bool rebuild, bool silent=false,bool onlyCheckSyntax=false);
void cleanProject(std::shared_ptr<Project> project);
2021-09-17 19:58:37 +08:00
void buildProjectMakefile(std::shared_ptr<Project> project);
2021-09-12 22:45:00 +08:00
void checkSyntax(const QString&filename, const QString& content, bool isAscii, std::shared_ptr<Project> project);
void run(const QString& filename, const QString& arguments, const QString& workDir);
2021-06-25 12:40:11 +08:00
void stopRun();
void stopCompile();
void stopCheckSyntax();
bool canCompile(const QString& filename);
2021-06-23 22:38:02 +08:00
int compileErrorCount() const;
int syntaxCheckErrorCount() const;
int compileIssueCount() const;
int syntaxCheckIssueCount() const;
2021-04-20 22:24:33 +08:00
private slots:
void onRunnerTerminated();
2021-06-24 20:43:09 +08:00
void onCompileFinished();
void onCompileIssue(PCompileIssue issue);
2021-06-24 20:43:09 +08:00
void onSyntaxCheckFinished();
void onSyntaxCheckIssue(PCompileIssue issue);
2021-04-20 22:24:33 +08:00
private:
Compiler* mCompiler;
2021-06-23 22:38:02 +08:00
int mCompileErrorCount;
int mCompileIssueCount;
2021-06-23 22:38:02 +08:00
int mSyntaxCheckErrorCount;
int mSyntaxCheckIssueCount;
2021-04-20 22:24:33 +08:00
Compiler* mBackgroundSyntaxChecker;
ExecutableRunner* mRunner;
2021-06-25 12:40:11 +08:00
QMutex mCompileMutex;
QMutex mBackgroundSyntaxCheckMutex;
QMutex mRunnerMutex;
2021-04-20 22:24:33 +08:00
};
class CompileError : public BaseError {
public:
explicit CompileError(const QString& reason);
};
2021-04-20 22:24:33 +08:00
#endif // COMPILERMANAGER_H