Add compileCommandsDirectory to config struct

This commit is contained in:
Peter Elmers 2017-11-17 14:45:49 -08:00 committed by Jacob Dufault
parent dba27c3d34
commit b7059e69d7
2 changed files with 10 additions and 1 deletions

View File

@ -1462,6 +1462,12 @@ bool QueryDbMainLoop(Config* config,
LOG_S(FATAL) << "Exiting; no cache directory"; LOG_S(FATAL) << "Exiting; no cache directory";
exit(1); exit(1);
} }
// Make sure compile commands directory is valid.
if (config->compileCommandsDirectory.empty()) {
LOG_S(ERROR) << "No compile commands directory";
exit(1);
}
config->cacheDirectory = NormalizePath(config->cacheDirectory); config->cacheDirectory = NormalizePath(config->cacheDirectory);
EnsureEndsInSlash(config->cacheDirectory); EnsureEndsInSlash(config->cacheDirectory);
MakeDirectoryRecursive(config->cacheDirectory); MakeDirectoryRecursive(config->cacheDirectory);
@ -1566,7 +1572,7 @@ bool QueryDbMainLoop(Config* config,
Timer time; Timer time;
// Open up / load the project. // Open up / load the project.
project->Load(config->extraClangArguments, project_path, project->Load(config->extraClangArguments, config->compileCommandsDirectory,
config->resourceDirectory); config->resourceDirectory);
time.ResetAndPrint("[perf] Loaded compilation entries (" + time.ResetAndPrint("[perf] Loaded compilation entries (" +
std::to_string(project->entries.size()) + std::to_string(project->entries.size()) +

View File

@ -7,6 +7,8 @@
struct Config { struct Config {
// Root directory of the project. **Not serialized** // Root directory of the project. **Not serialized**
std::string projectRoot; std::string projectRoot;
// Location of compile_commands.json.
std::string compileCommandsDirectory;
// Cache directory for indexed files. // Cache directory for indexed files.
std::string cacheDirectory; std::string cacheDirectory;
// Value to use for clang -resource-dir if not present in // Value to use for clang -resource-dir if not present in
@ -70,6 +72,7 @@ struct Config {
bool enableSnippetInsertion = true; bool enableSnippetInsertion = true;
}; };
MAKE_REFLECT_STRUCT(Config, MAKE_REFLECT_STRUCT(Config,
compileCommandsDirectory,
cacheDirectory, cacheDirectory,
resourceDirectory, resourceDirectory,