From b7059e69d7cc3f6e389f8c8cf4c23f7551c2b3bc Mon Sep 17 00:00:00 2001 From: Peter Elmers Date: Fri, 17 Nov 2017 14:45:49 -0800 Subject: [PATCH] Add compileCommandsDirectory to config struct --- src/command_line.cc | 8 +++++++- src/config.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/command_line.cc b/src/command_line.cc index 55e649ff..3fa37561 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -1462,6 +1462,12 @@ bool QueryDbMainLoop(Config* config, LOG_S(FATAL) << "Exiting; no cache directory"; 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); EnsureEndsInSlash(config->cacheDirectory); MakeDirectoryRecursive(config->cacheDirectory); @@ -1566,7 +1572,7 @@ bool QueryDbMainLoop(Config* config, Timer time; // Open up / load the project. - project->Load(config->extraClangArguments, project_path, + project->Load(config->extraClangArguments, config->compileCommandsDirectory, config->resourceDirectory); time.ResetAndPrint("[perf] Loaded compilation entries (" + std::to_string(project->entries.size()) + diff --git a/src/config.h b/src/config.h index 9cc3e396..edaafbd2 100644 --- a/src/config.h +++ b/src/config.h @@ -7,6 +7,8 @@ struct Config { // Root directory of the project. **Not serialized** std::string projectRoot; + // Location of compile_commands.json. + std::string compileCommandsDirectory; // Cache directory for indexed files. std::string cacheDirectory; // Value to use for clang -resource-dir if not present in @@ -70,6 +72,7 @@ struct Config { bool enableSnippetInsertion = true; }; MAKE_REFLECT_STRUCT(Config, + compileCommandsDirectory, cacheDirectory, resourceDirectory,