Browse Source

Implemented menu item to clean build directory

merge-requests/365/head
d3rrial 9 years ago committed by eidheim
parent
commit
0cfa6b8b84
  1. 4
      src/menu.cc
  2. 13
      src/project.cc
  3. 1
      src/project.h
  4. 13
      src/window.cc

4
src/menu.cc

@ -244,6 +244,10 @@ Menu::Menu() {
<attribute name='label' translatable='yes'>_Compile</attribute>
<attribute name='action'>app.compile</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Clean _Project</attribute>
<attribute name='action'>app.clean_project</attribute>
</item>
</section>
<section>
<item>

13
src/project.cc

@ -147,6 +147,19 @@ void Project::Base::compile_and_run() {
Info::get().print("Could not find a supported project");
}
void Project::Base::clean_project() {
auto default_build_path=build->get_default_path();
if(default_build_path.empty() || !build->update_default())
return;
if(Config::get().project.clear_terminal_on_compile)
Terminal::get().clear();
Terminal::get().print("Cleaning build directory\n");
boost::filesystem::remove_all(default_build_path);
boost::filesystem::create_directory(default_build_path);
Terminal::get().print("Build directory cleaned!\n");
}
std::pair<std::string, std::string> Project::Base::debug_get_run_arguments() {
Info::get().print("Could not find a supported project");
return {"", ""};

1
src/project.h

@ -43,6 +43,7 @@ namespace Project {
virtual std::pair<std::string, std::string> get_run_arguments();
virtual void compile();
virtual void compile_and_run();
virtual void clean_project();
virtual std::pair<std::string, std::string> debug_get_run_arguments();
virtual Gtk::Popover *debug_get_options() { return nullptr; }

13
src/window.cc

@ -855,6 +855,19 @@ void Window::set_menu_actions() {
Project::current->compile();
});
menu.add_action("clean_project", [this]() {
if(Project::compiling || Project::debugging) {
Info::get().print("Compile or debug in progress");
return;
}
Project::current=Project::create();
if(Config::get().project.save_on_compile_or_run)
Project::save_files(Project::current->build->project_path);
Project::current->clean_project();
});
menu.add_action("run_command", [this]() {
EntryBox::get().clear();

Loading…
Cancel
Save