Browse Source

Minor debug build cleanup

merge-requests/365/head
eidheim 10 years ago
parent
commit
7118026df2
  1. 19
      src/cmake.cc
  2. 3
      src/cmake.h
  3. 2
      src/notebook.cc
  4. 22
      src/project.cc
  5. 4
      src/project_build.cc
  6. 4
      src/project_build.h

19
src/cmake.cc

@ -5,8 +5,6 @@
#include "terminal.h" #include "terminal.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
std::unordered_set<std::string> CMake::debug_build_needed;
CMake::CMake(const boost::filesystem::path &path) { CMake::CMake(const boost::filesystem::path &path) {
const auto find_cmake_project=[this](const boost::filesystem::path &cmake_path) { const auto find_cmake_project=[this](const boost::filesystem::path &cmake_path) {
for(auto &line: filesystem::read_lines(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")) if(!force && boost::filesystem::exists(default_build_path/"compile_commands.json"))
return true; return true;
debug_build_needed.emplace(project_path.string());
auto compile_commands_path=default_build_path/"compile_commands.json"; auto compile_commands_path=default_build_path/"compile_commands.json";
Dialog::Message message("Creating/updating default build"); Dialog::Message message("Creating/updating default build");
auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+ auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
@ -135,7 +131,7 @@ bool CMake::update_default_build(bool force) {
return false; return false;
} }
bool CMake::update_debug_build() { bool CMake::update_debug_build(bool force) {
if(project_path.empty()) if(project_path.empty())
return false; return false;
@ -154,11 +150,8 @@ bool CMake::update_debug_build() {
} }
} }
if(boost::filesystem::exists(debug_build_path/"CMakeCache.txt")) { if(!force && boost::filesystem::exists(debug_build_path/"CMakeCache.txt"))
auto it=debug_build_needed.find(project_path.string()); return true;
if(it==debug_build_needed.end())
return true;
}
std::unique_ptr<Dialog::Message> message; std::unique_ptr<Dialog::Message> message;
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Creating/updating debug build")); message=std::unique_ptr<Dialog::Message>(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); filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path);
if(message) if(message)
message->hide(); message->hide();
if(exit_status==EXIT_SUCCESS) { 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);
return true; return true;
}
return false; return false;
} }

3
src/cmake.h

@ -14,7 +14,7 @@ public:
boost::filesystem::path get_default_build_path(); boost::filesystem::path get_default_build_path();
boost::filesystem::path get_debug_build_path(); boost::filesystem::path get_debug_build_path();
bool update_default_build(bool force=false); 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); boost::filesystem::path get_executable(const boost::filesystem::path &file_path);
@ -31,6 +31,5 @@ private:
void parse(); void parse();
std::vector<std::string> get_function_parameters(std::string &data); std::vector<std::string> get_function_parameters(std::string &data);
bool parsed=false; bool parsed=false;
static std::unordered_set<std::string> debug_build_needed;
}; };
#endif //JUCI_CMAKE_H_ #endif //JUCI_CMAKE_H_

2
src/notebook.cc

@ -249,7 +249,7 @@ bool Notebook::save(int page) {
auto build=Project::get_build(view->file_path); auto build=Project::get_build(view->file_path);
build->update_default_build(true); build->update_default_build(true);
if(boost::filesystem::exists(build->get_debug_build_path())) if(boost::filesystem::exists(build->get_debug_build_path()))
build->update_debug_build(); build->update_debug_build(true);
for(auto source_view: source_views) { for(auto source_view: source_views) {
if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) { if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) {

22
src/project.cc

@ -132,12 +132,10 @@ std::pair<std::string, std::string> Project::Clang::get_run_arguments() {
} }
void Project::Clang::compile() { void Project::Clang::compile() {
if(build->get_default_build_path().empty() || !build->update_default_build())
return;
auto default_build_path=build->get_default_build_path(); auto default_build_path=build->get_default_build_path();
if(default_build_path.empty()) if(default_build_path.empty() || !build->update_default_build())
return; return;
compiling=true; compiling=true;
Terminal::get().print("Compiling project "+build->project_path.string()+"\n"); 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) { 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() { 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; return;
auto project_path=build->project_path; 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()); auto run_arguments_it=run_arguments.find(project_path.string());
std::string arguments; std::string arguments;
if(run_arguments_it!=run_arguments.end()) if(run_arguments_it!=run_arguments.end())
@ -217,15 +212,10 @@ std::pair<std::string, std::string> Project::Clang::debug_get_run_arguments() {
} }
void Project::Clang::debug_start() { 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(); auto debug_build_path=build->get_debug_build_path();
if(debug_build_path.empty()) if(debug_build_path.empty() || !build->update_debug_build())
return;
if(!build->update_debug_build())
return; return;
auto project_path=build->project_path;
auto run_arguments_it=debug_run_arguments.find(project_path.string()); auto run_arguments_it=debug_run_arguments.find(project_path.string());
std::string run_arguments; std::string run_arguments;

4
src/project_build.cc

@ -20,8 +20,8 @@ boost::filesystem::path Project::CMake::get_debug_build_path() {
return cmake.get_debug_build_path(); return cmake.get_debug_build_path();
} }
bool Project::CMake::update_debug_build() { bool Project::CMake::update_debug_build(bool force) {
return cmake.update_debug_build(); return cmake.update_debug_build(force);
} }
boost::filesystem::path Project::CMake::get_executable(const boost::filesystem::path &path) { boost::filesystem::path Project::CMake::get_executable(const boost::filesystem::path &path) {

4
src/project_build.h

@ -15,7 +15,7 @@ namespace Project {
virtual boost::filesystem::path get_default_build_path() {return boost::filesystem::path();} virtual boost::filesystem::path get_default_build_path() {return boost::filesystem::path();}
virtual bool update_default_build(bool force=false) {return false;} virtual bool update_default_build(bool force=false) {return false;}
virtual boost::filesystem::path get_debug_build_path() {return boost::filesystem::path();} 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();} 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; boost::filesystem::path get_default_build_path() override;
bool update_default_build(bool force=false) override; bool update_default_build(bool force=false) override;
boost::filesystem::path get_debug_build_path() 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; boost::filesystem::path get_executable(const boost::filesystem::path &path) override;
}; };

Loading…
Cancel
Save