logic: Implemented usage of PCH for indexing EmptyCxx Source Groups

* further change: initialize all llvm targets before indexing
* further change: remove configurable dependencies directory from gradle and maven sourcegroups
This commit is contained in:
mlangkabel
2019-07-02 15:52:17 +02:00
parent 3aebe91e36
commit bb78c04b34
57 changed files with 677 additions and 457 deletions
+2 -4
View File
@@ -150,10 +150,8 @@ add_files(
qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h
qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h
qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.h
qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h
qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp
@@ -19,8 +19,7 @@
#include "QtProjectWizardContentPath.h"
#include "QtProjectWizardContentPathCDB.h"
#include "QtProjectWizardContentPathCodeblocksProject.h"
#include "QtProjectWizardContentPathDependenciesGradle.h"
#include "QtProjectWizardContentPathDependenciesMaven.h"
#include "QtProjectWizardContentPathCxxPch.h"
#include "QtProjectWizardContentPathPythonEnvironment.h"
#include "QtProjectWizardContentPathSonargraphProject.h"
#include "QtProjectWizardContentPathSourceGradle.h"
@@ -141,6 +140,13 @@ namespace
{
QtSourceGroupWizardPage<SourceGroupSettingsCEmpty> page("Advanced (optional)");
page.addContentCreatorWithSettings<QtProjectWizardContentFlags>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreator(
WIZARD_CONTENT_CONTEXT_ALL,
[](std::shared_ptr<SourceGroupSettingsCEmpty> settings, QtProjectWizardWindow* window)
{
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
}
);
pages.push_back(page);
}
@@ -180,6 +186,13 @@ namespace
{
QtSourceGroupWizardPage<SourceGroupSettingsCppEmpty> page("Advanced (optional)");
page.addContentCreatorWithSettings<QtProjectWizardContentFlags>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreator(
WIZARD_CONTENT_CONTEXT_ALL,
[](std::shared_ptr<SourceGroupSettingsCppEmpty> settings, QtProjectWizardWindow* window)
{
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
}
);
pages.push_back(page);
}
@@ -362,7 +375,6 @@ namespace
QtSourceGroupWizardPage<SourceGroupSettingsJavaMaven> page("Indexed Paths");
page.addContentCreatorWithSettings<QtProjectWizardContentJavaStandard>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSourceMaven>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathDependenciesMaven>(WIZARD_CONTENT_CONTEXT_ALL);
pages.push_back(page);
}
{
@@ -383,7 +395,6 @@ namespace
QtSourceGroupWizardPage<SourceGroupSettingsJavaGradle> page("Indexed Paths");
page.addContentCreatorWithSettings<QtProjectWizardContentJavaStandard>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSourceGradle>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathDependenciesGradle>(WIZARD_CONTENT_CONTEXT_ALL);
pages.push_back(page);
}
{
@@ -1107,28 +1118,12 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType)
case SOURCE_GROUP_JAVA_MAVEN:
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::make_shared<SourceGroupSettingsJavaMaven>(sourceGroupId, m_projectSettings.get());
settings->setMavenDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(settings->getId()) +
L"/maven"
)
);
executeSourceGroupSetup<SourceGroupSettingsJavaMaven>(settings);
}
break;
case SOURCE_GROUP_JAVA_GRADLE:
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::make_shared<SourceGroupSettingsJavaGradle>(sourceGroupId, m_projectSettings.get());
settings->setGradleDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(settings->getId()) +
L"/gradle"
)
);
executeSourceGroupSetup<SourceGroupSettingsJavaGradle>(settings);
}
break;
@@ -3,10 +3,10 @@
#include <QMessageBox>
#include "SourceGroupSettings.h"
#include "utilityFile.h"
QtProjectWizardContentPath::QtProjectWizardContentPath(QtProjectWizardWindow* window)
: QtProjectWizardContent(window)
, m_makePathRelativeToProjectFileLocation(true)
, m_allowEmpty(false)
{
}
@@ -25,10 +25,7 @@ void QtProjectWizardContentPath::populate(QGridLayout* layout, int& row)
m_picker->setPickDirectory(true);
m_picker->setPlaceholderText(m_placeholderString);
if (m_makePathRelativeToProjectFileLocation)
{
m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath());
}
m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath());
layout->addWidget(m_picker, row, QtProjectWizardWindow::BACK_COL);
row++;
@@ -53,7 +50,7 @@ bool QtProjectWizardContentPath::check()
}
}
FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString()));
FilePath path = utility::getExpandedAndAbsolutePath(FilePath(m_picker->getText().toStdWString()), getSourceGroupSettings()->getProjectDirectoryPath());
if (m_picker->pickDirectory())
{
@@ -66,7 +63,7 @@ bool QtProjectWizardContentPath::check()
break;
}
if (m_fileEndings.find(path.extension()) == m_fileEndings.end())
if (!m_fileEndings.empty() && m_fileEndings.find(path.extension()) == m_fileEndings.end())
{
error = "The entered path does have a correct file ending at \"" + m_titleString + "\".";
break;
@@ -31,8 +31,6 @@ protected:
QtLocationPicker* m_picker;
bool m_makePathRelativeToProjectFileLocation;
private:
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() = 0;
@@ -0,0 +1,46 @@
#include "QtProjectWizardContentPathCxxPch.h"
#include "SourceGroupSettingsWithCxxPchOptions.h"
#include "utility.h"
#include "utilityFile.h"
QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch(
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settingsCxxPch,
QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
, m_settingsCxxPch(settingsCxxPch)
{
setTitleString("Precompiled Header File");
setHelpString(
"Specify the path to the input header file that should be used to generate a precompiled header during indexing.<br />"
"If the indexed source code is usually built using precompiled headers, using this option will speed up your indexing performance.<br />"
"Leave blank to disable the use of precompiled headers. You can make use of environment variables with ${ENV_VAR}."
);
setAllowEmpty(true);
setPlaceholderString("Not Using Precompiled Headers");
}
void QtProjectWizardContentPathCxxPch::populate(QGridLayout* layout, int& row)
{
QtProjectWizardContentPath::populate(layout, row);
m_picker->setPickDirectory(false);
}
void QtProjectWizardContentPathCxxPch::load()
{
m_picker->setText(QString::fromStdWString(m_settingsCxxPch->getPchInputFilePath().wstr()));
}
void QtProjectWizardContentPathCxxPch::save()
{
m_settingsCxxPch->setPchInputFilePathFilePath(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathCxxPch::getSourceGroupSettings()
{
return m_settings;
}
@@ -0,0 +1,33 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
#include "QtProjectWizardContentPath.h"
#include "SingleValueCache.h"
class SourceGroupSettingsWithCxxPchOptions;
class QtProjectWizardContentPathCxxPch
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathCxxPch(
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settingsCxxPch,
QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void populate(QGridLayout* layout, int& row) override;
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettings> m_settings;
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> m_settingsCxxPch;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
@@ -1,33 +0,0 @@
#include "QtProjectWizardContentPathDependenciesGradle.h"
#include "SourceGroupSettingsJavaGradle.h"
QtProjectWizardContentPathDependenciesGradle::QtProjectWizardContentPathDependenciesGradle(
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle "
"project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizardContentPathDependenciesGradle::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr()));
}
void QtProjectWizardContentPathDependenciesGradle::save()
{
m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathDependenciesGradle::getSourceGroupSettings()
{
return m_settings;
}
@@ -1,27 +0,0 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
#include "QtProjectWizardContentPath.h"
class SourceGroupSettingsJavaGradle;
class QtProjectWizardContentPathDependenciesGradle
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathDependenciesGradle(
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
@@ -1,32 +0,0 @@
#include "QtProjectWizardContentPathDependenciesMaven.h"
#include "SourceGroupSettingsJavaMaven.h"
QtProjectWizardContentPathDependenciesMaven::QtProjectWizardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizardContentPathDependenciesMaven::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr()));
}
void QtProjectWizardContentPathDependenciesMaven::save()
{
m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathDependenciesMaven::getSourceGroupSettings()
{
return m_settings;
}
@@ -1,26 +0,0 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
#include "QtProjectWizardContentPath.h"
class SourceGroupSettingsJavaMaven;
class QtProjectWizardContentPathDependenciesMaven
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
@@ -3,6 +3,7 @@
#include "ResourcePaths.h"
#include "SourceGroupSettingsPythonEmpty.h"
#include "utilityApp.h"
#include "utilityFile.h"
QtProjectWizardContentPathPythonEnvironment::QtProjectWizardContentPathPythonEnvironment(
std::shared_ptr<SourceGroupSettingsPythonEmpty> settings, QtProjectWizardWindow* window
@@ -63,7 +64,7 @@ void QtProjectWizardContentPathPythonEnvironment::onTextChanged(const QString& t
std::thread([=]() {
std::pair<int, std::string> out = utility::executeProcess(
"\"" + ResourcePaths::getPythonPath().str() + "SourcetrailPythonIndexer\" check-environment " +
"--environment-path \"" + m_settings->makePathExpandedAndAbsolute(FilePath(text.toStdWString())).str() + "\"",
"--environment-path \"" + utility::getExpandedAndAbsolutePath(FilePath(text.toStdWString()), m_settings->getProjectDirectoryPath()).str() + "\"",
FilePath(),
5000
);