GUI: Added configuration for VS include paths
This commit is contained in:
parent
fb925069a5
commit
ff8c5f7457
|
@ -119,16 +119,6 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
// To create compile_commands.json in windows see:
|
|
||||||
// https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/
|
|
||||||
|
|
||||||
// TODO: Replace the "QDir::homePath()"
|
|
||||||
args << "-isystem" << (QDir::homePath() + "/include");
|
|
||||||
args << "-isystem" << (QDir::homePath() + "/include/c++");
|
|
||||||
args << "-isystem" << (QDir::homePath() + "/include/c++/i686-w64-mingw32");
|
|
||||||
args << "-fno-ms-compatibility";
|
|
||||||
#endif
|
|
||||||
for (std::list<std::string>::const_iterator I = fileSettings->includePaths.begin(); I != fileSettings->includePaths.end(); ++I)
|
for (std::list<std::string>::const_iterator I = fileSettings->includePaths.begin(); I != fileSettings->includePaths.end(); ++I)
|
||||||
args << ("-I" + QString::fromStdString(*I));
|
args << ("-I" + QString::fromStdString(*I));
|
||||||
for (std::list<std::string>::const_iterator i = fileSettings->systemIncludePaths.begin(); i != fileSettings->systemIncludePaths.end(); ++i)
|
for (std::list<std::string>::const_iterator i = fileSettings->systemIncludePaths.begin(); i != fileSettings->systemIncludePaths.end(); ++i)
|
||||||
|
@ -136,8 +126,36 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
|
||||||
foreach (QString D, QString::fromStdString(fileSettings->defines).split(";")) {
|
foreach (QString D, QString::fromStdString(fileSettings->defines).split(";")) {
|
||||||
args << ("-D" + D);
|
args << ("-D" + D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mClangPath.isEmpty()) {
|
||||||
|
QDir dir(mClangPath + "/../lib/clang");
|
||||||
|
foreach (QString ver, dir.entryList()) {
|
||||||
|
QString includePath = dir.absolutePath() + '/' + ver + "/include";
|
||||||
|
if (ver[0] != '.' && QDir(includePath).exists()) {
|
||||||
|
args << "-isystem" << includePath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// To create compile_commands.json in windows see:
|
||||||
|
// https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/
|
||||||
|
|
||||||
|
foreach (QString s, mVsIncludePaths.split(";")) {
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
s.replace("\\", "/");
|
||||||
|
args << "-isystem" << s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args << "-fno-ms-compatibility";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!fileSettings->standard.empty())
|
if (!fileSettings->standard.empty())
|
||||||
args << (" -std=" + QString::fromStdString(fileSettings->standard));
|
args << ("-std=" + QString::fromStdString(fileSettings->standard));
|
||||||
|
else if (!mVsIncludePaths.isEmpty() && fileName.endsWith(".cpp"))
|
||||||
|
args << "-std=c++14";
|
||||||
|
|
||||||
QString analyzerInfoFile;
|
QString analyzerInfoFile;
|
||||||
|
|
||||||
|
@ -149,7 +167,6 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
|
||||||
QStringList args2(args);
|
QStringList args2(args);
|
||||||
args2.insert(0,"-E");
|
args2.insert(0,"-E");
|
||||||
args2 << fileName;
|
args2 << fileName;
|
||||||
qDebug() << cmd << args2;
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(cmd,args2);
|
process.start(cmd,args2);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
@ -192,7 +209,10 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
|
||||||
{
|
{
|
||||||
QString debug(cmd);
|
QString debug(cmd);
|
||||||
foreach (QString arg, args) {
|
foreach (QString arg, args) {
|
||||||
debug += ' ' + arg;
|
if (arg.contains(" "))
|
||||||
|
debug += " \"" + arg + '\"';
|
||||||
|
else
|
||||||
|
debug += ' ' + arg;
|
||||||
}
|
}
|
||||||
qDebug() << debug;
|
qDebug() << debug;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ public:
|
||||||
mAddons = addons;
|
mAddons = addons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setVsIncludePaths(const QString &s) {
|
||||||
|
mVsIncludePaths = s;
|
||||||
|
}
|
||||||
|
|
||||||
void setDataDir(const QString &dataDir) {
|
void setDataDir(const QString &dataDir) {
|
||||||
mDataDir = dataDir;
|
mDataDir = dataDir;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +124,7 @@ private:
|
||||||
QStringList mFiles;
|
QStringList mFiles;
|
||||||
bool mAnalyseWholeProgram;
|
bool mAnalyseWholeProgram;
|
||||||
QStringList mAddons;
|
QStringList mAddons;
|
||||||
|
QString mVsIncludePaths;
|
||||||
QString mDataDir;
|
QString mDataDir;
|
||||||
QString mClangPath;
|
QString mClangPath;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
#define SETTINGS_APPLICATION_DEFAULT "Default Application"
|
#define SETTINGS_APPLICATION_DEFAULT "Default Application"
|
||||||
#define SETTINGS_LANGUAGE "Application language"
|
#define SETTINGS_LANGUAGE "Application language"
|
||||||
#define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
|
#define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
|
||||||
|
#define SETTINGS_VS_INCLUDE_PATHS "Visual studio include paths"
|
||||||
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
|
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
|
||||||
#define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"
|
#define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"
|
||||||
#define SETTINGS_MRU_PROJECTS "MRU Projects"
|
#define SETTINGS_MRU_PROJECTS "MRU Projects"
|
||||||
|
|
|
@ -414,6 +414,7 @@ void MainWindow::doAnalyzeProject(ImportProject p)
|
||||||
//mThread->SetanalyzeProject(true);
|
//mThread->SetanalyzeProject(true);
|
||||||
if (mProjectFile) {
|
if (mProjectFile) {
|
||||||
mThread->setAddons(mProjectFile->getAddons());
|
mThread->setAddons(mProjectFile->getAddons());
|
||||||
|
mThread->setVsIncludePaths(mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString());
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Try to autodetect clang
|
// Try to autodetect clang
|
||||||
if (QFileInfo("C:/Program Files/LLVM/bin/clang.exe").exists())
|
if (QFileInfo("C:/Program Files/LLVM/bin/clang.exe").exists())
|
||||||
|
|
|
@ -240,6 +240,16 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="mLabelVsInclude">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p>Visual Studio include paths<br/>Open Visual Studio command prompt. Type &quot;SET INCLUDE&quot; and paste the outputs below:</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mEditVsInclude"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
|
|
|
@ -54,6 +54,15 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
|
||||||
mUI.mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool()));
|
mUI.mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool()));
|
||||||
mUI.mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
|
mUI.mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
mUI.mLabelVsInclude->setVisible(true);
|
||||||
|
mUI.mEditVsInclude->setVisible(true);
|
||||||
|
mUI.mEditVsInclude->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString());
|
||||||
|
#else
|
||||||
|
mUI.mLabelVsInclude->setVisible(false);
|
||||||
|
mUI.mEditVsInclude->setVisible(false);
|
||||||
|
mUI.mEditVsInclude->setText(QString());
|
||||||
|
#endif
|
||||||
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
|
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
|
||||||
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
|
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
|
||||||
connect(mUI.mBtnAddApplication, SIGNAL(clicked()),
|
connect(mUI.mBtnAddApplication, SIGNAL(clicked()),
|
||||||
|
@ -177,6 +186,13 @@ void SettingsDialog::saveSettingValues() const
|
||||||
saveCheckboxValue(&settings, mUI.mShowStatistics, SETTINGS_SHOW_STATISTICS);
|
saveCheckboxValue(&settings, mUI.mShowStatistics, SETTINGS_SHOW_STATISTICS);
|
||||||
saveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID);
|
saveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QString vsIncludePaths = mUI.mEditVsInclude->text();
|
||||||
|
if (vsIncludePaths.startsWith("INCLUDE="))
|
||||||
|
vsIncludePaths.remove(0, 8);
|
||||||
|
settings.setValue(SETTINGS_VS_INCLUDE_PATHS, vsIncludePaths);
|
||||||
|
#endif
|
||||||
|
|
||||||
const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
|
const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
|
||||||
if (currentLang) {
|
if (currentLang) {
|
||||||
const QString langcode = currentLang->data(LangCodeRole).toString();
|
const QString langcode = currentLang->data(LangCodeRole).toString();
|
||||||
|
|
|
@ -93,6 +93,7 @@ void ThreadHandler::check(const Settings &settings)
|
||||||
|
|
||||||
for (int i = 0; i < mRunningThreadCount; i++) {
|
for (int i = 0; i < mRunningThreadCount; i++) {
|
||||||
mThreads[i]->setAddons(mAddons);
|
mThreads[i]->setAddons(mAddons);
|
||||||
|
mThreads[i]->setVsIncludePaths(mVsIncludePaths);
|
||||||
mThreads[i]->setClangPath(mClangPath);
|
mThreads[i]->setClangPath(mClangPath);
|
||||||
mThreads[i]->setDataDir(mDataDir);
|
mThreads[i]->setDataDir(mDataDir);
|
||||||
mThreads[i]->check(settings);
|
mThreads[i]->check(settings);
|
||||||
|
|
|
@ -75,6 +75,10 @@ public:
|
||||||
mAddons = addons;
|
mAddons = addons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setVsIncludePaths(const QString &s) {
|
||||||
|
mVsIncludePaths = s;
|
||||||
|
}
|
||||||
|
|
||||||
void setClangPath(const QString &p) {
|
void setClangPath(const QString &p) {
|
||||||
mClangPath = p;
|
mClangPath = p;
|
||||||
}
|
}
|
||||||
|
@ -246,6 +250,7 @@ protected:
|
||||||
bool mAnalyseWholeProgram;
|
bool mAnalyseWholeProgram;
|
||||||
|
|
||||||
QStringList mAddons;
|
QStringList mAddons;
|
||||||
|
QString mVsIncludePaths;
|
||||||
QString mClangPath;
|
QString mClangPath;
|
||||||
|
|
||||||
QString mDataDir;
|
QString mDataDir;
|
||||||
|
|
Loading…
Reference in New Issue