ui: added initial auto-detection for cpp standard headers and java runtime library
* when Coati is started with no java-path or global cxx header or framework paths in the appsettings they are auto-detected using the first working detector * order in which the detectors are shown in gui now matches the order they are added to the combined detector.
This commit is contained in:
+61
-8
@@ -1,10 +1,3 @@
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "ProjectFactoryModuleC.h"
|
||||
#include "ProjectFactoryModuleCpp.h"
|
||||
@@ -17,8 +10,61 @@
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewFactory.h"
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/commandline/CommandLineParser.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
#include "utility/Version.h"
|
||||
#include "version.h"
|
||||
|
||||
void prefillJavaRuntimePath()
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
if (settings->getJavaPath().empty())
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> javaPathDetector = utility::getJavaRuntimePathDetector();
|
||||
std::vector<FilePath> paths = javaPathDetector->getPaths();
|
||||
if (!paths.empty())
|
||||
{
|
||||
settings->setJavaPath(paths.front().str());
|
||||
settings->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prefillCxxHeaderPaths()
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
if (settings->getHeaderSearchPaths().empty())
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
|
||||
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
|
||||
if (!paths.empty())
|
||||
{
|
||||
settings->setHeaderSearchPaths(paths);
|
||||
settings->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prefillCxxFrameworkPaths()
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
if (settings->getFrameworkSearchPaths().empty())
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> cxxFrameworkDetector = utility::getCxxFrameworkPathDetector();
|
||||
std::vector<FilePath> paths = cxxFrameworkDetector->getPaths();
|
||||
if (!paths.empty())
|
||||
{
|
||||
settings->setFrameworkSearchPaths(paths);
|
||||
settings->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setApplicationName("Coati");
|
||||
@@ -51,6 +97,10 @@ int main(int argc, char *argv[])
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
prefillJavaRuntimePath();
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
|
||||
@@ -90,6 +140,10 @@ int main(int argc, char *argv[])
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
prefillJavaRuntimePath();
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
|
||||
@@ -102,4 +156,3 @@ int main(int argc, char *argv[])
|
||||
return qtApp.exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,4 +194,6 @@ add_files(
|
||||
|
||||
utility/utilityApp.cpp
|
||||
utility/utilityApp.h
|
||||
utility/utilityPathDetection.cpp
|
||||
utility/utilityPathDetection.h
|
||||
)
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#include "utility/CompilationDatabase.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/path_detector/cxx_header/CxxFrameworkPathDetector.h"
|
||||
#include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h"
|
||||
#include "utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
|
||||
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
@@ -364,17 +362,7 @@ QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHead
|
||||
"Finding System Header Locations</a> or use the auto detection below)."
|
||||
);
|
||||
|
||||
m_pathDetector = std::make_shared<CombinedPathDetector>();
|
||||
m_pathDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("gcc"));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("clang"));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true));
|
||||
m_pathDetector = utility::getCxxHeaderPathDetector();
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsHeaderSearchGlobal::load()
|
||||
@@ -439,9 +427,7 @@ QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsF
|
||||
"Finding System Header Locations</a> or use the auto detection below)."
|
||||
);
|
||||
|
||||
m_pathDetector = std::make_shared<CombinedPathDetector>();
|
||||
m_pathDetector->addDetector(std::make_shared<CxxFrameworkPathDetector>("gcc"));
|
||||
m_pathDetector->addDetector(std::make_shared<CxxFrameworkPathDetector>("clang"));
|
||||
m_pathDetector = utility::getCxxFrameworkPathDetector();
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsFrameworkSearchGlobal::load()
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorLinux.h"
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
|
||||
QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
@@ -217,19 +215,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
);
|
||||
row++;
|
||||
|
||||
m_javaPathDetector = std::make_shared<CombinedPathDetector>();
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_javaPathDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8"));
|
||||
}
|
||||
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
m_javaPathDetector->addDetector(std::make_shared<JavaPathDetectorMac>("1.8"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_javaPathDetector->addDetector(std::make_shared<JavaPathDetectorLinux>("1.8"));
|
||||
}
|
||||
m_javaPathDetector = utility::getJavaRuntimePathDetector();
|
||||
addJavaPathDetection(layout, row);
|
||||
|
||||
layout->setRowMinimumHeight(row, 20);
|
||||
@@ -350,7 +336,7 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
|
||||
void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layout, int& row)
|
||||
{
|
||||
std::vector<std::string> detectorNames = m_javaPathDetector->getWorkingDetectorNames();
|
||||
if (!detectorNames.size())
|
||||
if (detectorNames.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,29 +11,27 @@ CombinedPathDetector::~CombinedPathDetector()
|
||||
|
||||
void CombinedPathDetector::addDetector(std::shared_ptr<PathDetector> detector)
|
||||
{
|
||||
m_detectors[detector->getName()] = detector;
|
||||
m_detectors.push_back(detector);
|
||||
}
|
||||
|
||||
std::vector<std::string> CombinedPathDetector::getWorkingDetectorNames()
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
|
||||
for (DetectorPair detectorEntry: m_detectors)
|
||||
for (std::shared_ptr<PathDetector> detector: m_detectors)
|
||||
{
|
||||
if (detectorEntry.second->isWorking())
|
||||
if (detector->isWorking())
|
||||
{
|
||||
names.push_back(detectorEntry.first);
|
||||
names.push_back(detector->getName());
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
std::vector<FilePath> CombinedPathDetector::getPaths() const
|
||||
{
|
||||
for (DetectorPair detectorEntry: m_detectors)
|
||||
for (std::shared_ptr<PathDetector> detector: m_detectors)
|
||||
{
|
||||
std::vector<FilePath> detectedPaths = detectorEntry.second->getPaths();
|
||||
std::vector<FilePath> detectedPaths = detector->getPaths();
|
||||
if (!detectedPaths.empty())
|
||||
{
|
||||
return detectedPaths;
|
||||
@@ -44,11 +42,12 @@ std::vector<FilePath> CombinedPathDetector::getPaths() const
|
||||
|
||||
std::vector<FilePath> CombinedPathDetector::getPaths(std::string detectorName) const
|
||||
{
|
||||
std::vector<FilePath> paths;
|
||||
DetectorMap::const_iterator it = m_detectors.find(detectorName);
|
||||
if (it != m_detectors.end())
|
||||
for (std::shared_ptr<PathDetector> detector: m_detectors)
|
||||
{
|
||||
paths = it->second->getPaths();
|
||||
if (detector->getName() == detectorName)
|
||||
{
|
||||
return detector->getPaths();
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
return std::vector<FilePath>();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ public:
|
||||
std::vector<FilePath> getPaths(std::string detectorName) const;
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, std::shared_ptr<PathDetector>> DetectorMap;
|
||||
typedef std::pair<std::string, std::shared_ptr<PathDetector>> DetectorPair;
|
||||
|
||||
DetectorMap m_detectors;
|
||||
std::vector<std::shared_ptr<PathDetector>> m_detectors;
|
||||
};
|
||||
|
||||
#endif // COMBINED_PATH_DETECTOR_H
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "utility/utilityPathDetection.h"
|
||||
|
||||
#include <QSysInfo>
|
||||
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorLinux.h"
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
|
||||
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
|
||||
|
||||
#include "utility/path_detector/cxx_header/CxxFrameworkPathDetector.h"
|
||||
#include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h"
|
||||
#include "utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h"
|
||||
|
||||
std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8"));
|
||||
}
|
||||
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorMac>("1.8"));
|
||||
}
|
||||
else
|
||||
{
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorLinux>("1.8"));
|
||||
}
|
||||
|
||||
return combinedDetector;
|
||||
}
|
||||
|
||||
std::shared_ptr<CombinedPathDetector> utility::getCxxHeaderPathDetector()
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
|
||||
combinedDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("gcc"));
|
||||
combinedDetector->addDetector(std::make_shared<CxxHeaderPathDetector>("clang"));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, false));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(14, true));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, false));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(12, true));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, false));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(11, true));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, false));
|
||||
combinedDetector->addDetector(std::make_shared<CxxVsHeaderPathDetector>(9, true));
|
||||
return combinedDetector;
|
||||
}
|
||||
|
||||
std::shared_ptr<CombinedPathDetector> utility::getCxxFrameworkPathDetector()
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
|
||||
combinedDetector->addDetector(std::make_shared<CxxFrameworkPathDetector>("gcc"));
|
||||
combinedDetector->addDetector(std::make_shared<CxxFrameworkPathDetector>("clang"));
|
||||
return combinedDetector;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef UTILITY_PATH_DETECTION_H
|
||||
#define UTILITY_PATH_DETECTION_H
|
||||
|
||||
#include "utility/path_detector/CombinedPathDetector.h"
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::shared_ptr<CombinedPathDetector> getJavaRuntimePathDetector();
|
||||
std::shared_ptr<CombinedPathDetector> getCxxHeaderPathDetector();
|
||||
std::shared_ptr<CombinedPathDetector> getCxxFrameworkPathDetector();
|
||||
}
|
||||
|
||||
|
||||
#endif // UTILITY_PATH_DETECTION_H
|
||||
|
||||
Reference in New Issue
Block a user