Tweaks to use summaries in GUI

This commit is contained in:
Daniel Marjamäki 2020-12-19 20:45:51 +01:00
parent c9881bb445
commit a493e17a6a
4 changed files with 11 additions and 6 deletions

View File

@ -901,7 +901,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
std::list<std::string> fileNames;
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i)
fileNames.emplace_back(i->first);
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.project.fileSettings);
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, settings.project.fileSettings);
}
unsigned int returnValue = 0;

View File

@ -444,8 +444,9 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
qDebug() << "Checking project file" << mProjectFile->getFilename();
if (!checkSettings.buildDir.empty()) {
checkSettings.loadSummaries();
std::list<std::string> sourcefiles;
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings);
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings);
}
//mThread->SetanalyzeProject(true);
@ -510,10 +511,11 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
qDebug() << "Checking project file" << mProjectFile->getFilename();
if (!checkSettings.buildDir.empty()) {
checkSettings.loadSummaries();
std::list<std::string> sourcefiles;
foreach (QString s, fileNames)
sourcefiles.push_back(s.toStdString());
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.project.fileSettings);
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, checkSettings.project.fileSettings);
}
mThread->setCheckFiles(true);
@ -1175,7 +1177,8 @@ void MainWindow::clearResults()
if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) {
QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir());
for (const QString& f: dir.entryList(QDir::Files)) {
dir.remove(f);
if (!f.endsWith("files.txt") && !QRegExp(".*.s[0-9]+$").exactMatch(f))
dir.remove(f);
}
}
mUI.mResults->clear(true);

View File

@ -44,7 +44,7 @@ static std::string getFilename(const std::string &fullpath)
return fullpath.substr(pos1,pos2);
}
void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::list<ImportProject::FileSettings> &fileSettings)
void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<ImportProject::FileSettings> &fileSettings)
{
std::map<std::string, unsigned int> fileCount;
@ -53,6 +53,8 @@ void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::
for (const std::string &f : sourcefiles) {
const std::string afile = getFilename(f);
fout << afile << ".a" << (++fileCount[afile]) << "::" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n';
if (!userDefines.empty())
fout << afile << ".a" << (++fileCount[afile]) << ":" << userDefines << ":" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n';
}
for (const ImportProject::FileSettings &fs : fileSettings) {

View File

@ -50,7 +50,7 @@ class CPPCHECKLIB AnalyzerInformation {
public:
~AnalyzerInformation();
static void writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::list<ImportProject::FileSettings> &fileSettings);
static void writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<ImportProject::FileSettings> &fileSettings);
/** Close current TU.analyzerinfo file */
void close();