GUI: Configuration of python path for the addons
This commit is contained in:
parent
663beb6fd2
commit
71f52b77a4
|
@ -267,12 +267,32 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
|
||||||
mCppcheck.settings().buildDir = buildDir;
|
mCppcheck.settings().buildDir = buildDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cmd = "python " + a + ' ' + dumpFile;
|
const QString python = mPythonPath.isEmpty() ? QString("python") : mPythonPath;
|
||||||
qDebug() << cmd;
|
QStringList args;
|
||||||
|
args << a << dumpFile;
|
||||||
|
qDebug() << python << args;
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(cmd);
|
if (!mPythonPath.isEmpty()) {
|
||||||
|
QStringList env(QProcess::systemEnvironment());
|
||||||
|
for (int i = 0; i < env.size(); ++i) {
|
||||||
|
if (env[i].startsWith("PYTHONHOME=")) {
|
||||||
|
env.removeAt(i);
|
||||||
|
process.setEnvironment(env);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
process.start(python, args);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
parseAddonErrors(process.readAllStandardError(), addon);
|
const QString errout(process.readAllStandardError());
|
||||||
|
QFile f(dumpFile + '-' + addon + "-results");
|
||||||
|
if (f.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream out(&f);
|
||||||
|
out << errout;
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
parseAddonErrors(errout, addon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,6 +309,8 @@ QString CheckThread::getAddonPath() const
|
||||||
return mDataDir;
|
return mDataDir;
|
||||||
else if (QDir(mDataDir + "/addons").exists())
|
else if (QDir(mDataDir + "/addons").exists())
|
||||||
return mDataDir + "/addons";
|
return mDataDir + "/addons";
|
||||||
|
else if (QDir(mDataDir + "/../addons").exists())
|
||||||
|
return mDataDir + "/../addons";
|
||||||
else if (mDataDir.endsWith("/cfg")) {
|
else if (mDataDir.endsWith("/cfg")) {
|
||||||
if (QDir(mDataDir.mid(0,mDataDir.size()-3) + "addons").exists())
|
if (QDir(mDataDir.mid(0,mDataDir.size()-3) + "addons").exists())
|
||||||
return mDataDir.mid(0,mDataDir.size()-3) + "addons";
|
return mDataDir.mid(0,mDataDir.size()-3) + "addons";
|
||||||
|
|
|
@ -56,6 +56,10 @@ public:
|
||||||
mAddons = addons;
|
mAddons = addons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPythonPath(const QString &p) {
|
||||||
|
mPythonPath = p;
|
||||||
|
}
|
||||||
|
|
||||||
void setDataDir(const QString &dataDir) {
|
void setDataDir(const QString &dataDir) {
|
||||||
mDataDir = dataDir;
|
mDataDir = dataDir;
|
||||||
}
|
}
|
||||||
|
@ -128,6 +132,7 @@ private:
|
||||||
QStringList mFiles;
|
QStringList mFiles;
|
||||||
bool mAnalyseWholeProgram;
|
bool mAnalyseWholeProgram;
|
||||||
QStringList mAddons;
|
QStringList mAddons;
|
||||||
|
QString mPythonPath;
|
||||||
QString mDataDir;
|
QString mDataDir;
|
||||||
QString mClangPath;
|
QString mClangPath;
|
||||||
QStringList mClangIncludePaths;
|
QStringList mClangIncludePaths;
|
||||||
|
|
|
@ -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_PYTHON_PATH "Python path"
|
||||||
#define SETTINGS_CLANG_PATH "Clang path"
|
#define SETTINGS_CLANG_PATH "Clang path"
|
||||||
#define SETTINGS_VS_INCLUDE_PATHS "VS include paths"
|
#define SETTINGS_VS_INCLUDE_PATHS "VS include paths"
|
||||||
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
|
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
|
||||||
|
|
|
@ -444,6 +444,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->setPythonPath(mSettings->value(SETTINGS_PYTHON_PATH).toString());
|
||||||
QString clangHeaders = mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString();
|
QString clangHeaders = mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString();
|
||||||
mThread->setClangIncludePaths(clangHeaders.split(";"));
|
mThread->setClangIncludePaths(clangHeaders.split(";"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="inputMask">
|
<property name="inputMask">
|
||||||
<string notr="true">009; </string>
|
<string notr="true">009</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
|
@ -282,6 +282,45 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_5">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Addons</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
|
<string>Python binary (leave this empty to use python in the PATH)</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mEditPythonPath"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnBrowsePythonPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>168</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="mTabClang">
|
<widget class="QWidget" name="mTabClang">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Clang</string>
|
<string>Clang</string>
|
||||||
|
|
|
@ -53,6 +53,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
|
||||||
mUI.mEnableInconclusive->setCheckState(boolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()));
|
mUI.mEnableInconclusive->setCheckState(boolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()));
|
||||||
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()));
|
||||||
|
mUI.mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
//mUI.mTabClang->setVisible(true);
|
//mUI.mTabClang->setVisible(true);
|
||||||
|
@ -75,6 +76,8 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
|
||||||
connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||||
this, SLOT(editApplication()));
|
this, SLOT(editApplication()));
|
||||||
|
|
||||||
|
connect(mUI.mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath);
|
||||||
|
|
||||||
mUI.mListWidget->setSortingEnabled(false);
|
mUI.mListWidget->setSortingEnabled(false);
|
||||||
populateApplicationList();
|
populateApplicationList();
|
||||||
|
|
||||||
|
@ -157,6 +160,7 @@ void SettingsDialog::saveSettingValues() const
|
||||||
saveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS);
|
saveCheckboxValue(&settings, mUI.mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS);
|
||||||
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);
|
||||||
|
settings.setValue(SETTINGS_PYTHON_PATH, mUI.mEditPythonPath->text());
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text());
|
settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text());
|
||||||
|
@ -295,6 +299,13 @@ bool SettingsDialog::showInconclusive() const
|
||||||
return checkStateToBool(mUI.mEnableInconclusive->checkState());
|
return checkStateToBool(mUI.mEnableInconclusive->checkState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::browsePythonPath()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Select python binary"), QDir::rootPath());
|
||||||
|
if (fileName.contains("python", Qt::CaseInsensitive))
|
||||||
|
mUI.mEditPythonPath->setText(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::browseClangPath()
|
void SettingsDialog::browseClangPath()
|
||||||
{
|
{
|
||||||
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
||||||
|
|
|
@ -124,6 +124,9 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void defaultApplication();
|
void defaultApplication();
|
||||||
|
|
||||||
|
/** @brief Slot for browsing for the python binary */
|
||||||
|
void browsePythonPath();
|
||||||
|
|
||||||
/** @brief Slot for browsing for the clang binary */
|
/** @brief Slot for browsing for the clang binary */
|
||||||
void browseClangPath();
|
void browseClangPath();
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -94,6 +94,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]->setPythonPath(mPythonPath);
|
||||||
mThreads[i]->setSuppressions(mSuppressions);
|
mThreads[i]->setSuppressions(mSuppressions);
|
||||||
mThreads[i]->setClangPath(mClangPath);
|
mThreads[i]->setClangPath(mClangPath);
|
||||||
mThreads[i]->setClangIncludePaths(mClangIncludePaths);
|
mThreads[i]->setClangIncludePaths(mClangIncludePaths);
|
||||||
|
|
|
@ -79,6 +79,10 @@ public:
|
||||||
mSuppressions = s;
|
mSuppressions = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPythonPath(const QString &p) {
|
||||||
|
mPythonPath = p;
|
||||||
|
}
|
||||||
|
|
||||||
void setClangPath(const QString &p) {
|
void setClangPath(const QString &p) {
|
||||||
mClangPath = p;
|
mClangPath = p;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +259,7 @@ protected:
|
||||||
|
|
||||||
QStringList mAddons;
|
QStringList mAddons;
|
||||||
QStringList mSuppressions;
|
QStringList mSuppressions;
|
||||||
|
QString mPythonPath;
|
||||||
QString mClangPath;
|
QString mClangPath;
|
||||||
QStringList mClangIncludePaths;
|
QStringList mClangIncludePaths;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue