From 5370e684799accaf9ac61ba6ff24c5bd2aa9454b Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 11 Jun 2023 12:48:41 +0200 Subject: [PATCH] Added support for compile_commands.json file in project root folder --- src/project_build.cpp | 8 ++++++-- src/project_build.hpp | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/project_build.cpp b/src/project_build.cpp index 2ac28bd..ce412c2 100644 --- a/src/project_build.cpp +++ b/src/project_build.cpp @@ -19,8 +19,6 @@ std::unique_ptr Project::Build::create(const boost::filesystem:: std::unique_ptr build(new CMakeBuild(path)); if(!build->project_path.empty()) return build; - else - return std::make_unique(); } if(boost::filesystem::exists(search_path / "meson.build"), ec) { @@ -35,6 +33,12 @@ std::unique_ptr Project::Build::create(const boost::filesystem:: return build; } + if(boost::filesystem::exists(search_path / "compile_commands.json", ec)) { + std::unique_ptr build(new CompileCommandsInProjectRootBuild()); + build->project_path = search_path; + return build; + } + if(boost::filesystem::exists(search_path / "Cargo.toml", ec)) { std::unique_ptr build(new CargoBuild()); build->project_path = search_path; diff --git a/src/project_build.hpp b/src/project_build.hpp index 11b6fe6..a962bf3 100644 --- a/src/project_build.hpp +++ b/src/project_build.hpp @@ -61,6 +61,11 @@ namespace Project { public: }; + class CompileCommandsInProjectRootBuild : public Build { + public: + boost::filesystem::path get_default_path() override { return project_path; }; + }; + class CargoBuild : public Build { public: boost::filesystem::path get_default_path() override { return project_path / "target" / "debug"; }