diff --git a/src/cmake.cc b/src/cmake.cc index 1ff555f..4b4150c 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -5,8 +5,6 @@ #include "terminal.h" #include -std::unordered_set CMake::debug_build_needed; - CMake::CMake(const boost::filesystem::path &path) { const auto find_cmake_project=[this](const boost::filesystem::path &cmake_path) { for(auto &line: filesystem::read_lines(cmake_path)) { @@ -108,8 +106,6 @@ bool CMake::update_default_build(bool force) { if(!force && boost::filesystem::exists(default_build_path/"compile_commands.json")) return true; - debug_build_needed.emplace(project_path.string()); - auto compile_commands_path=default_build_path/"compile_commands.json"; Dialog::Message message("Creating/updating default build"); auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+ @@ -135,7 +131,7 @@ bool CMake::update_default_build(bool force) { return false; } -bool CMake::update_debug_build() { +bool CMake::update_debug_build(bool force) { if(project_path.empty()) return false; @@ -154,11 +150,8 @@ bool CMake::update_debug_build() { } } - if(boost::filesystem::exists(debug_build_path/"CMakeCache.txt")) { - auto it=debug_build_needed.find(project_path.string()); - if(it==debug_build_needed.end()) - return true; - } + if(!force && boost::filesystem::exists(debug_build_path/"CMakeCache.txt")) + return true; std::unique_ptr message; message=std::unique_ptr(new Dialog::Message("Creating/updating debug build")); @@ -166,12 +159,8 @@ bool CMake::update_debug_build() { filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path); if(message) message->hide(); - if(exit_status==EXIT_SUCCESS) { - auto it=debug_build_needed.find(project_path.string()); - if(it!=debug_build_needed.end()) - debug_build_needed.erase(it); + if(exit_status==EXIT_SUCCESS) return true; - } return false; } diff --git a/src/cmake.h b/src/cmake.h index 9d18f77..eb282db 100644 --- a/src/cmake.h +++ b/src/cmake.h @@ -14,7 +14,7 @@ public: boost::filesystem::path get_default_build_path(); boost::filesystem::path get_debug_build_path(); bool update_default_build(bool force=false); - bool update_debug_build(); + bool update_debug_build(bool force=false); boost::filesystem::path get_executable(const boost::filesystem::path &file_path); @@ -31,6 +31,5 @@ private: void parse(); std::vector get_function_parameters(std::string &data); bool parsed=false; - static std::unordered_set debug_build_needed; }; #endif //JUCI_CMAKE_H_ diff --git a/src/notebook.cc b/src/notebook.cc index ea9124b..0497b21 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -249,7 +249,7 @@ bool Notebook::save(int page) { auto build=Project::get_build(view->file_path); build->update_default_build(true); if(boost::filesystem::exists(build->get_debug_build_path())) - build->update_debug_build(); + build->update_debug_build(true); for(auto source_view: source_views) { if(auto source_clang_view=dynamic_cast(source_view)) { diff --git a/src/project.cc b/src/project.cc index a0763a4..cf2c5d3 100644 --- a/src/project.cc +++ b/src/project.cc @@ -131,13 +131,11 @@ std::pair Project::Clang::get_run_arguments() { return {project_path, arguments}; } -void Project::Clang::compile() { - if(build->get_default_build_path().empty() || !build->update_default_build()) - return; - +void Project::Clang::compile() { auto default_build_path=build->get_default_build_path(); - if(default_build_path.empty()) + if(default_build_path.empty() || !build->update_default_build()) return; + compiling=true; Terminal::get().print("Compiling project "+build->project_path.string()+"\n"); Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) { @@ -146,15 +144,12 @@ void Project::Clang::compile() { } void Project::Clang::compile_and_run() { - if(build->get_default_build_path().empty() || !build->update_default_build()) + auto default_build_path=build->get_default_build_path(); + if(default_build_path.empty() || !build->update_default_build()) return; auto project_path=build->project_path; - auto default_build_path=build->get_default_build_path(); - if(default_build_path.empty()) - return; - auto run_arguments_it=run_arguments.find(project_path.string()); std::string arguments; if(run_arguments_it!=run_arguments.end()) @@ -217,15 +212,10 @@ std::pair Project::Clang::debug_get_run_arguments() { } void Project::Clang::debug_start() { - if(build->get_default_build_path().empty() || !build->update_default_build()) - return; - auto project_path=build->project_path; - auto debug_build_path=build->get_debug_build_path(); - if(debug_build_path.empty()) - return; - if(!build->update_debug_build()) + if(debug_build_path.empty() || !build->update_debug_build()) return; + auto project_path=build->project_path; auto run_arguments_it=debug_run_arguments.find(project_path.string()); std::string run_arguments; diff --git a/src/project_build.cc b/src/project_build.cc index 84ebdd8..5da6b64 100644 --- a/src/project_build.cc +++ b/src/project_build.cc @@ -20,8 +20,8 @@ boost::filesystem::path Project::CMake::get_debug_build_path() { return cmake.get_debug_build_path(); } -bool Project::CMake::update_debug_build() { - return cmake.update_debug_build(); +bool Project::CMake::update_debug_build(bool force) { + return cmake.update_debug_build(force); } boost::filesystem::path Project::CMake::get_executable(const boost::filesystem::path &path) { diff --git a/src/project_build.h b/src/project_build.h index 5057e09..ffd36cb 100644 --- a/src/project_build.h +++ b/src/project_build.h @@ -15,7 +15,7 @@ namespace Project { virtual boost::filesystem::path get_default_build_path() {return boost::filesystem::path();} virtual bool update_default_build(bool force=false) {return false;} virtual boost::filesystem::path get_debug_build_path() {return boost::filesystem::path();} - virtual bool update_debug_build() {return false;} + virtual bool update_debug_build(bool force=false) {return false;} virtual boost::filesystem::path get_executable(const boost::filesystem::path &path) {return boost::filesystem::path();} }; @@ -28,7 +28,7 @@ namespace Project { boost::filesystem::path get_default_build_path() override; bool update_default_build(bool force=false) override; boost::filesystem::path get_debug_build_path() override; - bool update_debug_build() override; + bool update_debug_build(bool force=false) override; boost::filesystem::path get_executable(const boost::filesystem::path &path) override; };