Browse Source

Working directory for libclang set to default build path. Fixes relative include paths in compile_commands.json, see #177

merge-requests/365/head
Ole Christian Eidheim 10 years ago
parent
commit
c605dab165
  1. 6
      src/project_build.cc
  2. 8
      src/source_clang.cc

6
src/project_build.cc

@ -10,6 +10,9 @@ std::unique_ptr<Project::Build> Project::get_build(const boost::filesystem::path
}
boost::filesystem::path Project::Build::get_default_build_path() {
if(project_path.empty())
return boost::filesystem::path();
boost::filesystem::path default_build_path=Config::get().project.default_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>";
@ -30,6 +33,9 @@ boost::filesystem::path Project::Build::get_default_build_path() {
}
boost::filesystem::path Project::Build::get_debug_build_path() {
if(project_path.empty())
return boost::filesystem::path();
boost::filesystem::path debug_build_path=Config::get().project.debug_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>";

8
src/source_clang.cc

@ -178,8 +178,9 @@ void Source::ClangViewParse::soft_reparse() {
std::vector<std::string> Source::ClangViewParse::get_compilation_commands() {
auto build=Project::get_build(file_path);
auto default_build_path=build->get_default_build_path();
build->update_default_build();
clang::CompilationDatabase db(build->get_default_build_path().string());
clang::CompilationDatabase db(default_build_path.string());
clang::CompileCommands commands(file_path.string(), db);
std::vector<clang::CompileCommand> cmds = commands.get_commands();
std::vector<std::string> arguments;
@ -209,6 +210,11 @@ std::vector<std::string> Source::ClangViewParse::get_compilation_commands() {
if(file_path.extension()==".h") //TODO: temporary fix for .h-files (parse as c++)
arguments.emplace_back("-xc++");
if(!default_build_path.empty()) {
arguments.emplace_back("-working-directory");
arguments.emplace_back(default_build_path.string());
}
return arguments;
}

Loading…
Cancel
Save