logic: compilationdatabase parsing
* compilationdatabase cleaned * add SolutionparserCompliationDatabase * added cmake_build_type_init as release for better autocomplition on linux * external source handling for different linux versions * clean script remove windows symbolic links only on windows * linux external lib handling for different build easier
This commit is contained in:
@@ -18,8 +18,6 @@
|
||||
#include "qt/window/QtSplashScreen.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include "utility/solution/SolutionParserVisualStudio.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
void init()
|
||||
|
||||
@@ -276,6 +276,8 @@ add_files(
|
||||
|
||||
utility/solution/ISolutionParser.cpp
|
||||
utility/solution/ISolutionParser.h
|
||||
utility/solution/SolutionParserCompilationDatabase.cpp
|
||||
utility/solution/SolutionParserCompilationDatabase.h
|
||||
utility/solution/SolutionParserVisualStudio.cpp
|
||||
utility/solution/SolutionParserVisualStudio.h
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#include "utility/solution/SolutionParserCompilationDatabase.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "clang/Tooling/JSONCompilationDatabase.h"
|
||||
|
||||
SolutionParserCompilationDatabase::SolutionParserCompilationDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
SolutionParserCompilationDatabase::~SolutionParserCompilationDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
std::string SolutionParserCompilationDatabase::getSolutionName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCompilationDatabase::getProjects()
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCompilationDatabase::getProjectItems()
|
||||
{
|
||||
return getDatabase()->getAllFiles();
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCompilationDatabase::getIncludePaths()
|
||||
{
|
||||
std::vector<clang::tooling::CompileCommand> commands = getDatabase()->getAllCompileCommands();
|
||||
|
||||
std::set<std::string> searchPaths;
|
||||
bool insertNext = false;
|
||||
for(clang::tooling::CompileCommand command : commands)
|
||||
{
|
||||
std::string dir = command.Directory;
|
||||
for(std::string argument : command.CommandLine)
|
||||
{
|
||||
if(insertNext)
|
||||
{
|
||||
searchPaths.insert(getIncludePath(argument, command.Directory));
|
||||
insertNext = false;
|
||||
}
|
||||
if(argument.substr(0,2) == "-I")
|
||||
{
|
||||
searchPaths.insert(getIncludePath(argument.substr(2), command.Directory));
|
||||
}
|
||||
if(argument == "-isystem")
|
||||
{
|
||||
insertNext = true;
|
||||
}
|
||||
// TODO Implement iframework handling
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> paths;
|
||||
for(std::string p : searchPaths)
|
||||
{
|
||||
paths.push_back(p);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCompilationDatabase::getProjectFiles()
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::string SolutionParserCompilationDatabase::getIncludePath(const std::string& path, const std::string& dir)
|
||||
{
|
||||
if (FilePath(path).isAbsolute())
|
||||
{
|
||||
return path;
|
||||
}
|
||||
return dir + "/" + path;
|
||||
}
|
||||
|
||||
clang::tooling::JSONCompilationDatabase* SolutionParserCompilationDatabase::getDatabase()
|
||||
{
|
||||
if(m_database == nullptr)
|
||||
{
|
||||
if(m_solutionPath.empty())
|
||||
{
|
||||
LOG_ERROR("No compilation database file");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string error;
|
||||
m_database = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||
( clang::tooling::JSONCompilationDatabase::loadFromFile(m_solutionPath + m_solutionName,error) );
|
||||
}
|
||||
if(m_database == nullptr)
|
||||
{
|
||||
LOG_ERROR("Could not load compilation database from file: " + m_solutionPath );
|
||||
}
|
||||
}
|
||||
return m_database.get();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
|
||||
#define COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
|
||||
|
||||
#include "utility/solution/ISolutionParser.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class FilePath;
|
||||
namespace clang
|
||||
{
|
||||
namespace tooling
|
||||
{
|
||||
class JSONCompilationDatabase;
|
||||
}
|
||||
}
|
||||
|
||||
class SolutionParserCompilationDatabase : public ISolutionParser
|
||||
{
|
||||
public:
|
||||
SolutionParserCompilationDatabase();
|
||||
~SolutionParserCompilationDatabase();
|
||||
|
||||
virtual std::string getSolutionName();
|
||||
virtual std::vector<std::string> getProjects();
|
||||
virtual std::vector<std::string> getProjectFiles();
|
||||
virtual std::vector<std::string> getProjectItems();
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
|
||||
private:
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_database;
|
||||
clang::tooling::JSONCompilationDatabase* getDatabase();
|
||||
std::string getIncludePath(const std::string& argument, const std::string& dir);
|
||||
};
|
||||
|
||||
|
||||
#endif //COATI_SOLUTIONPARSERCOMPILATIONDATABASE_H
|
||||
Reference in New Issue
Block a user