build: ship clang compiler header within Sourcetrail package on macOS and Linux

* replace path to local compiler headers with packaged ones in include path detection
* added app settings migration to replace local compiler header path with path to packaged headers
This commit is contained in:
Eberhard Graether
2018-06-18 14:08:50 +02:00
parent a1c146d439
commit f11be042a6
20 changed files with 121 additions and 22 deletions
+1
View File
@@ -4,6 +4,7 @@
/bin/app/data/projects/ignored/
/bin/app/data/java/lib/
/bin/app/data/cxx/
/bin/app/user/log/
/bin/app/user/ApplicationSettings.xml
/bin/app/user/window_settings.ini
+5
View File
@@ -799,6 +799,11 @@ if (UNIX)
"-E" "create_symlink"
"${CMAKE_SOURCE_DIR}/bin/app/user"
"${CMAKE_BINARY_DIR}/app/user"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${CMAKE_SOURCE_DIR}/bin/app/data/cxx"
COMMAND "${CMAKE_COMMAND}"
"-E" "create_symlink"
"$ENV{LLVM_DIR}/build_release/lib/clang/6.0.0/include"
"${CMAKE_SOURCE_DIR}/bin/app/data/cxx/include"
)
if (UNIX AND NOT APPLE)
+5
View File
@@ -25,6 +25,7 @@
For MacOS and Linux
* QT_DIR - .../Qt/Qt5.10.1/5.10.1/<IDE>
* LLVM_DIR - .../clang-llvm
For Windows:
* QT_WIN32_DIR - .../Qt/Qt5.10.1/5.10.1/msvc2015
@@ -137,6 +138,10 @@ $ cd ../build_release
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RTTI=ON ../llvm
$ ninja -j4 check-all
# Update CMakeLists.txt symlink directory
# Update cmake/linux_package.cmake clang include path
# Update LLVM version in dockerfiles
#### Remarks
* Boost lib dir: rename library directory for your system (e.g.: 'lib32-msvc-12.0') to 'lib'
+7
View File
@@ -50,6 +50,7 @@ function(AddSharedToComponent)
DESTINATION Sourcetrail
PATTERN "log/*" EXCLUDE
PATTERN "data/src" EXCLUDE
PATTERN "data/cxx" EXCLUDE
PATTERN "projects" EXCLUDE
PATTERN "data/install" EXCLUDE
PATTERN "ProjectSettings_template.xml" EXCLUDE
@@ -102,6 +103,12 @@ function(AddSharedToComponent)
DESTINATION Sourcetrail/lib
)
INSTALL(DIRECTORY DESTINATION Sourcetrail/data/cxx/include)
INSTALL(DIRECTORY
$ENV{LLVM_DIR}/lib/clang/6.0.0/include/
DESTINATION Sourcetrail/data/cxx/include
)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/user
DESTINATION Sourcetrail
PATTERN "ApplicationSettings.xml" EXCLUDE
+2
View File
@@ -20,5 +20,7 @@ ln -f -s /opt/sourcetrail/Sourcetrail.sh /usr/bin/sourcetrail
update-mime-database /usr/share/mime > /dev/null
update-desktop-database > /dev/null
mkdir -p ~/.config/sourcetrail
echo "Installation complete."
echo "Enter 'sourcetrail' to launch application."
+2
View File
@@ -79,6 +79,8 @@ cp -R ../../../bin/app/user/projects $RES_DIR/data/fallback/projects
cp -R ../../../bin/app/data/3rd_party_licenses $RES_DIR/3rd_party_licenses
mkdir -p $RES_DIR/data/cxx/include
cp -R ../../../bin/app/data/cxx/include/* $RES_DIR/data/cxx/include
echo -e $INFO "run macdeployqt to copy Qt Frameworks and Plugins"
$QT_DIR/bin/macdeployqt $BUNDLE_PATH
+7
View File
@@ -30,6 +30,7 @@
#include "utility/UserPaths.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "utility/utilityCxx.h"
#include "utility/utilityPathDetection.h"
#include "utility/Version.h"
#include "version.h"
@@ -126,6 +127,12 @@ void prefillCxxHeaderPaths()
{
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
if (utility::getOsType() != OS_WINDOWS)
{
paths = utility::replaceOrAddCxxCompilerHeaderPath(paths);
}
if (!paths.empty())
{
MessageStatus(L"Ran C/C++ header path detection, found " + std::to_wstring(paths.size()) + L" path" +
+3 -1
View File
@@ -529,7 +529,7 @@ add_files(
utility/scheduling/TaskScheduler.cpp
utility/scheduling/TaskScheduler.h
utility/scheduling/TaskSetValue.h
utility/sonargraph/SonargraphProject.cpp
utility/sonargraph/SonargraphProject.h
utility/sonargraph/SonargraphSoftwareSystem.cpp
@@ -594,6 +594,8 @@ add_files(
utility/UserPaths.h
utility/utility.cpp
utility/utility.h
utility/utilityCxx.cpp
utility/utilityCxx.h
utility/utilityFile.cpp
utility/utilityFile.h
utility/utilityLibrary.h
+15 -4
View File
@@ -9,10 +9,11 @@
#include "utility/Status.h"
#include "utility/TimeStamp.h"
#include "utility/utility.h"
#include "utility/utilityCxx.h"
#include "utility/UserPaths.h"
#include "utility/Version.h"
const size_t ApplicationSettings::VERSION = 4;
const size_t ApplicationSettings::VERSION = 5;
std::shared_ptr<ApplicationSettings> ApplicationSettings::s_instance;
@@ -34,9 +35,9 @@ ApplicationSettings::~ApplicationSettings()
{
}
bool ApplicationSettings::load(const FilePath& filePath)
bool ApplicationSettings::load(const FilePath& filePath, bool readOnly)
{
bool loaded = Settings::load(filePath);
bool loaded = Settings::load(filePath, readOnly);
if (!loaded)
{
return false;
@@ -85,9 +86,19 @@ bool ApplicationSettings::load(const FilePath& filePath)
}
}
));
migrator.addMigration(5, std::make_shared<SettingsMigrationLambda>(
[](const SettingsMigration* migration, Settings* settings)
{
std::vector<FilePath> cxxHeaderSearchPaths = migration->getValuesFromSettings(
settings, "indexing/cxx/header_search_paths/header_search_path", std::vector<FilePath>());
cxxHeaderSearchPaths = utility::replaceOrAddCxxCompilerHeaderPath(cxxHeaderSearchPaths);
migration->setValuesInSettings(settings, "indexing/cxx/header_search_paths/header_search_path", cxxHeaderSearchPaths);
}
));
bool migrated = migrator.migrate(this, ApplicationSettings::VERSION);
if (migrated)
{
save();
+1 -1
View File
@@ -20,7 +20,7 @@ public:
ApplicationSettings();
~ApplicationSettings();
bool load(const FilePath& filePath);
bool load(const FilePath& filePath, bool readOnly = false);
bool operator==(const ApplicationSettings& other) const;
+8 -1
View File
@@ -25,8 +25,10 @@ Settings::~Settings()
{
}
bool Settings::load(const FilePath& filePath)
bool Settings::load(const FilePath& filePath, bool readOnly)
{
m_readOnly = readOnly;
if (filePath.exists())
{
m_config = ConfigManager::createAndLoad(TextAccess::createFromFile(filePath));
@@ -44,6 +46,11 @@ bool Settings::load(const FilePath& filePath)
void Settings::save()
{
if (m_readOnly)
{
return;
}
if (m_config.get() && !m_filePath.empty())
{
m_config->save(m_filePath.str());
+2 -1
View File
@@ -17,7 +17,7 @@ public:
Settings& operator=(const Settings& other);
virtual ~Settings();
bool load(const FilePath& filePath);
bool load(const FilePath& filePath, bool readOnly = false);
void save();
void save(const FilePath& filePath);
@@ -63,6 +63,7 @@ protected:
private:
FilePath m_filePath;
bool m_readOnly = false;
friend SettingsMigration;
};
+5
View File
@@ -26,3 +26,8 @@ FilePath ResourcePaths::getJavaPath()
{
return AppPath::getAppPath().concatenate(L"data/java/");
}
FilePath ResourcePaths::getCxxCompilerHeaderPath()
{
return AppPath::getAppPath().concatenate(L"data/cxx/include/");
}
+1
View File
@@ -13,6 +13,7 @@ public:
static FilePath getFontsPath();
static FilePath getGuiPath();
static FilePath getJavaPath();
static FilePath getCxxCompilerHeaderPath();
};
#endif // RESOURCE_PATHS_H
+28
View File
@@ -0,0 +1,28 @@
#include "utility/utilityCxx.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityApp.h"
namespace utility
{
std::vector<FilePath> replaceOrAddCxxCompilerHeaderPath(const std::vector<FilePath>& headerSearchPaths)
{
if (utility::getOsType() == OS_WINDOWS)
{
return headerSearchPaths;
}
std::vector<FilePath> newHeaderSearchPaths;
for (const FilePath& path : headerSearchPaths)
{
if (!path.getConcatenated(L"/stdarg.h").exists())
{
newHeaderSearchPaths.push_back(path);
}
}
newHeaderSearchPaths.push_back(ResourcePaths::getCxxCompilerHeaderPath().getCanonical());
return newHeaderSearchPaths;
}
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef UTILITY_CXX_H
#define UTILITY_CXX_H
#include <vector>
#include <utility/file/FilePath.h>
namespace utility
{
std::vector<FilePath> replaceOrAddCxxCompilerHeaderPath(const std::vector<FilePath>& headerSearchPaths);
}
#endif // UTILITY_CXX_H
@@ -20,7 +20,7 @@ void setupPlatform(int argc, char *argv[])
// Set QT screen scaling factor
ApplicationSettings appSettings;
appSettings.load(UserPaths::getAppSettingsPath());
appSettings.load(UserPaths::getAppSettingsPath(), true);
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR_SOURCETRAIL", qgetenv("QT_AUTO_SCREEN_SCALE_FACTOR"));
qputenv("QT_SCALE_FACTOR_SOURCETRAIL", qgetenv("QT_SCALE_FACTOR"));
@@ -44,10 +44,7 @@ void setupPlatform(int argc, char *argv[])
void setupApp(int argc, char *argv[])
{
if (AppPath::getAppPath().empty())
{
AppPath::setAppPath(FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/"));
}
AppPath::setAppPath(FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute());
std::string userdir(std::getenv("HOME"));
QDir coatiDir((userdir + "/.config/coati").c_str());
@@ -89,8 +89,8 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
: QtProjectWizzardWindow(parent, false)
, m_windowStack(this)
, m_editing(false)
, m_contentWidget(nullptr)
, m_previouslySelectedIndex(-1)
, m_contentWidget(nullptr)
{
setScrollAble(true);
@@ -831,7 +831,7 @@ void QtProjectWizzard::emptySourceGroup()
contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaEmpty, this));
}
if (std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> settingsCrossCompile =
if (std::shared_ptr<SourceGroupSettingsWithCxxCrossCompilationOptions> settingsCrossCompile =
std::dynamic_pointer_cast<SourceGroupSettingsWithCxxCrossCompilationOptions>(m_newSourceGroupSettings))
{
contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCrossCompile, window));
@@ -32,6 +32,7 @@
#include "utility/IncludeProcessing.h"
#include "utility/ScopedFunctor.h"
#include "utility/utility.h"
#include "utility/utilityCxx.h"
#include "utility/utilityFile.h"
#include "utility/utilityPathDetection.h"
#include "utility/utilityString.h"
@@ -198,7 +199,11 @@ void QtProjectWizzardContentPaths::detectionClicked()
{
std::vector<FilePath> paths = m_pathDetector->getPaths(m_detectorBox->currentText().toStdString());
std::vector<FilePath> oldPaths = m_list->getPathsAsDisplayed();
m_list->setPaths(utility::unique(utility::concat(oldPaths, paths)));
paths = utility::unique(utility::concat(oldPaths, paths));
paths = utility::replaceOrAddCxxCompilerHeaderPath(paths);
m_list->setPaths(paths);
}
@@ -418,7 +423,7 @@ void QtProjectWizzardContentIndexedHeaderPaths::populate(QGridLayout* layout, in
void QtProjectWizzardContentIndexedHeaderPaths::load()
{
if (std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> cdbSettings =
if (std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> cdbSettings =
std::dynamic_pointer_cast<SourceGroupSettingsWithIndexedHeaderPaths>(m_settings))
{
m_list->setPaths(cdbSettings->getIndexedHeaderPaths());
@@ -427,7 +432,7 @@ void QtProjectWizzardContentIndexedHeaderPaths::load()
void QtProjectWizzardContentIndexedHeaderPaths::save()
{
if (std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> cdbSettings =
if (std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> cdbSettings =
std::dynamic_pointer_cast<SourceGroupSettingsWithIndexedHeaderPaths>(m_settings))
{
cdbSettings->setIndexedHeaderPaths(m_list->getPathsAsDisplayed());
@@ -441,7 +446,7 @@ bool QtProjectWizzardContentIndexedHeaderPaths::check()
QMessageBox msgBox;
msgBox.setText("You didn't specify any Header Files & Directories to Index.");
msgBox.setInformativeText(QString::fromStdString(
"Sourcetrail will only index the source files listed in the " + m_projectKindName +
"Sourcetrail will only index the source files listed in the " + m_projectKindName +
" file and none of the included header files."
));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
@@ -714,7 +719,7 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked()
{
// TODO: regard Force Includes here, too!
m_window->saveContent();
std::thread([&]()
{
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> extensionSettings = std::dynamic_pointer_cast<SourceGroupSettingsWithSourceExtensions>(m_settings);
@@ -786,7 +791,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP
// TODO: regard Force Includes here, too!
const std::vector<FilePath> searchedPaths = m_settings->makePathsExpandedAndAbsolute(m_pathsDialog->getPaths());
closedPathsDialog();
std::thread([=]()
{
std::shared_ptr<SourceGroupSettingsWithSourceExtensions> extensionSettings = std::dynamic_pointer_cast<SourceGroupSettingsWithSourceExtensions>(m_settings);
+1 -1
View File
@@ -41,7 +41,7 @@ add_files(
UtilityStringTestSuite.h
UtilityTestSuite.h
Vector2TestSuite.h
# Java tests need to be executed last because of some linux related issues.
JavaParserTestSuite.h
JavaIndexSampleProjectsTestSuite.h