diff --git a/.gitignore b/.gitignore index 4f2975b3..c48ba6b9 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index a3c0e1da..cee66c70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index e846e01e..7bbbe45d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ For MacOS and Linux * QT_DIR - .../Qt/Qt5.10.1/5.10.1/ +* 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' diff --git a/cmake/linux_package.cmake b/cmake/linux_package.cmake index 0769f92d..74bb6f10 100644 --- a/cmake/linux_package.cmake +++ b/cmake/linux_package.cmake @@ -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 diff --git a/setup/Linux/install.sh b/setup/Linux/install.sh index 8a81396f..b97e0382 100755 --- a/setup/Linux/install.sh +++ b/setup/Linux/install.sh @@ -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." diff --git a/setup/MacOSX/bundle_install.sh.in b/setup/MacOSX/bundle_install.sh.in index ec51176a..d7ff04a7 100755 --- a/setup/MacOSX/bundle_install.sh.in +++ b/setup/MacOSX/bundle_install.sh.in @@ -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 diff --git a/src/app/main.cpp b/src/app/main.cpp index 83f40e43..d2e5acf7 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -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 cxxHeaderDetector = utility::getCxxHeaderPathDetector(); std::vector 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" + diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 97ab22e6..5ec92044 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -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 diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 267bc48e..732aa694 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -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::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( + [](const SettingsMigration* migration, Settings* settings) + { + std::vector cxxHeaderSearchPaths = migration->getValuesFromSettings( + settings, "indexing/cxx/header_search_paths/header_search_path", std::vector()); + + 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(); diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index 4497496c..ff17f06f 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -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; diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp index b6699a45..bd22122a 100644 --- a/src/lib/settings/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -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()); diff --git a/src/lib/settings/Settings.h b/src/lib/settings/Settings.h index d13364fa..e6653ecd 100644 --- a/src/lib/settings/Settings.h +++ b/src/lib/settings/Settings.h @@ -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; }; diff --git a/src/lib/utility/ResourcePaths.cpp b/src/lib/utility/ResourcePaths.cpp index 63d2bdb6..9d65b738 100644 --- a/src/lib/utility/ResourcePaths.cpp +++ b/src/lib/utility/ResourcePaths.cpp @@ -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/"); +} diff --git a/src/lib/utility/ResourcePaths.h b/src/lib/utility/ResourcePaths.h index d573c97a..006194db 100644 --- a/src/lib/utility/ResourcePaths.h +++ b/src/lib/utility/ResourcePaths.h @@ -13,6 +13,7 @@ public: static FilePath getFontsPath(); static FilePath getGuiPath(); static FilePath getJavaPath(); + static FilePath getCxxCompilerHeaderPath(); }; #endif // RESOURCE_PATHS_H diff --git a/src/lib/utility/utilityCxx.cpp b/src/lib/utility/utilityCxx.cpp new file mode 100644 index 00000000..1841435e --- /dev/null +++ b/src/lib/utility/utilityCxx.cpp @@ -0,0 +1,28 @@ +#include "utility/utilityCxx.h" + +#include "utility/ResourcePaths.h" +#include "utility/utilityApp.h" + +namespace utility +{ + std::vector replaceOrAddCxxCompilerHeaderPath(const std::vector& headerSearchPaths) + { + if (utility::getOsType() == OS_WINDOWS) + { + return headerSearchPaths; + } + + std::vector 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; + } +} diff --git a/src/lib/utility/utilityCxx.h b/src/lib/utility/utilityCxx.h new file mode 100644 index 00000000..a2f063d3 --- /dev/null +++ b/src/lib/utility/utilityCxx.h @@ -0,0 +1,13 @@ +#ifndef UTILITY_CXX_H +#define UTILITY_CXX_H + +#include + +#include + +namespace utility +{ + std::vector replaceOrAddCxxCompilerHeaderPath(const std::vector& headerSearchPaths); +} + +#endif // UTILITY_CXX_H diff --git a/src/lib_gui/platform_includes/includesLinux.h b/src/lib_gui/platform_includes/includesLinux.h index f6c70ef7..faf3fc4c 100644 --- a/src/lib_gui/platform_includes/includesLinux.h +++ b/src/lib_gui/platform_includes/includesLinux.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()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 063c8de2..b96f95e1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -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 settingsCrossCompile = + if (std::shared_ptr settingsCrossCompile = std::dynamic_pointer_cast(m_newSourceGroupSettings)) { contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCrossCompile, window)); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index f23ab8af..4d719f0e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -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 paths = m_pathDetector->getPaths(m_detectorBox->currentText().toStdString()); std::vector 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 cdbSettings = + if (std::shared_ptr cdbSettings = std::dynamic_pointer_cast(m_settings)) { m_list->setPaths(cdbSettings->getIndexedHeaderPaths()); @@ -427,7 +432,7 @@ void QtProjectWizzardContentIndexedHeaderPaths::load() void QtProjectWizzardContentIndexedHeaderPaths::save() { - if (std::shared_ptr cdbSettings = + if (std::shared_ptr cdbSettings = std::dynamic_pointer_cast(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 extensionSettings = std::dynamic_pointer_cast(m_settings); @@ -786,7 +791,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP // TODO: regard Force Includes here, too! const std::vector searchedPaths = m_settings->makePathsExpandedAndAbsolute(m_pathsDialog->getPaths()); closedPathsDialog(); - + std::thread([=]() { std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 258f3d25..2ace570a 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -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