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; std::list<std::string> fileNames;
for (std::map<std::string, std::size_t>::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i) for (std::map<std::string, std::size_t>::const_iterator i = mFiles.begin(); i != mFiles.end(); ++i)
fileNames.emplace_back(i->first); 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; 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(); qDebug() << "Checking project file" << mProjectFile->getFilename();
if (!checkSettings.buildDir.empty()) { if (!checkSettings.buildDir.empty()) {
checkSettings.loadSummaries();
std::list<std::string> sourcefiles; std::list<std::string> sourcefiles;
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings); AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings);
} }
//mThread->SetanalyzeProject(true); //mThread->SetanalyzeProject(true);
@ -510,10 +511,11 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
qDebug() << "Checking project file" << mProjectFile->getFilename(); qDebug() << "Checking project file" << mProjectFile->getFilename();
if (!checkSettings.buildDir.empty()) { if (!checkSettings.buildDir.empty()) {
checkSettings.loadSummaries();
std::list<std::string> sourcefiles; std::list<std::string> sourcefiles;
foreach (QString s, fileNames) foreach (QString s, fileNames)
sourcefiles.push_back(s.toStdString()); 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); mThread->setCheckFiles(true);
@ -1175,6 +1177,7 @@ void MainWindow::clearResults()
if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) { if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) {
QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir()); QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir());
for (const QString& f: dir.entryList(QDir::Files)) { for (const QString& f: dir.entryList(QDir::Files)) {
if (!f.endsWith("files.txt") && !QRegExp(".*.s[0-9]+$").exactMatch(f))
dir.remove(f); dir.remove(f);
} }
} }

View File

@ -44,7 +44,7 @@ static std::string getFilename(const std::string &fullpath)
return fullpath.substr(pos1,pos2); 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; 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) { for (const std::string &f : sourcefiles) {
const std::string afile = getFilename(f); const std::string afile = getFilename(f);
fout << afile << ".a" << (++fileCount[afile]) << "::" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n'; 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) { for (const ImportProject::FileSettings &fs : fileSettings) {

View File

@ -50,7 +50,7 @@ class CPPCHECKLIB AnalyzerInformation {
public: public:
~AnalyzerInformation(); ~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 */ /** Close current TU.analyzerinfo file */
void close(); void close();