2021-04-20 22:24:33 +08:00
|
|
|
#ifndef COMPILERMANAGER_H
|
|
|
|
#define COMPILERMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QMutex>
|
2021-06-21 11:21:26 +08:00
|
|
|
#include "../utils.h"
|
2021-04-20 22:24:33 +08:00
|
|
|
|
2021-04-21 18:58:35 +08:00
|
|
|
class ExecutableRunner;
|
|
|
|
class Compiler;
|
2021-04-20 22:24:33 +08:00
|
|
|
class CompilerManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit CompilerManager(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
bool compiling();
|
|
|
|
bool backgroundSyntaxChecking();
|
|
|
|
|
|
|
|
void compile(const QString& filename, const QByteArray& encoding, bool silent=false,bool onlyCheckSyntax=false);
|
2021-04-21 18:58:35 +08:00
|
|
|
void run(const QString& filename, const QString& arguments, const QString& workDir);
|
|
|
|
bool canCompile(const QString& filename);
|
2021-04-20 22:24:33 +08:00
|
|
|
private slots:
|
|
|
|
void onCompileFinished();
|
2021-04-21 18:58:35 +08:00
|
|
|
void onRunnerTerminated();
|
2021-04-20 22:24:33 +08:00
|
|
|
private:
|
|
|
|
Compiler* mCompiler;
|
|
|
|
Compiler* mBackgroundSyntaxChecker;
|
2021-04-21 18:58:35 +08:00
|
|
|
ExecutableRunner* mRunner;
|
2021-04-20 22:24:33 +08:00
|
|
|
QMutex compileMutex;
|
|
|
|
QMutex backgroundSyntaxChekMutex;
|
2021-04-21 18:58:35 +08:00
|
|
|
QMutex runnerMutex;
|
2021-04-20 22:24:33 +08:00
|
|
|
};
|
|
|
|
|
2021-06-21 11:21:26 +08:00
|
|
|
class CompileError : public BaseError {
|
|
|
|
public:
|
|
|
|
explicit CompileError(const QString& reason);
|
|
|
|
};
|
|
|
|
|
2021-04-20 22:24:33 +08:00
|
|
|
#endif // COMPILERMANAGER_H
|