From 5bd1d92d53419f630dd44df5b8e73a19375b2129 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 20 Feb 2023 16:37:58 +0800 Subject: [PATCH] remove no use code --- RedPandaIDE/RedPandaIDE.pro | 4 - RedPandaIDE/codeformatter.cpp | 22 --- RedPandaIDE/codeformatter.h | 26 --- RedPandaIDE/compiler/xmakecompiler.cpp | 211 ------------------------- RedPandaIDE/compiler/xmakecompiler.h | 48 ------ 5 files changed, 311 deletions(-) delete mode 100644 RedPandaIDE/codeformatter.cpp delete mode 100644 RedPandaIDE/codeformatter.h delete mode 100644 RedPandaIDE/compiler/xmakecompiler.cpp delete mode 100644 RedPandaIDE/compiler/xmakecompiler.h diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 64b2d605..72050b95 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -81,13 +81,11 @@ LIBS += advapi32.lib user32.lib SOURCES += \ autolinkmanager.cpp \ caretlist.cpp \ - codeformatter.cpp \ codesnippetsmanager.cpp \ colorscheme.cpp \ compiler/compilerinfo.cpp \ compiler/ojproblemcasesrunner.cpp \ compiler/projectcompiler.cpp \ - compiler/xmakecompiler.cpp \ compiler/runner.cpp \ customfileiconprovider.cpp \ gdbmiresultparser.cpp \ @@ -218,7 +216,6 @@ HEADERS += \ SimpleIni.h \ autolinkmanager.h \ caretlist.h \ - codeformatter.h \ codesnippetsmanager.h \ colorscheme.h \ compiler/compiler.h \ @@ -226,7 +223,6 @@ HEADERS += \ compiler/compilermanager.h \ compiler/executablerunner.h \ compiler/filecompiler.h \ - compiler/xmakecompiler.h \ compiler/ojproblemcasesrunner.h \ compiler/projectcompiler.h \ compiler/runner.h \ diff --git a/RedPandaIDE/codeformatter.cpp b/RedPandaIDE/codeformatter.cpp deleted file mode 100644 index b02ebea2..00000000 --- a/RedPandaIDE/codeformatter.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "codeformatter.h" - -CodeFormatter::CodeFormatter() -{ - -} diff --git a/RedPandaIDE/codeformatter.h b/RedPandaIDE/codeformatter.h deleted file mode 100644 index aa80d614..00000000 --- a/RedPandaIDE/codeformatter.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef CODEFORMATTER_H -#define CODEFORMATTER_H - -class CodeFormatter -{ -public: - CodeFormatter(); -}; - -#endif // CODEFORMATTER_H diff --git a/RedPandaIDE/compiler/xmakecompiler.cpp b/RedPandaIDE/compiler/xmakecompiler.cpp deleted file mode 100644 index fecbc09e..00000000 --- a/RedPandaIDE/compiler/xmakecompiler.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "xmakecompiler.h" -#include "../project.h" -#include "compilermanager.h" -#include "../systemconsts.h" -#include "qt_utils/charsetinfo.h" -#include "../editor.h" - -#include - -XMakeCompiler::XMakeCompiler(std::shared_ptr project, bool silent, bool onlyCheckSyntax): - Compiler("",silent,onlyCheckSyntax), - mOnlyClean(false) -{ - setProject(project); -} - -void XMakeCompiler::buildXMakeFile() -{ - //we are using custom make file, don't overwrite it - if (mProject->options().useCustomMakefile && !mProject->options().customMakefile.isEmpty()) - return; - - QFile file(mProject->makeFileName()); - newXMakeFile(file); - -} - -void XMakeCompiler::newXMakeFile(QFile& file) -{ - // Create OBJ output directory - if (!mProject->options().objectOutput.isEmpty()) { - QDir(mProject->directory()).mkpath(mProject->options().objectOutput); - } - - // Write more information to the log file than before - log(tr("Building xmake.lua file...")); - log("--------"); - log(tr("- Filename: %1").arg(mProject->xmakeFileName())); - - // Create the actual file - if (!file.open(QFile::WriteOnly | QFile::Truncate)) - throw CompileError(tr("Can't open '%1' for write!").arg(mProject->xmakeFileName())); - - writeln(file,"-- Project: " + mProject->name()); - writeln(file,QString("-- xmake.lua created by Red Panda C++ ") + REDPANDA_CPP_VERSION); - writeln(file); - - writeln(file, QString("target(\"%1\")").arg(mProject->name())); - switch(mProject->options().type) { - case ProjectType::StaticLib: - writeln(file,"\tset_kind(\"static\")"); - break; - case ProjectType::DynamicLib: - writeln(file,"\tset_kind(\"shared\")"); - break; - default: - writeln(file,"\tset_kind(\"binary\")"); - } - // add files to compile - foreach(const PProjectUnit &unit, mProject->unitList()) { - if (!unit->compile() && !unit->link()) - continue; - - // Only process source files - QString relativeName = extractRelativePath(mProject->directory(), unit->fileName()); - FileType fileType = getFileType(relativeName); - if (fileType==FileType::ASM && !compilerSet()->canAssemble()) - continue; - - if (fileType == FileType::CHeader || fileType == FileType::CppHeader) { - writeln(file,QString("\tadd_headerfiles(\"%1\")").arg(relativeName)); - } else if (fileType == FileType::CSource || fileType == FileType::CppSource - || fileType == FileType::ASM || fileType==FileType::GAS || fileType==FileType::WindowsResourceSource) { - writeln(file,QString("\tadd_files(\"%1\")").arg(relativeName)); - } - } - - // Get windres file -#ifdef Q_OS_WIN - if (!mProject->options().privateResource.isEmpty()) { - QString relativeName = extractRelativePath(mProject->directory(), mProject->options().privateResource); - writeln(file,QString("\tadd_files(\"%1\")").arg(relativeName)); - } -#endif - - // Get list of applicable flags - QString cCompileArguments = getCCompileArguments(mOnlyCheckSyntax); - QString cppCompileArguments = getCppCompileArguments(mOnlyCheckSyntax); - QString libraryArguments = getLibraryArguments(FileType::Project); - QString cIncludeArguments = getCIncludeArguments() + " " + getProjectIncludeArguments(); - QString cppIncludeArguments = getCppIncludeArguments() + " " +getProjectIncludeArguments(); - - cCompileArguments.replace("\"","\\\""); - cppCompileArguments.replace("\"","\\\""); - libraryArguments.replace("\"","\\\""); - cIncludeArguments.replace("\"","\\\""); - cppIncludeArguments.replace("\"","\\\""); - - writeln(file,QString("\tadd_cflags(\"%1\")").arg(cCompileArguments)); - writeln(file,QString("\tadd_cflags(\"%1\")").arg(cIncludeArguments)); - writeln(file,QString("\tadd_cxxflags(\"%1\")").arg(cppCompileArguments)); - writeln(file,QString("\tadd_cxxflags(\"%1\")").arg(cppIncludeArguments)); - writeln(file,QString("\tadd_ldflags(\"%1\")").arg(libraryArguments)); - -#ifdef Q_OS_WIN - writeln(file,QString("\tadd_rcflags(\"%1\")").arg(mProject->options().resourceCmd)); -#endif - - if (mProject->getCompileOption(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON) { - writeln(file,QString("\tadd_defines(\"__DEBUG__\")")); - } - - writeln(file,QString("target_end()")); -} - -void XMakeCompiler::writeln(QFile &file, const QString &s) -{ - if (!s.isEmpty()) - file.write(s.toLocal8Bit()); - file.write("\n"); -} - -bool XMakeCompiler::onlyClean() const -{ - return mOnlyClean; -} - -void XMakeCompiler::setOnlyClean(bool newOnlyClean) -{ - mOnlyClean = newOnlyClean; -} - -bool XMakeCompiler::prepareForRebuild() -{ - //we use make argument to clean - return true; -} - -bool XMakeCompiler::prepareForCompile() -{ - if (!mProject) - return false; - //initProgressForm(); - log(tr("Compiling project changes...")); - log("--------"); - log(tr("- Project Filename: %1").arg(mProject->filename())); - log(tr("- Compiler Set Name: %1").arg(compilerSet()->name())); - log(""); - - buildXMakeFile(); - - mCompiler = compilerSet()->make(); - - if (!fileExists(mCompiler)) { - throw CompileError( - tr("Make program '%1' doesn't exists!").arg(mCompiler) - +"
" - +tr("Please check the \"program\" page of compiler settings.")); - } - - QString parallelParam; - if (mProject->options().allowParallelBuilding) { - if (mProject->options().parellelBuildingJobs==0) { - parallelParam = " --jobs"; - } else { - parallelParam = QString(" -j%1").arg(mProject->options().parellelBuildingJobs); - } - } - - if (mOnlyClean) { - mArguments = QString(" %1 -f \"%2\" clean").arg(parallelParam, - extractRelativePath( - mProject->directory(), - mProject->makeFileName())); - } else if (mRebuild) { - mArguments = QString(" %1 -f \"%2\" clean all").arg(parallelParam, - extractRelativePath( - mProject->directory(), - mProject->makeFileName())); - } else { - mArguments = QString(" %1 -f \"%2\" all").arg(parallelParam, - extractRelativePath( - mProject->directory(), - mProject->makeFileName())); - } - mDirectory = mProject->directory(); - - log(tr("Processing makefile:")); - log("--------"); - log(tr("- makefile processer: %1").arg(mCompiler)); - log(tr("- Command: %1 %2").arg(extractFileName(mCompiler)).arg(mArguments)); - log(""); - - return true; -} diff --git a/RedPandaIDE/compiler/xmakecompiler.h b/RedPandaIDE/compiler/xmakecompiler.h deleted file mode 100644 index f806faae..00000000 --- a/RedPandaIDE/compiler/xmakecompiler.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef XMAKECOMPILER_H -#define XMAKECOMPILER_H - -#include "compiler.h" -#include -#include - -class Project; -class XMakeCompiler : public Compiler -{ - Q_OBJECT -public: - XMakeCompiler(std::shared_ptr project, bool silent,bool onlyCheckSyntax); - XMakeCompiler(const XMakeCompiler&)=delete; - XMakeCompiler& operator=(const XMakeCompiler&)=delete; - void buildXMakeFile(); - - bool onlyClean() const; - void setOnlyClean(bool newOnlyClean); - -private: - void newXMakeFile(QFile& file); - void writeln(QFile& file, const QString& s=""); - // Compiler interface -private: - bool mOnlyClean; -protected: - bool prepareForCompile() override; - bool prepareForRebuild() override; -}; - -#endif // XMakeCompiler_H