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:
malte_langkabel
2016-10-12 19:10:03 +02:00
parent c018020a73
commit 97b151371b
8 changed files with 151 additions and 59 deletions
@@ -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