Fix handling of compile_commands.json files with relative include paths (Fixes #189)
This commit is contained in:
@@ -80,6 +80,7 @@ Nowadays, this file can be generated rather easily using multiple methods:
|
|||||||
* For Boost-based projects
|
* For Boost-based projects
|
||||||
try [commands_to_compilation_database](https://github.com/tee3/commands_to_compilation_database)
|
try [commands_to_compilation_database](https://github.com/tee3/commands_to_compilation_database)
|
||||||
* For SCons, invoke `compilation_db` tool (requires SCons > 4.0.0)
|
* For SCons, invoke `compilation_db` tool (requires SCons > 4.0.0)
|
||||||
|
* For Bazel, try [bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor)
|
||||||
* For Microsoft Visual Studio projects try [Clang Power Tools](https://www.clangpowertools.com)
|
* For Microsoft Visual Studio projects try [Clang Power Tools](https://www.clangpowertools.com)
|
||||||
|
|
||||||
### Invocation
|
### Invocation
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ void translation_unit_visitor::set_source_location(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std::filesystem::path file_path{file}; !file_path.is_absolute()) {
|
||||||
|
file_path =
|
||||||
|
std::filesystem::canonical(std::filesystem::absolute(file_path));
|
||||||
|
file = file_path.string();
|
||||||
|
}
|
||||||
|
|
||||||
element.set_file(file);
|
element.set_file(file);
|
||||||
element.set_file_relative(util::path_to_url(
|
element.set_file_relative(util::path_to_url(
|
||||||
std::filesystem::relative(element.file(), relative_to_path_).string()));
|
std::filesystem::relative(element.file(), relative_to_path_).string()));
|
||||||
|
|||||||
Reference in New Issue
Block a user