utility: Standardheadersearch
Standardheadersearch for clang and gcc TODO: Visual Studio & Windows Kit bzw SDK
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
|
||||
#include "utility/headerSearch/StandardHeaderDetection.h"
|
||||
|
||||
void init()
|
||||
{
|
||||
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
|
||||
@@ -83,6 +86,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
LicenseChecker checker;
|
||||
|
||||
StandardHeaderDetection detection;
|
||||
detection.printdetectedCompilers();
|
||||
detection.printAvailableDetectors();
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
|
||||
|
||||
@@ -30,3 +30,8 @@ std::vector<FilePath> CompilerDetector::getStandardHeaderPaths()
|
||||
return paths;
|
||||
}
|
||||
|
||||
// Add Gcc to Available Detectors
|
||||
static StandardHeaderDetection::Add<CompilerDetector> gcc("gcc");
|
||||
// Add Clang to Available Detectors
|
||||
static StandardHeaderDetection::Add<CompilerDetector> clang("clang");
|
||||
|
||||
|
||||
@@ -13,8 +13,5 @@ public:
|
||||
private:
|
||||
};
|
||||
|
||||
static StandardHeaderDetection::Add<CompilerDetector> gcc("gcc");
|
||||
static StandardHeaderDetection::Add<CompilerDetector> clang("clang");
|
||||
static StandardHeaderDetection::Add<CompilerDetector> fakecomplier("fakecompiler");
|
||||
|
||||
#endif // COMPILER_DETECTOR_H
|
||||
|
||||
@@ -85,44 +85,3 @@ void StandardHeaderDetection::printAvailableDetectors()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//bool StandardHeaderDetection::detectFromCompiler(const std::string& compiler)
|
||||
//{
|
||||
//LOG_INFO("Searching for " + compiler + " include paths");
|
||||
//std::string command = compiler + " -x c++ -v -E /dev/null";
|
||||
//std::string clangOutput = utility::executeProcess(command.c_str());
|
||||
//std::string standardHeaders = utility::substrBetween(clangOutput, "#include <...> search starts here:\n","\nEnd of search list");
|
||||
//if(standardHeaders.empty())
|
||||
//{
|
||||
//return false;
|
||||
//}
|
||||
//std::vector<FilePath> paths;
|
||||
//for(std::string s : utility::splitToVector(standardHeaders, '\n'))
|
||||
//{
|
||||
//paths.push_back(s);
|
||||
//}
|
||||
//m_standardHeaderPaths.insert(std::make_pair(compiler, paths));
|
||||
//LOG_INFO(compiler + " standard headers detected");
|
||||
//return true;
|
||||
//}
|
||||
|
||||
//bool StandardHeaderDetection::detectVisualStudioVersion(const std::string& version)
|
||||
//{
|
||||
//LOG_INFO_STREAM(<< "Searching for Visual Studio Includes from Version: " << version);
|
||||
//std::string vstoolstring = version + "COMNTOOLS";
|
||||
//if( const char* vs_env = std::getenv(vstoolstring.c_str()))
|
||||
//{
|
||||
//FilePath VSHeaderPath(vs_env);
|
||||
//VSHeaderPath = VSHeaderPath.concat("../VC/include");
|
||||
//if(VSHeaderPath.exists())
|
||||
//{
|
||||
//LOG_INFO_STREAM(<< "Visual Studio 20" << version.substr(2,version.length()-3) << " includes detected");
|
||||
//std::vector<FilePath> path;
|
||||
//path.push_back(VSHeaderPath.str());
|
||||
//m_standardHeaderPaths.insert(std::make_pair(version, path));
|
||||
//return true;
|
||||
//}
|
||||
//}
|
||||
//return false;
|
||||
//}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// Debugging Output
|
||||
void printAvailableDetectors();
|
||||
void printdetectedCompilers();
|
||||
private:
|
||||
|
||||
@@ -1,59 +1,64 @@
|
||||
#include "utility/headerSearch/VisualStudioDetector.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QSysInfo>
|
||||
#include <QDir>
|
||||
|
||||
#include <string>
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/headerSearch/StandardHeaderDetection.h"
|
||||
#include <iostream>
|
||||
|
||||
VisualStudioDetector::VisualStudioDetector(const std::string name)
|
||||
: DetectorBase(name)
|
||||
: DetectorBase("")
|
||||
, m_isExpress(false)
|
||||
{
|
||||
setName(name);
|
||||
}
|
||||
|
||||
VisualStudioDetector::~VisualStudioDetector()
|
||||
{
|
||||
}
|
||||
|
||||
void VisualStudioDetector::setName(const std::string& name)
|
||||
void VisualStudioDetector::setName(const std::string& version)
|
||||
{
|
||||
if (name.substr(0,2) == "VS")
|
||||
m_versionNumber = std::stoi(version);
|
||||
if (m_versionNumber > 8 && m_versionNumber < 15)
|
||||
{
|
||||
m_versionNumber = std::stoi(name.substr(2,name.size()-3).c_str());
|
||||
if (m_versionNumber == 0)
|
||||
{
|
||||
// no version
|
||||
}
|
||||
DetectorBase::setName(name);
|
||||
DetectorBase::setName("VS" + version + "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// invalid Visual Studio detector name
|
||||
// unsupported Visual Studio version
|
||||
}
|
||||
}
|
||||
|
||||
std::string VisualStudioDetector::getFullName()
|
||||
{
|
||||
return "Visual Studio " + std::to_string(m_versionNumber + 1);
|
||||
return "Visual Studio " + std::to_string(m_versionNumber + 1) + (m_isExpress ? " Express" : "");
|
||||
}
|
||||
|
||||
std::vector<FilePath> VisualStudioDetector::getStandardHeaderPaths()
|
||||
{
|
||||
QSettings registry;
|
||||
std::string vstoolstring = m_name + "COMNTOOLS";
|
||||
std::vector<FilePath> path;
|
||||
if( const char* vs_env = std::getenv(vstoolstring.c_str()))
|
||||
std::vector<FilePath> headerPaths;
|
||||
// vc++ headers
|
||||
if ( !getStanardHeaderPathsUsingEnvironmentVariable(headerPaths) )
|
||||
{
|
||||
FilePath VSHeaderPath(vs_env);
|
||||
VSHeaderPath = VSHeaderPath.concat("../VC/include");
|
||||
if(VSHeaderPath.exists())
|
||||
if ( !getStanardHeaderPathsUsingRegistry(headerPaths) )
|
||||
{
|
||||
LOG_INFO_STREAM(<< getFullName() << " includes detected");
|
||||
path.push_back(VSHeaderPath.str());
|
||||
if ( !getStanardHeaderPathsUsingRegistry(headerPaths, true) )
|
||||
{
|
||||
return headerPaths;
|
||||
}
|
||||
}
|
||||
}
|
||||
return path;
|
||||
|
||||
//windows sdk
|
||||
//TODO
|
||||
|
||||
|
||||
return headerPaths;
|
||||
}
|
||||
|
||||
std::string getInstallDir(const std::string RegistryKey)
|
||||
@@ -63,23 +68,58 @@ std::string getInstallDir(const std::string RegistryKey)
|
||||
|
||||
std::string getWindowsSDKDir()
|
||||
{
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
bool searchForExpress()
|
||||
bool VisualStudioDetector::getStanardHeaderPathsUsingEnvironmentVariable(std::vector<FilePath>& paths)
|
||||
{
|
||||
QSettings expressKey("HKLM\\SOFTWARE\\Microsoft\\Visual Studio\\", QSettings::NativeFormat);
|
||||
std::string VSToolstring = m_name + "comntools";
|
||||
std::vector<FilePath> path;
|
||||
|
||||
if ( const char* vs_env = std::getenv(VSToolstring.c_str()))
|
||||
{
|
||||
FilePath VSHeaderpath(vs_env);
|
||||
VSHeaderpath = VSHeaderpath.concat("../vc/include");
|
||||
if (VSHeaderpath.exists())
|
||||
{
|
||||
LOG_INFO_STREAM(<< getFullName() << " includes detected");
|
||||
path.push_back(VSHeaderpath.str());
|
||||
paths = std::move(path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool searchForStandard()
|
||||
bool VisualStudioDetector::getStanardHeaderPathsUsingRegistry(std::vector<FilePath>& paths, bool lookForExpressVersion)
|
||||
{
|
||||
QString key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\";
|
||||
if (QSysInfo::currentCpuArchitecture() == "x86_64")
|
||||
{
|
||||
key += "Wow6432Node\\";
|
||||
}
|
||||
key += "Microsoft\\";
|
||||
key += ( lookForExpressVersion ? "VCExpress" : "VisualStudio" );
|
||||
key += "\\" + QString::number(m_versionNumber) + ".0";
|
||||
|
||||
QSettings expressKey(key, QSettings::NativeFormat);
|
||||
QString value = expressKey.value("InstallDir").toString() + "../VC/include";
|
||||
QDir dir(value);
|
||||
if ( dir.exists())
|
||||
{
|
||||
if ( lookForExpressVersion )
|
||||
{
|
||||
m_isExpress = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add Visual Studio Version to the available detectors
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2015("VS140");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2013("VS120");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2012("VS110");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2010("VS90");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2015("14");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2013("12");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2012("11");
|
||||
static StandardHeaderDetection::Add<VisualStudioDetector> vs2010("9");
|
||||
|
||||
|
||||
@@ -9,13 +9,17 @@ class FilePath;
|
||||
class VisualStudioDetector : public DetectorBase
|
||||
{
|
||||
public:
|
||||
VisualStudioDetector(const std::string name = "VS140");
|
||||
VisualStudioDetector(const std::string name = "14");
|
||||
virtual ~VisualStudioDetector();
|
||||
virtual std::vector<FilePath> getStandardHeaderPaths();
|
||||
private:
|
||||
std::string getFullName();
|
||||
void setName(const std::string& name);
|
||||
bool getStanardHeaderPathsUsingEnvironmentVariable(std::vector<FilePath>& paths);
|
||||
bool getStanardHeaderPathsUsingRegistry(std::vector<FilePath>& paths, bool lookForExpressVersion = false);
|
||||
|
||||
void setName(const std::string& version);
|
||||
int m_versionNumber;
|
||||
bool m_isExpress;
|
||||
};
|
||||
|
||||
#endif // VISUAL_STUDIO_DETECTOR_H
|
||||
|
||||
Reference in New Issue
Block a user