streamline codes
This commit is contained in:
parent
08693b81ec
commit
72883cf8fb
|
@ -36,9 +36,8 @@
|
||||||
|
|
||||||
#define COMPILE_PROCESS_END "---//END//----"
|
#define COMPILE_PROCESS_END "---//END//----"
|
||||||
|
|
||||||
Compiler::Compiler(const QString &filename, bool silent, bool onlyCheckSyntax):
|
Compiler::Compiler(const QString &filename, bool onlyCheckSyntax):
|
||||||
QThread(),
|
QThread(),
|
||||||
mSilent(silent),
|
|
||||||
mOnlyCheckSyntax(onlyCheckSyntax),
|
mOnlyCheckSyntax(onlyCheckSyntax),
|
||||||
mFilename(filename),
|
mFilename(filename),
|
||||||
mRebuild(false),
|
mRebuild(false),
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
Project,
|
Project,
|
||||||
StdIn
|
StdIn
|
||||||
};
|
};
|
||||||
Compiler(const QString& filename, bool silent,bool onlyCheckSyntax);
|
Compiler(const QString& filename, bool onlyCheckSyntax);
|
||||||
Compiler(const Compiler&)=delete;
|
Compiler(const Compiler&)=delete;
|
||||||
Compiler& operator=(const Compiler&)=delete;
|
Compiler& operator=(const Compiler&)=delete;
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ protected:
|
||||||
void runCommand(const QString& cmd, const QString& arguments, const QString& workingDir, const QByteArray& inputText=QByteArray(), const QString& outputFile=QString());
|
void runCommand(const QString& cmd, const QString& arguments, const QString& workingDir, const QByteArray& inputText=QByteArray(), const QString& outputFile=QString());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool mSilent;
|
|
||||||
bool mOnlyCheckSyntax;
|
bool mOnlyCheckSyntax;
|
||||||
QString mCompiler;
|
QString mCompiler;
|
||||||
QString mArguments;
|
QString mArguments;
|
||||||
|
|
|
@ -92,10 +92,10 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
|
||||||
//deleted when thread finished
|
//deleted when thread finished
|
||||||
#ifdef ENABLE_SDCC
|
#ifdef ENABLE_SDCC
|
||||||
if (pSettings->compilerSets().defaultSet()->compilerType()==CompilerType::SDCC) {
|
if (pSettings->compilerSets().defaultSet()->compilerType()==CompilerType::SDCC) {
|
||||||
mCompiler = new SDCCFileCompiler(filename,encoding,compileType);
|
mCompiler = new SDCCFileCompiler(filename,encoding,compileType,false);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
mCompiler = new FileCompiler(filename,encoding,compileType,false,false);
|
mCompiler = new FileCompiler(filename,encoding,compileType,false);
|
||||||
mCompiler->setRebuild(rebuild);
|
mCompiler->setRebuild(rebuild);
|
||||||
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
|
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
|
||||||
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
|
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
|
||||||
|
@ -126,7 +126,7 @@ void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebu
|
||||||
mCompileErrorCount = 0;
|
mCompileErrorCount = 0;
|
||||||
mCompileIssueCount = 0;
|
mCompileIssueCount = 0;
|
||||||
//deleted when thread finished
|
//deleted when thread finished
|
||||||
mCompiler = new ProjectCompiler(project,false,false);
|
mCompiler = new ProjectCompiler(project,false);
|
||||||
mCompiler->setRebuild(rebuild);
|
mCompiler->setRebuild(rebuild);
|
||||||
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
|
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
|
||||||
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
|
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
|
||||||
|
@ -158,7 +158,7 @@ void CompilerManager::cleanProject(std::shared_ptr<Project> project)
|
||||||
mCompileErrorCount = 0;
|
mCompileErrorCount = 0;
|
||||||
mCompileIssueCount = 0;
|
mCompileIssueCount = 0;
|
||||||
//deleted when thread finished
|
//deleted when thread finished
|
||||||
ProjectCompiler* compiler = new ProjectCompiler(project,false,false);
|
ProjectCompiler* compiler = new ProjectCompiler(project,false);
|
||||||
compiler->setOnlyClean(true);
|
compiler->setOnlyClean(true);
|
||||||
mCompiler = compiler;
|
mCompiler = compiler;
|
||||||
mCompiler->setRebuild(false);
|
mCompiler->setRebuild(false);
|
||||||
|
@ -189,7 +189,7 @@ void CompilerManager::buildProjectMakefile(std::shared_ptr<Project> project)
|
||||||
if (mCompiler!=nullptr) {
|
if (mCompiler!=nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProjectCompiler compiler(project,false,false);
|
ProjectCompiler compiler(project,false);
|
||||||
compiler.buildMakeFile();
|
compiler.buildMakeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ void CompilerManager::checkSyntax(const QString &filename, const QByteArray& enc
|
||||||
mSyntaxCheckIssueCount = 0;
|
mSyntaxCheckIssueCount = 0;
|
||||||
|
|
||||||
//deleted when thread finished
|
//deleted when thread finished
|
||||||
mBackgroundSyntaxChecker = new StdinCompiler(filename,encoding, content,true,true);
|
mBackgroundSyntaxChecker = new StdinCompiler(filename,encoding, content,true);
|
||||||
mBackgroundSyntaxChecker->setProject(project);
|
mBackgroundSyntaxChecker->setProject(project);
|
||||||
connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater);
|
connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater);
|
||||||
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue);
|
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue);
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include "../utils.h"
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
class Runner;
|
class Runner;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
#include "filecompiler.h"
|
#include "filecompiler.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "../mainwindow.h"
|
|
||||||
#include "compilermanager.h"
|
#include "compilermanager.h"
|
||||||
#include "qsynedit/syntaxer/asm.h"
|
#include "qsynedit/syntaxer/asm.h"
|
||||||
#include "../systemconsts.h"
|
#include "../systemconsts.h"
|
||||||
|
@ -27,8 +26,8 @@
|
||||||
|
|
||||||
|
|
||||||
FileCompiler::FileCompiler(const QString &filename, const QByteArray &encoding,
|
FileCompiler::FileCompiler(const QString &filename, const QByteArray &encoding,
|
||||||
CppCompileType compileType,bool silent,bool onlyCheckSyntax):
|
CppCompileType compileType, bool onlyCheckSyntax):
|
||||||
Compiler(filename, silent,onlyCheckSyntax),
|
Compiler(filename, onlyCheckSyntax),
|
||||||
mEncoding(encoding),
|
mEncoding(encoding),
|
||||||
mCompileType(compileType)
|
mCompileType(compileType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ class FileCompiler : public Compiler
|
||||||
public:
|
public:
|
||||||
FileCompiler(const QString& filename, const QByteArray& encoding,
|
FileCompiler(const QString& filename, const QByteArray& encoding,
|
||||||
CppCompileType compileType,
|
CppCompileType compileType,
|
||||||
bool silent,bool onlyCheckSyntax);
|
bool onlyCheckSyntax);
|
||||||
FileCompiler(const FileCompiler&)=delete;
|
FileCompiler(const FileCompiler&)=delete;
|
||||||
FileCompiler& operator=(const FileCompiler&)=delete;
|
FileCompiler& operator=(const FileCompiler&)=delete;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
ProjectCompiler::ProjectCompiler(std::shared_ptr<Project> project, bool silent, bool onlyCheckSyntax):
|
ProjectCompiler::ProjectCompiler(std::shared_ptr<Project> project, bool onlyCheckSyntax):
|
||||||
Compiler("",silent,onlyCheckSyntax),
|
Compiler("",onlyCheckSyntax),
|
||||||
mOnlyClean(false)
|
mOnlyClean(false)
|
||||||
{
|
{
|
||||||
setProject(project);
|
setProject(project);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ProjectCompiler : public Compiler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProjectCompiler(std::shared_ptr<Project> project, bool silent,bool onlyCheckSyntax);
|
ProjectCompiler(std::shared_ptr<Project> project, bool onlyCheckSyntax);
|
||||||
ProjectCompiler(const ProjectCompiler&)=delete;
|
ProjectCompiler(const ProjectCompiler&)=delete;
|
||||||
ProjectCompiler& operator=(const ProjectCompiler&)=delete;
|
ProjectCompiler& operator=(const ProjectCompiler&)=delete;
|
||||||
void buildMakeFile();
|
void buildMakeFile();
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
|
|
||||||
SDCCFileCompiler::SDCCFileCompiler(const QString &filename, const QByteArray &encoding,
|
SDCCFileCompiler::SDCCFileCompiler(const QString &filename, const QByteArray &encoding,
|
||||||
CppCompileType compileType):
|
CppCompileType compileType, bool onlyCheckSyntax):
|
||||||
Compiler(filename, false,false),
|
Compiler(filename, onlyCheckSyntax),
|
||||||
mEncoding(encoding),
|
mEncoding(encoding),
|
||||||
mCompileType(compileType),
|
mCompileType(compileType),
|
||||||
mNoStartup(false)
|
mNoStartup(false)
|
||||||
|
@ -36,7 +36,17 @@ SDCCFileCompiler::SDCCFileCompiler(const QString &filename, const QByteArray &en
|
||||||
|
|
||||||
bool SDCCFileCompiler::prepareForCompile()
|
bool SDCCFileCompiler::prepareForCompile()
|
||||||
{
|
{
|
||||||
compilerSet()->setCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable);
|
//compilerSet()->setCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable);
|
||||||
|
|
||||||
|
if (mOnlyCheckSyntax) {
|
||||||
|
mCompiler = compilerSet()->CCompiler();
|
||||||
|
mArguments += getCCompileArguments(false);
|
||||||
|
mArguments += getCIncludeArguments();
|
||||||
|
mArguments += getProjectIncludeArguments();
|
||||||
|
mArguments = QString("--syntax-only \"%1\"").arg(mFilename);
|
||||||
|
mDirectory = extractFileDir(mFilename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
log(tr("Compiling single file..."));
|
log(tr("Compiling single file..."));
|
||||||
log("------------------");
|
log("------------------");
|
||||||
log(tr("- Filename: %1").arg(mFilename));
|
log(tr("- Filename: %1").arg(mFilename));
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SDCCFileCompiler : public Compiler
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SDCCFileCompiler(const QString& filename, const QByteArray& encoding,
|
SDCCFileCompiler(const QString& filename, const QByteArray& encoding,
|
||||||
CppCompileType compileType);
|
CppCompileType compileType, bool onlyCheckSyntax);
|
||||||
SDCCFileCompiler(const SDCCFileCompiler&)=delete;
|
SDCCFileCompiler(const SDCCFileCompiler&)=delete;
|
||||||
SDCCFileCompiler& operator=(const SDCCFileCompiler&)=delete;
|
SDCCFileCompiler& operator=(const SDCCFileCompiler&)=delete;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
StdinCompiler::StdinCompiler(const QString &filename,const QByteArray& encoding, const QString& content,bool silent, bool onlyCheckSyntax):
|
StdinCompiler::StdinCompiler(const QString &filename,const QByteArray& encoding, const QString& content, bool onlyCheckSyntax):
|
||||||
Compiler(filename,silent, onlyCheckSyntax),
|
Compiler(filename, onlyCheckSyntax),
|
||||||
mContent(content),
|
mContent(content),
|
||||||
mEncoding(encoding)
|
mEncoding(encoding)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ class StdinCompiler : public Compiler
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StdinCompiler(const QString& filename, const QByteArray& encoding, const QString& content, bool silent,bool onlyCheckSyntax);
|
explicit StdinCompiler(const QString& filename, const QByteArray& encoding, const QString& content, bool onlyCheckSyntax);
|
||||||
StdinCompiler(const StdinCompiler&)=delete;
|
StdinCompiler(const StdinCompiler&)=delete;
|
||||||
StdinCompiler& operator=(const StdinCompiler&)=delete;
|
StdinCompiler& operator=(const StdinCompiler&)=delete;
|
||||||
|
|
||||||
|
|
|
@ -3018,9 +3018,13 @@ bool Settings::CompilerSets::addSets(const QString &folder, const QString& c_pro
|
||||||
PCompilerSet baseSet = addSet(folder,c_prog);
|
PCompilerSet baseSet = addSet(folder,c_prog);
|
||||||
if (!baseSet || baseSet->name().isEmpty())
|
if (!baseSet || baseSet->name().isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
#if ENABLE_SDCC
|
||||||
if (c_prog == SDCC_PROGRAM) {
|
if (c_prog == SDCC_PROGRAM) {
|
||||||
//sdcc do nothing
|
baseSet->setCompileOption(SDCC_OPT_NOSTARTUP,COMPILER_OPTION_ON);
|
||||||
} else {
|
} else {
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
QString baseName = baseSet->name();
|
QString baseName = baseSet->name();
|
||||||
QString platformName;
|
QString platformName;
|
||||||
if (isTarget64Bit(baseSet->target())) {
|
if (isTarget64Bit(baseSet->target())) {
|
||||||
|
|
Loading…
Reference in New Issue