logic: ship clang compiler header within Sourcetrail package on Windows

* added clang system headers to data folder of Sourcetrail repo
* added clang system header search directory to detected directories on windows
* updated migration to add clang system header search directory on windows
* updated windows installer and portable package to include compiler headers
* updated linux package
* cleaned code of path detectors
* unrelated removal of unnecessary code in LicenseChecker and UpdateChecker
This commit is contained in:
mlangkabel
2018-07-23 15:14:07 +02:00
parent 637857fb56
commit 20086d14a6
154 changed files with 179919 additions and 183 deletions
-5
View File
@@ -128,11 +128,6 @@ void prefillCxxHeaderPaths()
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
std::vector<FilePath> 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" +
-4
View File
@@ -24,10 +24,6 @@ std::shared_ptr<LicenseChecker> LicenseChecker::getInstance()
return s_instance;
}
LicenseChecker::~LicenseChecker()
{
}
std::string LicenseChecker::getCurrentLicenseString() const
{
License license;
+1 -1
View File
@@ -21,7 +21,7 @@ public:
static void createInstance();
static std::shared_ptr<LicenseChecker> getInstance();
~LicenseChecker();
~LicenseChecker() = default;
std::string getCurrentLicenseString() const;
void saveCurrentLicenseString(const std::string& licenseString) const;
+1 -2
View File
@@ -4,8 +4,7 @@
class UpdateChecker
{
public:
virtual ~UpdateChecker() {}
virtual ~UpdateChecker() = default;
virtual void checkUpdate() = 0;
};
+10 -8
View File
@@ -7,18 +7,20 @@ namespace utility
{
std::vector<FilePath> replaceOrAddCxxCompilerHeaderPath(const std::vector<FilePath>& headerSearchPaths)
{
if (utility::getOsType() == OS_WINDOWS)
{
return headerSearchPaths;
}
std::vector<FilePath> newHeaderSearchPaths;
for (const FilePath& path : headerSearchPaths)
if (utility::getOsType() == OS_WINDOWS)
{
if (!path.getConcatenated(L"/stdarg.h").exists())
newHeaderSearchPaths = headerSearchPaths;
}
else
{
for (const FilePath& path : headerSearchPaths)
{
newHeaderSearchPaths.push_back(path);
if (!path.getConcatenated(L"/stdarg.h").exists())
{
newHeaderSearchPaths.push_back(path);
}
}
}
+13 -6
View File
@@ -13,6 +13,7 @@
#include "utility/file/FileRegister.h"
#include "utility/logging/logging.h"
#include "utility/text/TextAccess.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "utility/utility.h"
@@ -70,11 +71,8 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
clang::tooling::CompileCommand compileCommand;
compileCommand.Filename = utility::encodeToUtf8(indexerCommand->getSourceFilePath().wstr());
compileCommand.Directory = utility::encodeToUtf8(indexerCommand->getWorkingDirectory().wstr());
compileCommand.CommandLine = utility::concat(
utility::convert<std::wstring, std::string>(indexerCommand->getCompilerFlags(), [](const std::wstring & flag) { return utility::encodeToUtf8(flag); }),
getCommandlineArgumentsEssential(
std::vector<std::wstring>(), indexerCommand->getSystemHeaderSearchPaths(), indexerCommand->getFrameworkSearchPaths()
)
compileCommand.CommandLine = getCommandlineArgumentsEssential(
indexerCommand->getCompilerFlags(), indexerCommand->getSystemHeaderSearchPaths(), indexerCommand->getFrameworkSearchPaths()
);
if (!utility::isPrefix<std::string>("-", compileCommand.CommandLine.front()))
@@ -134,7 +132,9 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase
}
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(
const std::vector<std::wstring>& compilerFlags, const std::vector<FilePath>& systemHeaderSearchPaths, const std::vector<FilePath>& frameworkSearchPaths
const std::vector<std::wstring>& compilerFlags,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths
) const {
std::vector<std::string> args;
@@ -164,6 +164,13 @@ std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(
for (const FilePath& path : systemHeaderSearchPaths)
{
#ifdef _WIN32
if (path == ResourcePaths::getCxxCompilerHeaderPath())
{
args = utility::concat({ "-isystem" , utility::encodeToUtf8(path.wstr()) }, args);
continue;
}
#endif
args.push_back("-isystem");
args.push_back(utility::encodeToUtf8(path.wstr()));
}
@@ -201,7 +201,6 @@ void QtProjectWizzardContentPaths::detectionClicked()
std::vector<FilePath> oldPaths = m_list->getPathsAsDisplayed();
paths = utility::unique(utility::concat(oldPaths, paths));
paths = utility::replaceOrAddCxxCompilerHeaderPath(paths);
m_list->setPaths(paths);
}
@@ -7,10 +7,6 @@ CombinedPathDetector::CombinedPathDetector()
{
}
CombinedPathDetector::~CombinedPathDetector()
{
}
void CombinedPathDetector::addDetector(std::shared_ptr<PathDetector> detector)
{
m_detectors.push_back(detector);
@@ -12,13 +12,12 @@ class CombinedPathDetector: public PathDetector
{
public:
CombinedPathDetector();
virtual ~CombinedPathDetector();
void addDetector(std::shared_ptr<PathDetector> detector);
std::vector<std::string> getWorkingDetectorNames();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
std::vector<FilePath> getPaths(std::string detectorName) const;
private:
@@ -7,10 +7,6 @@ PathDetector::PathDetector(const std::string& name)
{
}
PathDetector::~PathDetector()
{
}
std::string PathDetector::getName() const
{
return m_name;
@@ -10,7 +10,7 @@ class PathDetector
{
public:
PathDetector(const std::string& name);
virtual ~PathDetector();
virtual ~PathDetector() = default;
std::string getName() const;
bool isWorking() const;
@@ -10,10 +10,6 @@ CxxFrameworkPathDetector::CxxFrameworkPathDetector(const std::string& compilerNa
{
}
CxxFrameworkPathDetector::~CxxFrameworkPathDetector()
{
}
std::vector<FilePath> CxxFrameworkPathDetector::getPaths() const
{
std::vector<std::string> paths = utility::getCxxHeaderPaths(m_compilerName);
@@ -7,9 +7,7 @@ class CxxFrameworkPathDetector: public PathDetector
{
public:
CxxFrameworkPathDetector(const std::string& compilerName);
virtual ~CxxFrameworkPathDetector();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
private:
const std::string m_compilerName;
@@ -3,6 +3,7 @@
#include "utility/file/FilePath.h"
#include "utility/path_detector/cxx_header/utilityCxxHeaderDetection.h"
#include "utility/utilityString.h"
#include "utility/utilityCxx.h"
CxxHeaderPathDetector::CxxHeaderPathDetector(const std::string& compilerName)
: PathDetector(compilerName)
@@ -10,20 +11,17 @@ CxxHeaderPathDetector::CxxHeaderPathDetector(const std::string& compilerName)
{
}
CxxHeaderPathDetector::~CxxHeaderPathDetector()
{
}
std::vector<FilePath> CxxHeaderPathDetector::getPaths() const
{
std::vector<std::string> paths = utility::getCxxHeaderPaths(m_compilerName);
std::vector<FilePath> headerPaths;
std::vector<FilePath> headerSearchPaths;
for (const std::string& path : paths)
{
if (!utility::isPostfix<std::string>(" (framework directory)", path))
{
headerPaths.push_back(FilePath(path).makeCanonical());
headerSearchPaths.push_back(FilePath(path).makeCanonical());
}
}
return headerPaths;
return utility::replaceOrAddCxxCompilerHeaderPath(headerSearchPaths);
}
@@ -7,9 +7,7 @@ class CxxHeaderPathDetector: public PathDetector
{
public:
CxxHeaderPathDetector(const std::string& compilerName);
virtual ~CxxHeaderPathDetector();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
private:
const std::string m_compilerName;
@@ -8,6 +8,7 @@
#include "utility/file/FilePath.h"
#include "utility/path_detector/cxx_header/utilityCxxHeaderDetection.h"
#include "utility/utility.h"
#include "utility/utilityCxx.h"
CxxVs10To14HeaderPathDetector::CxxVs10To14HeaderPathDetector(VisualStudioType type, bool isExpress, ApplicationArchitectureType architecture)
: PathDetector(visualStudioTypeToString(type) + (isExpress ? " Express" : "") + (architecture == APPLICATION_ARCHITECTURE_X86_64 ? " 64 Bit" : ""))
@@ -17,10 +18,6 @@ CxxVs10To14HeaderPathDetector::CxxVs10To14HeaderPathDetector(VisualStudioType ty
{
}
CxxVs10To14HeaderPathDetector::~CxxVs10To14HeaderPathDetector()
{
}
std::vector<FilePath> CxxVs10To14HeaderPathDetector::getPaths() const
{
const FilePath vsInstallPath = getVsInstallPathUsingRegistry();
@@ -44,20 +41,20 @@ std::vector<FilePath> CxxVs10To14HeaderPathDetector::getPaths() const
utility::append(headerSearchPaths, utility::getWindowsSdkHeaderSearchPaths(m_architecture));
}
return headerSearchPaths;
return utility::replaceOrAddCxxCompilerHeaderPath(headerSearchPaths);
}
int CxxVs10To14HeaderPathDetector::visualStudioTypeToVersion(const VisualStudioType t)
{
switch (t)
{
case VISUAL_STUDIO_2010:
case VISUAL_STUDIO_2010:
return 10;
case VISUAL_STUDIO_2012:
case VISUAL_STUDIO_2012:
return 11;
case VISUAL_STUDIO_2013:
case VISUAL_STUDIO_2013:
return 12;
case VISUAL_STUDIO_2015:
case VISUAL_STUDIO_2015:
return 14;
}
return 0;
@@ -68,13 +65,13 @@ std::string CxxVs10To14HeaderPathDetector::visualStudioTypeToString(const Visual
std::string ret = "Visual Studio";
switch (t)
{
case VISUAL_STUDIO_2010:
case VISUAL_STUDIO_2010:
ret += " 2010";
case VISUAL_STUDIO_2012:
case VISUAL_STUDIO_2012:
ret += " 2012";
case VISUAL_STUDIO_2013:
case VISUAL_STUDIO_2013:
ret += " 2013";
case VISUAL_STUDIO_2015:
case VISUAL_STUDIO_2015:
ret += " 2015";
}
return ret;
@@ -16,9 +16,7 @@ public:
};
CxxVs10To14HeaderPathDetector(VisualStudioType type, bool isExpress, ApplicationArchitectureType architecture);
virtual ~CxxVs10To14HeaderPathDetector();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
private:
static int visualStudioTypeToVersion(const VisualStudioType t);
@@ -5,18 +5,15 @@
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
#include "utility/path_detector/cxx_header/utilityCxxHeaderDetection.h"
#include "utility/utilityApp.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "utility/utilityCxx.h"
CxxVs15HeaderPathDetector::CxxVs15HeaderPathDetector()
: PathDetector("Visual Studio 2017")
{
}
CxxVs15HeaderPathDetector::~CxxVs15HeaderPathDetector()
{
}
std::vector<FilePath> CxxVs15HeaderPathDetector::getPaths() const
{
std::vector<FilePath> headerSearchPaths;
@@ -56,5 +53,5 @@ std::vector<FilePath> CxxVs15HeaderPathDetector::getPaths() const
utility::append(headerSearchPaths, windowsSdkHeaderSearchPaths);
}
return headerSearchPaths;
return utility::replaceOrAddCxxCompilerHeaderPath(headerSearchPaths);
}
@@ -8,9 +8,7 @@ class CxxVs15HeaderPathDetector: public PathDetector
{
public:
CxxVs15HeaderPathDetector();
virtual ~CxxVs15HeaderPathDetector();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
};
#endif // CXX_VS_15_HEADER_PATH_DETECTOR_H
@@ -5,7 +5,3 @@ JavaPathDetector::JavaPathDetector(const std::string& name, const std::string& j
, m_javaVersion(javaVersion)
{
}
JavaPathDetector::~JavaPathDetector()
{
}
@@ -7,7 +7,6 @@ class JavaPathDetector: public PathDetector
{
public:
JavaPathDetector(const std::string& name, const std::string& javaVersion);
virtual ~JavaPathDetector();
protected:
const std::string m_javaVersion;
@@ -16,10 +16,6 @@ JavaPathDetectorLinux::JavaPathDetectorLinux(const std::string javaVersion)
{
}
JavaPathDetectorLinux::~JavaPathDetectorLinux()
{
}
FilePath JavaPathDetectorLinux::getJavaInPath() const
{
std::string command = "which java";
@@ -8,9 +8,7 @@ class JavaPathDetectorLinux
{
public:
JavaPathDetectorLinux(const std::string javaVersion);
virtual ~JavaPathDetectorLinux();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
private:
FilePath getJavaInPath() const;
@@ -9,10 +9,6 @@ JavaPathDetectorMac::JavaPathDetectorMac(const std::string javaVersion)
{
}
JavaPathDetectorMac::~JavaPathDetectorMac()
{
}
std::vector<FilePath> JavaPathDetectorMac::getPaths() const
{
std::vector<FilePath> paths;
@@ -8,9 +8,7 @@ class JavaPathDetectorMac
{
public:
JavaPathDetectorMac(const std::string javaVersion);
virtual ~JavaPathDetectorMac();
virtual std::vector<FilePath> getPaths() const;
virtual std::vector<FilePath> getPaths() const override;
};
#endif // JAVA_PATH_DETECTOR_MAC_H
@@ -11,10 +11,6 @@ JavaPathDetectorWindows::JavaPathDetectorWindows(const std::string javaVersion)
{
}
JavaPathDetectorWindows::~JavaPathDetectorWindows()
{
}
std::vector<FilePath> JavaPathDetectorWindows::getPaths() const
{
QString key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\";
@@ -7,9 +7,7 @@ class JavaPathDetectorWindows: public JavaPathDetector
{
public:
JavaPathDetectorWindows(const std::string javaVersion);
virtual ~JavaPathDetectorWindows();
virtual std::vector<FilePath> getPaths() const;
virtual std::vector<FilePath> getPaths() const override;
};
#endif // JAVA_PATH_DETECTOR_WINDOWS_H
@@ -12,10 +12,6 @@ JreSystemLibraryPathDetector::JreSystemLibraryPathDetector(std::shared_ptr<JavaP
{
}
JreSystemLibraryPathDetector::~JreSystemLibraryPathDetector()
{
}
std::vector<FilePath> JreSystemLibraryPathDetector::getPaths() const
{
std::vector<FilePath> paths;
@@ -11,9 +11,7 @@ class JreSystemLibraryPathDetector: public PathDetector
{
public:
JreSystemLibraryPathDetector(std::shared_ptr<JavaPathDetector> javaPathDetector);
virtual ~JreSystemLibraryPathDetector();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
private:
std::shared_ptr<JavaPathDetector> m_javaPathDetector;
@@ -6,7 +6,3 @@ JreSystemLibraryPathDetectorLinux::JreSystemLibraryPathDetectorLinux(const std::
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorLinux>(javaVersion))
{
}
JreSystemLibraryPathDetectorLinux::~JreSystemLibraryPathDetectorLinux()
{
}
@@ -7,7 +7,6 @@ class JreSystemLibraryPathDetectorLinux: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorLinux(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorLinux();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_LINUX_H
@@ -6,7 +6,3 @@ JreSystemLibraryPathDetectorMac::JreSystemLibraryPathDetectorMac(const std::stri
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorMac>(javaVersion))
{
}
JreSystemLibraryPathDetectorMac::~JreSystemLibraryPathDetectorMac()
{
}
@@ -7,7 +7,6 @@ class JreSystemLibraryPathDetectorMac: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorMac(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorMac();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_MAC_H
@@ -6,7 +6,3 @@ JreSystemLibraryPathDetectorWindows::JreSystemLibraryPathDetectorWindows(const s
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorWindows>(javaVersion))
{
}
JreSystemLibraryPathDetectorWindows::~JreSystemLibraryPathDetectorWindows()
{
}
@@ -7,7 +7,6 @@ class JreSystemLibraryPathDetectorWindows: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorWindows(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorWindows();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_WINDOWS_H
@@ -8,10 +8,6 @@ MavenPathDetectorUnix::MavenPathDetectorUnix()
{
}
MavenPathDetectorUnix::~MavenPathDetectorUnix()
{
}
std::vector<FilePath> MavenPathDetectorUnix::getPaths() const
{
std::string command = "which mvn";
@@ -7,9 +7,7 @@ class MavenPathDetectorUnix: public PathDetector
{
public:
MavenPathDetectorUnix();
virtual ~MavenPathDetectorUnix();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
};
#endif // MAVEN_PATH_DETECTOR_UNIX_H
@@ -8,10 +8,6 @@ MavenPathDetectorWindows::MavenPathDetectorWindows()
{
}
MavenPathDetectorWindows::~MavenPathDetectorWindows()
{
}
std::vector<FilePath> MavenPathDetectorWindows::getPaths() const
{
std::string command = "cmd /c where mvn.cmd && exit";
@@ -7,9 +7,7 @@ class MavenPathDetectorWindows: public PathDetector
{
public:
MavenPathDetectorWindows();
virtual ~MavenPathDetectorWindows();
virtual std::vector<FilePath> getPaths() const;
std::vector<FilePath> getPaths() const override;
};
#endif // MAVEN_PATH_DETECTOR_WINDOWS_H