RedPanda-CPP/RedPandaIDE/compiler/compiler.h

74 lines
1.9 KiB
C
Raw Normal View History

2021-04-20 22:24:33 +08:00
#ifndef COMPILER_H
#define COMPILER_H
#include <QThread>
#include "settings.h"
2021-04-24 15:57:45 +08:00
#include "../common.h"
2021-04-20 22:24:33 +08:00
class Compiler : public QThread
{
Q_OBJECT
public:
enum class TargetType {
Invalid,
cttNone,
File,
Project,
StdIn
};
2021-06-24 20:43:09 +08:00
Compiler(const QString& filename, bool silent,bool onlyCheckSyntax);
2021-04-20 22:24:33 +08:00
2021-06-25 12:40:11 +08:00
bool isRebuild() const;
void setRebuild(bool isRebuild);
2021-04-20 22:24:33 +08:00
signals:
void compileStarted();
void compileFinished();
void compileOutput(const QString& msg);
2021-04-24 15:57:45 +08:00
void compileIssue(PCompileIssue issue);
void compileErrorOccured(const QString& reason);
2021-04-20 22:24:33 +08:00
public slots:
void stopCompile();
protected:
void run() override;
2021-04-24 15:57:45 +08:00
void processOutput(QString& line);
virtual QString getFileNameFromOutputLine(QString &line);
virtual int getLineNumberFromOutputLine(QString &line);
virtual int getColunmnFromOutputLine(QString &line);
virtual CompileIssueType getIssueTypeFromOutputLine(QString &line);
2021-04-20 22:24:33 +08:00
protected:
virtual Settings::PCompilerSet compilerSet() = 0;
virtual bool prepareForCompile() = 0;
2021-06-24 20:43:09 +08:00
virtual QString pipedText() = 0;
2021-06-25 12:40:11 +08:00
virtual bool prepareForRebuild() = 0;
2021-04-20 22:24:33 +08:00
virtual QString getCharsetArgument(const QByteArray& encoding);
virtual QString getCCompileArguments(bool checkSyntax);
virtual QString getCppCompileArguments(bool checkSyntax);
virtual QString getCIncludeArguments();
virtual QString getCppIncludeArguments();
virtual QString getLibraryArguments();
void log(const QString& msg);
void error(const QString& msg);
void runCommand(const QString& cmd, const QString& arguments, const QString& workingDir, const QString& inputText=QString());
protected:
bool mSilent;
bool mOnlyCheckSyntax;
QString mCompiler;
QString mArguments;
QString mOutputFile;
2021-04-24 15:57:45 +08:00
int mErrorCount;
int mWarningCount;
PCompileIssue mLastIssue;
2021-06-24 20:43:09 +08:00
QString mFilename;
2021-06-25 12:40:11 +08:00
bool mRebuild;
2021-04-20 22:24:33 +08:00
private:
bool mStop;
};
2021-04-20 22:24:33 +08:00
#endif // COMPILER_H