Allow absolute path for compilationDatabaseDirectory

This commit is contained in:
sysRay 2019-03-21 10:26:21 +01:00
parent b7d9ced086
commit 560babbbfd

View File

@ -46,6 +46,7 @@ limitations under the License.
#include <limits.h>
#include <unordered_set>
#include <vector>
#include <filesystem>
using namespace clang;
using namespace llvm;
@ -331,10 +332,12 @@ void Project::LoadDirectory(const std::string &root, Project::Folder &folder) {
std::string err_msg;
folder.entries.clear();
if (g_config->compilationDatabaseCommand.empty()) {
CDBDir = root;
if (g_config->compilationDatabaseDirectory.size())
if (g_config->compilationDatabaseDirectory.size()) {
if (std::filesystem::path(g_config->compilationDatabaseDirectory).is_relative())
sys::path::append(CDBDir, g_config->compilationDatabaseDirectory);
sys::path::append(Path, CDBDir, "compile_commands.json");
else
CDBDir = g_config->compilationDatabaseDirectory;
}
} else {
// If `compilationDatabaseCommand` is specified, execute it to get the
// compdb.