optimize the algorithm for finding compiler sets
This commit is contained in:
parent
8d51876518
commit
8affc316f3
|
@ -1464,10 +1464,10 @@ void Settings::Editor::setTabToSpaces(bool tabToSpaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::CompilerSet::CompilerSet():
|
Settings::CompilerSet::CompilerSet():
|
||||||
|
mFullLoaded(false),
|
||||||
mAutoAddCharsetParams(true),
|
mAutoAddCharsetParams(true),
|
||||||
mExecCharset(ENCODING_SYSTEM_DEFAULT),
|
mExecCharset(ENCODING_SYSTEM_DEFAULT),
|
||||||
mStaticLink(true),
|
mStaticLink(true)
|
||||||
mFullLoaded(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1482,7 +1482,7 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString&
|
||||||
setProperties(compilerFolder, cc_prog);
|
setProperties(compilerFolder, cc_prog);
|
||||||
|
|
||||||
//manually set the directories
|
//manually set the directories
|
||||||
setDirectories(compilerFolder, cc_prog);
|
setDirectories(compilerFolder, mCompilerType);
|
||||||
|
|
||||||
setExecutables();
|
setExecutables();
|
||||||
|
|
||||||
|
@ -1504,10 +1504,16 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
|
||||||
mDebugger(set.mDebugger),
|
mDebugger(set.mDebugger),
|
||||||
mProfiler(set.mProfiler),
|
mProfiler(set.mProfiler),
|
||||||
mResourceCompiler(set.mResourceCompiler),
|
mResourceCompiler(set.mResourceCompiler),
|
||||||
|
mDebugServer(set.mDebugServer),
|
||||||
|
|
||||||
mBinDirs(set.mBinDirs),
|
mBinDirs(set.mBinDirs),
|
||||||
mCIncludeDirs(set.mCIncludeDirs),
|
mCIncludeDirs(set.mCIncludeDirs),
|
||||||
mCppIncludeDirs(set.mCppIncludeDirs),
|
mCppIncludeDirs(set.mCppIncludeDirs),
|
||||||
mLibDirs(set.mLibDirs),
|
mLibDirs(set.mLibDirs),
|
||||||
|
mDefaultLibDirs(set.mDefaultLibDirs),
|
||||||
|
mDefaultCIncludeDirs(set.mDefaultCIncludeDirs),
|
||||||
|
mDefaultCppIncludeDirs(set.mDefaultCppIncludeDirs),
|
||||||
|
|
||||||
mDumpMachine(set.mDumpMachine),
|
mDumpMachine(set.mDumpMachine),
|
||||||
mVersion(set.mVersion),
|
mVersion(set.mVersion),
|
||||||
mType(set.mType),
|
mType(set.mType),
|
||||||
|
@ -1515,16 +1521,25 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
|
||||||
mDefines(set.mDefines),
|
mDefines(set.mDefines),
|
||||||
mTarget(set.mTarget),
|
mTarget(set.mTarget),
|
||||||
mCompilerType(set.mCompilerType),
|
mCompilerType(set.mCompilerType),
|
||||||
|
mCompilerSetType(set.mCompilerSetType),
|
||||||
|
|
||||||
mUseCustomCompileParams(set.mUseCustomCompileParams),
|
mUseCustomCompileParams(set.mUseCustomCompileParams),
|
||||||
mUseCustomLinkParams(set.mUseCustomLinkParams),
|
mUseCustomLinkParams(set.mUseCustomLinkParams),
|
||||||
mCustomCompileParams(set.mCustomCompileParams),
|
mCustomCompileParams(set.mCustomCompileParams),
|
||||||
mCustomLinkParams(set.mCustomLinkParams),
|
mCustomLinkParams(set.mCustomLinkParams),
|
||||||
mAutoAddCharsetParams(set.mAutoAddCharsetParams),
|
mAutoAddCharsetParams(set.mAutoAddCharsetParams),
|
||||||
|
mExecCharset(set.mExecCharset),
|
||||||
|
mStaticLink(set.mStaticLink),
|
||||||
mCompileOptions(set.mCompileOptions)
|
mCompileOptions(set.mCompileOptions)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSet::resetCompileOptionts()
|
||||||
|
{
|
||||||
|
mCompileOptions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::CompilerSet::setCompileOption(const QString &key, int valIndex)
|
bool Settings::CompilerSet::setCompileOption(const QString &key, int valIndex)
|
||||||
{
|
{
|
||||||
PCompilerOption op = CompilerInfoManager::getCompilerOption(mCompilerType, key);
|
PCompilerOption op = CompilerInfoManager::getCompilerOption(mCompilerType, key);
|
||||||
|
@ -1773,7 +1788,7 @@ QStringList &Settings::CompilerSet::defaultCIncludeDirs()
|
||||||
{
|
{
|
||||||
if (!mFullLoaded && !binDirs().isEmpty()) {
|
if (!mFullLoaded && !binDirs().isEmpty()) {
|
||||||
mFullLoaded=true;
|
mFullLoaded=true;
|
||||||
setDirectories(binDirs()[0],mCCompiler);
|
setDirectories(binDirs()[0],mCompilerType);
|
||||||
setDefines();
|
setDefines();
|
||||||
}
|
}
|
||||||
return mDefaultCIncludeDirs;
|
return mDefaultCIncludeDirs;
|
||||||
|
@ -1783,7 +1798,7 @@ QStringList &Settings::CompilerSet::defaultCppIncludeDirs()
|
||||||
{
|
{
|
||||||
if (!mFullLoaded && !binDirs().isEmpty()) {
|
if (!mFullLoaded && !binDirs().isEmpty()) {
|
||||||
mFullLoaded=true;
|
mFullLoaded=true;
|
||||||
setDirectories(binDirs()[0],mCCompiler);
|
setDirectories(binDirs()[0],mCompilerType);
|
||||||
setDefines();
|
setDefines();
|
||||||
}
|
}
|
||||||
return mDefaultCppIncludeDirs;
|
return mDefaultCppIncludeDirs;
|
||||||
|
@ -1793,7 +1808,7 @@ QStringList &Settings::CompilerSet::defaultLibDirs()
|
||||||
{
|
{
|
||||||
if (!mFullLoaded && !binDirs().isEmpty()) {
|
if (!mFullLoaded && !binDirs().isEmpty()) {
|
||||||
mFullLoaded=true;
|
mFullLoaded=true;
|
||||||
setDirectories(binDirs()[0],mCCompiler);
|
setDirectories(binDirs()[0],mCompilerType);
|
||||||
setDefines();
|
setDefines();
|
||||||
}
|
}
|
||||||
return mLibDirs;
|
return mLibDirs;
|
||||||
|
@ -1843,7 +1858,7 @@ const QStringList& Settings::CompilerSet::defines()
|
||||||
{
|
{
|
||||||
if (!mFullLoaded && !binDirs().isEmpty()) {
|
if (!mFullLoaded && !binDirs().isEmpty()) {
|
||||||
mFullLoaded=true;
|
mFullLoaded=true;
|
||||||
setDirectories(binDirs()[0],mCCompiler);
|
setDirectories(binDirs()[0],mCompilerType);
|
||||||
setDefines();
|
setDefines();
|
||||||
}
|
}
|
||||||
return mDefines;
|
return mDefines;
|
||||||
|
@ -2100,9 +2115,14 @@ void Settings::CompilerSet::setExecutables()
|
||||||
mProfiler = findProgramInBinDirs(GPROF_PROGRAM);
|
mProfiler = findProgramInBinDirs(GPROF_PROGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setDirectories(const QString& binDir,const QString& cc_prog)
|
void Settings::CompilerSet::setDirectories(const QString& binDir,const QString& compilerType)
|
||||||
{
|
{
|
||||||
QString folder = QFileInfo(binDir).absolutePath();
|
QString folder = QFileInfo(binDir).absolutePath();
|
||||||
|
QString cc_prog;
|
||||||
|
if (compilerType==COMPILER_CLANG)
|
||||||
|
cc_prog = CLANG_PROGRAM;
|
||||||
|
else
|
||||||
|
cc_prog = GCC_PROGRAM;
|
||||||
// Find default directories
|
// Find default directories
|
||||||
// C include dirs
|
// C include dirs
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
@ -2378,6 +2398,13 @@ Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder, con
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::PCompilerSet Settings::CompilerSets::addSet(const PCompilerSet &pSet)
|
||||||
|
{
|
||||||
|
PCompilerSet p=std::make_shared<CompilerSet>(*pSet);
|
||||||
|
mList.push_back(p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static void set64_32Options(Settings::PCompilerSet pSet) {
|
static void set64_32Options(Settings::PCompilerSet pSet) {
|
||||||
pSet->setCompileOption(CC_CMD_OPT_POINTER_SIZE,"32");
|
pSet->setCompileOption(CC_CMD_OPT_POINTER_SIZE,"32");
|
||||||
}
|
}
|
||||||
|
@ -2414,39 +2441,34 @@ bool Settings::CompilerSets::addSets(const QString &folder, const QString& cc_pr
|
||||||
QString platformName;
|
QString platformName;
|
||||||
if (baseSet->target() == "x86_64") {
|
if (baseSet->target() == "x86_64") {
|
||||||
if (baseName.startsWith("TDM-GCC ")) {
|
if (baseName.startsWith("TDM-GCC ")) {
|
||||||
|
PCompilerSet set= addSet(baseSet);
|
||||||
platformName = "32-bit";
|
platformName = "32-bit";
|
||||||
baseSet->setName(baseName + " " + platformName + " Release");
|
set->setName(baseName + " " + platformName + " Release");
|
||||||
baseSet->setCompilerSetType(CompilerSetType::CST_RELEASE);
|
set->setCompilerSetType(CompilerSetType::CST_RELEASE);
|
||||||
set64_32Options(baseSet);
|
set64_32Options(set);
|
||||||
setReleaseOptions(baseSet);
|
setReleaseOptions(set);
|
||||||
|
|
||||||
baseSet = addSet(folder,cc_prog);
|
set = addSet(baseSet);
|
||||||
baseSet->setName(baseName + " " + platformName + " Debug");
|
set->setName(baseName + " " + platformName + " Debug");
|
||||||
baseSet->setCompilerSetType(CompilerSetType::CST_DEBUG);
|
set->setCompilerSetType(CompilerSetType::CST_DEBUG);
|
||||||
set64_32Options(baseSet);
|
set64_32Options(set);
|
||||||
setDebugOptions(baseSet);
|
setDebugOptions(set);
|
||||||
|
|
||||||
// baseSet = addSet(folder);
|
|
||||||
// baseSet->setName(baseName + " " + platformName + " Profiling");
|
|
||||||
// baseSet->setCompilerSetType(CompilerSetType::CST_PROFILING);
|
|
||||||
// set64_32Options(baseSet);
|
|
||||||
// setProfileOptions(baseSet);
|
|
||||||
|
|
||||||
baseSet = addSet(folder,cc_prog);
|
|
||||||
}
|
}
|
||||||
platformName = "64-bit";
|
platformName = "64-bit";
|
||||||
} else {
|
} else {
|
||||||
platformName = "32-bit";
|
platformName = "32-bit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCompilerSet set = addSet(baseSet);
|
||||||
|
set->setName(baseName + " " + platformName + " Debug");
|
||||||
|
set->setCompilerSetType(CompilerSetType::CST_DEBUG);
|
||||||
|
setDebugOptions(set);
|
||||||
|
|
||||||
baseSet->setName(baseName + " " + platformName + " Release");
|
baseSet->setName(baseName + " " + platformName + " Release");
|
||||||
baseSet->setCompilerSetType(CompilerSetType::CST_RELEASE);
|
baseSet->setCompilerSetType(CompilerSetType::CST_RELEASE);
|
||||||
setReleaseOptions(baseSet);
|
setReleaseOptions(baseSet);
|
||||||
|
|
||||||
baseSet = addSet(folder,cc_prog);
|
|
||||||
baseSet->setName(baseName + " " + platformName + " Debug");
|
|
||||||
baseSet->setCompilerSetType(CompilerSetType::CST_DEBUG);
|
|
||||||
setDebugOptions(baseSet);
|
|
||||||
|
|
||||||
// baseSet = addSet(folder);
|
// baseSet = addSet(folder);
|
||||||
// baseSet->setName(baseName + " " + platformName + " Profiling");
|
// baseSet->setName(baseName + " " + platformName + " Profiling");
|
||||||
// baseSet->setCompilerSetType(CompilerSetType::CST_PROFILING);
|
// baseSet->setCompilerSetType(CompilerSetType::CST_PROFILING);
|
||||||
|
@ -2833,8 +2855,6 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
||||||
if (pSet->binDirs().isEmpty())
|
if (pSet->binDirs().isEmpty())
|
||||||
return PCompilerSet();
|
return PCompilerSet();
|
||||||
|
|
||||||
//pSet->setDirectories(pSet->binDirs()[0]);
|
|
||||||
//pSet->setDefines();
|
|
||||||
return pSet;
|
return pSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1176,6 +1176,10 @@ public:
|
||||||
CompilerSet& operator= (const CompilerSet& ) = delete;
|
CompilerSet& operator= (const CompilerSet& ) = delete;
|
||||||
CompilerSet& operator= (const CompilerSet&& ) = delete;
|
CompilerSet& operator= (const CompilerSet&& ) = delete;
|
||||||
|
|
||||||
|
// Initialization
|
||||||
|
void setProperties(const QString& binDir, const QString& cc_prog);
|
||||||
|
|
||||||
|
void resetCompileOptionts();
|
||||||
bool setCompileOption(const QString& key, int valIndex);
|
bool setCompileOption(const QString& key, int valIndex);
|
||||||
bool setCompileOption(const QString& key, const QString& value);
|
bool setCompileOption(const QString& key, const QString& value);
|
||||||
void unsetCompileOption(const QString& key);
|
void unsetCompileOption(const QString& key);
|
||||||
|
@ -1183,8 +1187,6 @@ public:
|
||||||
|
|
||||||
QString getCompileOptionValue(const QString& key);
|
QString getCompileOptionValue(const QString& key);
|
||||||
|
|
||||||
void setProperties(const QString& binDir, const QString& cc_prog);
|
|
||||||
void setDirectories(const QString& binDir, const QString& cc_prog);
|
|
||||||
int mainVersion();
|
int mainVersion();
|
||||||
|
|
||||||
bool dirsValid(QString& msg);
|
bool dirsValid(QString& msg);
|
||||||
|
@ -1239,9 +1241,6 @@ public:
|
||||||
//Converts options to and from memory format ( for old settings compatibility)
|
//Converts options to and from memory format ( for old settings compatibility)
|
||||||
void setIniOptions(const QByteArray& value);
|
void setIniOptions(const QByteArray& value);
|
||||||
|
|
||||||
//load hard defines
|
|
||||||
void setDefines();
|
|
||||||
|
|
||||||
bool staticLink() const;
|
bool staticLink() const;
|
||||||
void setStaticLink(bool newStaticLink);
|
void setStaticLink(bool newStaticLink);
|
||||||
|
|
||||||
|
@ -1261,7 +1260,9 @@ public:
|
||||||
const QMap<QString, QString> &compileOptions() const;
|
const QMap<QString, QString> &compileOptions() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Initialization
|
void setDirectories(const QString& binDir, const QString& mCompilerType);
|
||||||
|
//load hard defines
|
||||||
|
void setDefines();
|
||||||
void setExecutables();
|
void setExecutables();
|
||||||
void setUserInput();
|
void setUserInput();
|
||||||
|
|
||||||
|
@ -1337,6 +1338,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PCompilerSet addSet(const QString& folder, const QString& cc_prog);
|
PCompilerSet addSet(const QString& folder, const QString& cc_prog);
|
||||||
|
PCompilerSet addSet(const PCompilerSet &pSet);
|
||||||
bool addSets(const QString& folder, const QString& cc_prog);
|
bool addSets(const QString& folder, const QString& cc_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