refactor: correct var name
This commit is contained in:
parent
ea3b4ea8e5
commit
e81c08d6c8
1
NEWS.md
1
NEWS.md
|
@ -13,6 +13,7 @@ Red Panda C++ Version 2.6
|
||||||
- enhancement: Show current problem's description in the problem list's mouse tip.
|
- enhancement: Show current problem's description in the problem list's mouse tip.
|
||||||
- enhancement: Show memory usage for problem cases (windows only).
|
- enhancement: Show memory usage for problem cases (windows only).
|
||||||
- enhancement: Show memory usage after console program exited.
|
- enhancement: Show memory usage after console program exited.
|
||||||
|
- fix: If clang and g++ are in the same folder, only the compiler sets for gcc are auto generated.
|
||||||
|
|
||||||
Red Panda C++ Version 2.5
|
Red Panda C++ Version 2.5
|
||||||
|
|
||||||
|
|
|
@ -1557,7 +1557,7 @@ Settings::CompilerSet::CompilerSet():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString& cc_prog):
|
Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString& c_prog):
|
||||||
mAutoAddCharsetParams(true),
|
mAutoAddCharsetParams(true),
|
||||||
mExecCharset(ENCODING_SYSTEM_DEFAULT),
|
mExecCharset(ENCODING_SYSTEM_DEFAULT),
|
||||||
mStaticLink(true),
|
mStaticLink(true),
|
||||||
|
@ -1568,7 +1568,7 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString&
|
||||||
mCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable)
|
mCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable)
|
||||||
{
|
{
|
||||||
if (QDir(compilerFolder).exists()) {
|
if (QDir(compilerFolder).exists()) {
|
||||||
setProperties(compilerFolder, cc_prog);
|
setProperties(compilerFolder, c_prog);
|
||||||
|
|
||||||
//manually set the directories
|
//manually set the directories
|
||||||
setDirectories(compilerFolder, mCompilerType);
|
setDirectories(compilerFolder, mCompilerType);
|
||||||
|
@ -2051,21 +2051,15 @@ static void addExistingDirectory(QStringList& dirs, const QString& directory) {
|
||||||
dirs.append(dirPath);
|
dirs.append(dirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setProperties(const QString &binDir, const QString& cc_prog)
|
void Settings::CompilerSet::setProperties(const QString &binDir, const QString& c_prog)
|
||||||
{
|
{
|
||||||
if (cc_prog.isEmpty())
|
if (c_prog.isEmpty())
|
||||||
return;
|
return;
|
||||||
// QString cc_prog;
|
|
||||||
// if (fileExists(binDir, CLANG_PROGRAM))
|
|
||||||
// cc_prog = CLANG_PROGRAM;
|
|
||||||
// else if (fileExists(binDir,GCC_PROGRAM))
|
|
||||||
// cc_prog = GCC_PROGRAM;
|
|
||||||
// else
|
|
||||||
// return;
|
|
||||||
// Obtain version number and compiler distro etc
|
// Obtain version number and compiler distro etc
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments.append("-v");
|
arguments.append("-v");
|
||||||
QByteArray output = getCompilerOutput(binDir,cc_prog,arguments);
|
QByteArray output = getCompilerOutput(binDir,c_prog,arguments);
|
||||||
|
|
||||||
//Target
|
//Target
|
||||||
QByteArray targetStr = "Target: ";
|
QByteArray targetStr = "Target: ";
|
||||||
|
@ -2169,7 +2163,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir, const QString&
|
||||||
// Obtain compiler target
|
// Obtain compiler target
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.append("-dumpmachine");
|
arguments.append("-dumpmachine");
|
||||||
mDumpMachine = getCompilerOutput(binDir, cc_prog, arguments);
|
mDumpMachine = getCompilerOutput(binDir, c_prog, arguments);
|
||||||
|
|
||||||
// Add the default directories
|
// Add the default directories
|
||||||
addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin");
|
addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin");
|
||||||
|
@ -2257,11 +2251,11 @@ void Settings::CompilerSet::setExecutables()
|
||||||
void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType compilerType)
|
void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType compilerType)
|
||||||
{
|
{
|
||||||
QString folder = QFileInfo(binDir).absolutePath();
|
QString folder = QFileInfo(binDir).absolutePath();
|
||||||
QString cc_prog;
|
QString c_prog;
|
||||||
if (compilerType==CompilerType::Clang)
|
if (compilerType==CompilerType::Clang)
|
||||||
cc_prog = CLANG_PROGRAM;
|
c_prog = CLANG_PROGRAM;
|
||||||
else
|
else
|
||||||
cc_prog = GCC_PROGRAM;
|
c_prog = GCC_PROGRAM;
|
||||||
// Find default directories
|
// Find default directories
|
||||||
// C include dirs
|
// C include dirs
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
@ -2270,7 +2264,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
|
||||||
arguments.append("-v");
|
arguments.append("-v");
|
||||||
arguments.append("-E");
|
arguments.append("-E");
|
||||||
arguments.append(NULL_FILE);
|
arguments.append(NULL_FILE);
|
||||||
QByteArray output = getCompilerOutput(binDir,cc_prog,arguments);
|
QByteArray output = getCompilerOutput(binDir,c_prog,arguments);
|
||||||
|
|
||||||
int delimPos1 = output.indexOf("#include <...> search starts here:");
|
int delimPos1 = output.indexOf("#include <...> search starts here:");
|
||||||
int delimPos2 = output.indexOf("End of search list.");
|
int delimPos2 = output.indexOf("End of search list.");
|
||||||
|
@ -2292,7 +2286,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
|
||||||
arguments.append("-E");
|
arguments.append("-E");
|
||||||
arguments.append("-v");
|
arguments.append("-v");
|
||||||
arguments.append(NULL_FILE);
|
arguments.append(NULL_FILE);
|
||||||
output = getCompilerOutput(binDir,cc_prog,arguments);
|
output = getCompilerOutput(binDir,c_prog,arguments);
|
||||||
//gcc -xc++ -E -v NUL
|
//gcc -xc++ -E -v NUL
|
||||||
|
|
||||||
delimPos1 = output.indexOf("#include <...> search starts here:");
|
delimPos1 = output.indexOf("#include <...> search starts here:");
|
||||||
|
@ -2312,7 +2306,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.append("-print-search-dirs");
|
arguments.append("-print-search-dirs");
|
||||||
arguments.append(NULL_FILE);
|
arguments.append(NULL_FILE);
|
||||||
output = getCompilerOutput(binDir,cc_prog,arguments);
|
output = getCompilerOutput(binDir,c_prog,arguments);
|
||||||
// bin dirs
|
// bin dirs
|
||||||
QByteArray targetStr = QByteArray("programs: =");
|
QByteArray targetStr = QByteArray("programs: =");
|
||||||
delimPos1 = output.indexOf(targetStr);
|
delimPos1 = output.indexOf(targetStr);
|
||||||
|
@ -2608,10 +2602,10 @@ Settings::PCompilerSet Settings::CompilerSets::addSet()
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder, const QString& cc_prog)
|
Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder, const QString& c_prog)
|
||||||
{
|
{
|
||||||
PCompilerSet p=std::make_shared<CompilerSet>(folder,cc_prog);
|
PCompilerSet p=std::make_shared<CompilerSet>(folder,c_prog);
|
||||||
if (cc_prog==GCC_PROGRAM && p->compilerType()==CompilerType::Clang)
|
if (c_prog==GCC_PROGRAM && p->compilerType()==CompilerType::Clang)
|
||||||
return PCompilerSet();
|
return PCompilerSet();
|
||||||
mList.push_back(p);
|
mList.push_back(p);
|
||||||
return p;
|
return p;
|
||||||
|
@ -2651,15 +2645,13 @@ static void setDebugOptions(Settings::PCompilerSet pSet) {
|
||||||
pSet->setStaticLink(false);
|
pSet->setStaticLink(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::CompilerSets::addSets(const QString &folder, const QString& cc_prog) {
|
bool Settings::CompilerSets::addSets(const QString &folder, const QString& c_prog) {
|
||||||
foreach (const PCompilerSet& set, mList) {
|
foreach (const PCompilerSet& set, mList) {
|
||||||
if (set->binDirs().contains(folder)) {
|
if (set->binDirs().contains(folder) && extractFileName(set->CCompiler())==c_prog)
|
||||||
if (extractFileName(set->cppCompiler())==cc_prog)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Default, release profile
|
// Default, release profile
|
||||||
PCompilerSet baseSet = addSet(folder,cc_prog);
|
PCompilerSet baseSet = addSet(folder,c_prog);
|
||||||
if (!baseSet)
|
if (!baseSet)
|
||||||
return false;
|
return false;
|
||||||
QString baseName = baseSet->name();
|
QString baseName = baseSet->name();
|
||||||
|
|
|
@ -1230,14 +1230,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit CompilerSet();
|
explicit CompilerSet();
|
||||||
explicit CompilerSet(const QString& compilerFolder, const QString& cc_prog);
|
explicit CompilerSet(const QString& compilerFolder, const QString& c_prog);
|
||||||
explicit CompilerSet(const CompilerSet& set);
|
explicit CompilerSet(const CompilerSet& set);
|
||||||
|
|
||||||
CompilerSet& operator= (const CompilerSet& ) = delete;
|
CompilerSet& operator= (const CompilerSet& ) = delete;
|
||||||
CompilerSet& operator= (const CompilerSet&& ) = delete;
|
CompilerSet& operator= (const CompilerSet&& ) = delete;
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
void setProperties(const QString& binDir, const QString& cc_prog);
|
void setProperties(const QString& binDir, const QString& c_prog);
|
||||||
|
|
||||||
void resetCompileOptionts();
|
void resetCompileOptionts();
|
||||||
bool setCompileOption(const QString& key, int valIndex);
|
bool setCompileOption(const QString& key, int valIndex);
|
||||||
|
@ -1425,9 +1425,9 @@ public:
|
||||||
QString getKeyFromCompilerCompatibleIndex(int idx) const;
|
QString getKeyFromCompilerCompatibleIndex(int idx) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PCompilerSet addSet(const QString& folder, const QString& cc_prog);
|
PCompilerSet addSet(const QString& folder, const QString& c_prog);
|
||||||
PCompilerSet addSet(const PCompilerSet &pSet);
|
PCompilerSet addSet(const PCompilerSet &pSet);
|
||||||
bool addSets(const QString& folder, const QString& cc_prog);
|
bool addSets(const QString& folder, const QString& c_prog);
|
||||||
void savePath(const QString& name, const QString& path);
|
void savePath(const QString& name, const QString& path);
|
||||||
void savePathList(const QString& name, const QStringList& pathList);
|
void savePathList(const QString& name, const QStringList& pathList);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue