Files
clice/src/Server/Command.cpp
2024-09-08 22:14:44 +08:00

29 lines
786 B
C++

#include <Server/Command.h>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/basic_file_sink.h>
namespace clice {
std::vector<const char*> CompilationDatabase::lookup(clang::StringRef path) {
auto& command = CDB->getCompileCommands(path).front();
std::vector<const char*> args;
for(auto& arg: command.CommandLine) {
// TODO:
// some modification
args.push_back(arg.c_str());
}
return args;
}
void CompilationDatabase::load(clang::StringRef path) {
std::string error;
CDB = clang::tooling::CompilationDatabase::loadFromDirectory(path, error);
if(!CDB) {
spdlog::error("Failed to load compilation database: {}", error);
spdlog::default_logger()->flush();
std::terminate();
}
}
} // namespace clice