diff --git a/src/app/main.cpp b/src/app/main.cpp index fcfaa772..775d1954 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -20,6 +20,9 @@ #include "settings/ProjectSettings.h" + +#include "utility/headerSearch/StandardHeaderDetection.h" + void init() { std::shared_ptr consoleLogger = std::make_shared(); @@ -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 app = Application::create(version, &viewFactory, &networkFactory); diff --git a/src/app/utility/headerSearch/CompilerDetector.cpp b/src/app/utility/headerSearch/CompilerDetector.cpp index f0836d3d..2c616a5c 100644 --- a/src/app/utility/headerSearch/CompilerDetector.cpp +++ b/src/app/utility/headerSearch/CompilerDetector.cpp @@ -30,3 +30,8 @@ std::vector CompilerDetector::getStandardHeaderPaths() return paths; } +// Add Gcc to Available Detectors +static StandardHeaderDetection::Add gcc("gcc"); +// Add Clang to Available Detectors +static StandardHeaderDetection::Add clang("clang"); + diff --git a/src/app/utility/headerSearch/CompilerDetector.h b/src/app/utility/headerSearch/CompilerDetector.h index 97a2e63b..c972c66b 100644 --- a/src/app/utility/headerSearch/CompilerDetector.h +++ b/src/app/utility/headerSearch/CompilerDetector.h @@ -13,8 +13,5 @@ public: private: }; -static StandardHeaderDetection::Add gcc("gcc"); -static StandardHeaderDetection::Add clang("clang"); -static StandardHeaderDetection::Add fakecomplier("fakecompiler"); #endif // COMPILER_DETECTOR_H diff --git a/src/app/utility/headerSearch/StandardHeaderDetection.cpp b/src/app/utility/headerSearch/StandardHeaderDetection.cpp index a7844cf6..08a98fcb 100644 --- a/src/app/utility/headerSearch/StandardHeaderDetection.cpp +++ b/src/app/utility/headerSearch/StandardHeaderDetection.cpp @@ -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 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 path; - //path.push_back(VSHeaderPath.str()); - //m_standardHeaderPaths.insert(std::make_pair(version, path)); - //return true; - //} - //} - //return false; -//} - diff --git a/src/app/utility/headerSearch/StandardHeaderDetection.h b/src/app/utility/headerSearch/StandardHeaderDetection.h index ab1b1aff..0559f6a8 100644 --- a/src/app/utility/headerSearch/StandardHeaderDetection.h +++ b/src/app/utility/headerSearch/StandardHeaderDetection.h @@ -42,6 +42,7 @@ public: } }; + /// Debugging Output void printAvailableDetectors(); void printdetectedCompilers(); private: diff --git a/src/app/utility/headerSearch/VisualStudioDetector.cpp b/src/app/utility/headerSearch/VisualStudioDetector.cpp index 749f4d64..79f15bc3 100644 --- a/src/app/utility/headerSearch/VisualStudioDetector.cpp +++ b/src/app/utility/headerSearch/VisualStudioDetector.cpp @@ -1,59 +1,64 @@ #include "utility/headerSearch/VisualStudioDetector.h" #include +#include +#include #include #include "utility/file/FilePath.h" #include "utility/logging/logging.h" #include "utility/headerSearch/StandardHeaderDetection.h" +#include 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 VisualStudioDetector::getStandardHeaderPaths() { - QSettings registry; - std::string vstoolstring = m_name + "COMNTOOLS"; - std::vector path; - if( const char* vs_env = std::getenv(vstoolstring.c_str())) + std::vector 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& paths) { - QSettings expressKey("HKLM\\SOFTWARE\\Microsoft\\Visual Studio\\", QSettings::NativeFormat); + std::string VSToolstring = m_name + "comntools"; + std::vector 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& 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 vs2015("VS140"); -static StandardHeaderDetection::Add vs2013("VS120"); -static StandardHeaderDetection::Add vs2012("VS110"); -static StandardHeaderDetection::Add vs2010("VS90"); +static StandardHeaderDetection::Add vs2015("14"); +static StandardHeaderDetection::Add vs2013("12"); +static StandardHeaderDetection::Add vs2012("11"); +static StandardHeaderDetection::Add vs2010("9"); diff --git a/src/app/utility/headerSearch/VisualStudioDetector.h b/src/app/utility/headerSearch/VisualStudioDetector.h index 29995b28..579df7c7 100644 --- a/src/app/utility/headerSearch/VisualStudioDetector.h +++ b/src/app/utility/headerSearch/VisualStudioDetector.h @@ -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 getStandardHeaderPaths(); private: std::string getFullName(); - void setName(const std::string& name); + bool getStanardHeaderPathsUsingEnvironmentVariable(std::vector& paths); + bool getStanardHeaderPathsUsingRegistry(std::vector& paths, bool lookForExpressVersion = false); + + void setName(const std::string& version); int m_versionNumber; + bool m_isExpress; }; #endif // VISUAL_STUDIO_DETECTOR_H