build: merge Coati app and Trial to single executable

* removed trial target
* updated deploy scripts to exclude trial
* cleanup CMakeLists
* removed Eigen dependencies
* split parser lib into lib_cxx and lib_java
* added ProjectFactory and ProjectFactoryModules
* removed old installer projects
* updated wix installer
  * updated readme for wix setup
  * updated to use obfuscated exe
  * added qt.conf
  * added indexing dialog images
  * added jars
  * added coatidb files of sample projects
  * added source code of javaparser sample
  * removed auto-refresh image
  * intermediate files of windows installer are created in build folder
  * preselected desktop shortcut
  * build bat is executed from deploy_windows script
This commit is contained in:
malte_langkabel
2016-09-16 12:45:00 +02:00
parent 8fcb35611d
commit 3b7baba24b
140 changed files with 869 additions and 22250 deletions
+227
View File
@@ -0,0 +1,227 @@
#include "data/parser/cxx/CxxParser.h"
#include "clang/Tooling/Tooling.h"
#include "utility/file/FileRegister.h"
#include "utility/logging/logging.h"
#include "utility/text/TextAccess.h"
#include "utility/tracing.h"
#include "data/parser/cxx/ASTActionFactory.h"
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
#include "data/parser/cxx/CxxDiagnosticConsumer.h"
namespace
{
static std::vector<std::string> getSyntaxOnlyToolArgs(const std::vector<std::string> &ExtraArgs, llvm::StringRef FileName)
{
std::vector<std::string> Args;
Args.push_back("clang-tool");
Args.push_back("-fsyntax-only");
Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
Args.push_back(FileName.str());
return Args;
}
// custom implementation of clang::runToolOnCodeWithArgs which also sets our custon DiagnosticConsumer
static bool runToolOnCodeWithArgs(
clang::DiagnosticConsumer* DiagConsumer,
clang::FrontendAction *ToolAction,
const llvm::Twine &Code,
const std::vector<std::string> &Args,
const llvm::Twine &FileName = "input.cc",
const clang::tooling::FileContentMappings &VirtualMappedFiles = clang::tooling::FileContentMappings()
)
{
llvm::SmallString<16> FileNameStorage;
llvm::StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
llvm::IntrusiveRefCntPtr<clang::FileManager> Files(new clang::FileManager(clang::FileSystemOptions()));
clang::tooling::ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef), ToolAction, Files.get());
llvm::SmallString<1024> CodeStorage;
Invocation.mapVirtualFile(FileNameRef, Code.toNullTerminatedStringRef(CodeStorage));
for (auto &FilenameWithContent : VirtualMappedFiles)
{
Invocation.mapVirtualFile(FilenameWithContent.first, FilenameWithContent.second);
}
Invocation.setDiagnosticConsumer(DiagConsumer);
return Invocation.run();
}
}
CxxParser::CxxParser(ParserClient* client, std::shared_ptr<FileRegister> fileRegister)
: Parser(client)
, m_fileRegister(fileRegister)
{
}
CxxParser::~CxxParser()
{
}
void CxxParser::parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments)
{
m_fileRegister->setFilePaths(filePaths);
setupParsing(arguments);
std::vector<std::string> sourcePaths;
for (const FilePath& path : m_fileRegister->getUnparsedSourceFilePaths()) // filter headers
{
sourcePaths.push_back(path.absolute().str());
}
runTool(sourcePaths);
}
void CxxParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
{
m_fileRegister->setFilePaths(std::vector<FilePath>(1, filePath));
setupParsing(arguments);
std::vector<std::string> args = getCommandlineArguments(arguments);
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(arguments);
ASTActionFactory actionFactory(m_client, m_fileRegister.get());
runToolOnCodeWithArgs(diagnostics.get(), actionFactory.create(), textAccess->getText(), args);
}
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(const Arguments& arguments) const
{
std::vector<std::string> args;
// verbose
// args.push_back("-v");
// The option -fno-delayed-template-parsing signals that templates that there should
// be AST elements for unused template functions as well.
args.push_back("-fno-delayed-template-parsing");
// The option -fexceptions signals that clang should watch out for exception-related code during indexing.
args.push_back("-fexceptions");
// The option -c signals that no executable is built.
args.push_back("-c");
// The option -w disables all warnings.
args.push_back("-w");
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
for (const FilePath& path : arguments.headerSearchPaths)
{
args.push_back("-I" + path.str());
}
for (const FilePath& path : arguments.systemHeaderSearchPaths)
{
args.push_back("-isystem");
args.push_back(path.str());
}
for (const FilePath& path : arguments.frameworkSearchPaths)
{
args.push_back("-iframework");
args.push_back(path.str());
}
return args;
}
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
{
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
// Set language standard
std::string standard = "-std=" + arguments.languageStandard;
args.push_back(standard);
return args;
}
std::shared_ptr<clang::tooling::FixedCompilationDatabase> CxxParser::getCompilationDatabase(
const Arguments& arguments
) const {
// Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
std::vector<std::string> args = getCommandlineArguments(arguments);
args.insert(args.begin(), "app");
args.insert(args.begin() + 1, "--");
int argc = args.size();
const char** argv = new const char*[argc];
for (size_t i = 0; i < args.size(); i++)
{
argv[i] = args[i].c_str();
}
std::shared_ptr<clang::tooling::FixedCompilationDatabase> compilationDatabase(
clang::tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv)
);
delete[] argv;
if (!compilationDatabase)
{
LOG_ERROR("Failed to load compilation database");
return nullptr;
}
return compilationDatabase;
}
std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(const Arguments& arguments) const
{
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
return std::make_shared<CxxDiagnosticConsumer>(
llvm::errs(), &*options, m_client, m_fileRegister.get(), arguments.logErrors);
}
void CxxParser::setupParsing(const Arguments& arguments)
{
m_compilationDatabase = getCompilationDatabase(arguments);
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::setupParsingCDB(const Arguments& arguments)
{
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::runTool(const std::vector<std::string>& files)
{
TRACE();
clang::tooling::ClangTool tool(*m_compilationDatabase, files);
tool.setDiagnosticConsumer(m_diagnostics.get());
ASTActionFactory actionFactory(m_client, m_fileRegister.get());
tool.run(&actionFactory);
}
void CxxParser::runTool(clang::tooling::CompileCommand command, const Arguments& arguments)
{
TRACE();
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
command.CommandLine.insert(command.CommandLine.end(), args.begin(), args.end());
CxxCompilationDatabaseSingle compilationDatabase(command);
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, command.Filename));
tool.setDiagnosticConsumer(m_diagnostics.get());
ASTActionFactory actionFactory(m_client, m_fileRegister.get());
tool.run(&actionFactory);
}
FileRegister* CxxParser::getFileRegister()
{
return m_fileRegister.get();
}
ParserClient* CxxParser::getParserClient()
{
return m_client;
}