diff --git a/src/project.cc b/src/project.cc index f5b46e3..ed4634d 100644 --- a/src/project.cc +++ b/src/project.cc @@ -9,6 +9,7 @@ #ifdef JUCI_ENABLE_DEBUG #include "debug_clang.h" #endif +#include "info.h" boost::filesystem::path Project::debug_last_stop_file_path; std::unordered_map Project::run_arguments; @@ -132,8 +133,31 @@ std::unique_ptr Project::create() { return std::unique_ptr(new Project::Base(std::move(build))); } +std::pair Project::Base::get_run_arguments() { + Info::get().print("Could not find a supported project"); + return {"", ""}; +} + +void Project::Base::compile() { + Info::get().print("Could not find a supported project"); +} + +void Project::Base::compile_and_run() { + Info::get().print("Could not find a supported project"); +} + +std::pair Project::Base::debug_get_run_arguments() { + Info::get().print("Could not find a supported project"); + return {"", ""}; +} + +void Project::Base::debug_start() { + Info::get().print("Could not find a supported project"); +} + std::pair Project::Clang::get_run_arguments() { - if(build->get_default_path().empty() || !build->update_default()) + auto build_path=build->get_default_path(); + if(build_path.empty()) return {"", ""}; auto project_path=build->project_path.string(); @@ -146,13 +170,9 @@ std::pair Project::Clang::get_run_arguments() { auto executable=build->get_executable(Notebook::get().get_current_page()!=-1?Notebook::get().get_current_view()->file_path:"").string(); if(executable!="") { - auto project_path=build->project_path; - auto build_path=build->get_default_path(); - if(!build_path.empty()) { - size_t pos=executable.find(project_path.string()); - if(pos!=std::string::npos) - executable.replace(pos, project_path.string().size(), build_path.string()); - } + size_t pos=executable.find(project_path); + if(pos!=std::string::npos) + executable.replace(pos, project_path.size(), build_path.string()); arguments=filesystem::escape_argument(executable); } else @@ -219,7 +239,8 @@ void Project::Clang::compile_and_run() { #ifdef JUCI_ENABLE_DEBUG std::pair Project::Clang::debug_get_run_arguments() { - if(build->get_default_path().empty() || !build->update_default()) + auto build_path=build->get_debug_path(); + if(build_path.empty()) return {"", ""}; auto project_path=build->project_path.string(); @@ -232,13 +253,9 @@ std::pair Project::Clang::debug_get_run_arguments() { auto executable=build->get_executable(Notebook::get().get_current_page()!=-1?Notebook::get().get_current_view()->file_path:"").string(); if(executable!="") { - auto project_path=build->project_path; - auto build_path=build->get_debug_path(); - if(!build_path.empty()) { - size_t pos=executable.find(project_path.string()); - if(pos!=std::string::npos) - executable.replace(pos, project_path.string().size(), build_path.string()); - } + size_t pos=executable.find(project_path); + if(pos!=std::string::npos) + executable.replace(pos, project_path.size(), build_path.string()); arguments=filesystem::escape_argument(executable); } else diff --git a/src/project.h b/src/project.h index 1bce53e..3e4cc8e 100644 --- a/src/project.h +++ b/src/project.h @@ -32,13 +32,13 @@ namespace Project { std::unique_ptr build; - virtual std::pair get_run_arguments() {return {"", ""};} - virtual void compile() {} - virtual void compile_and_run() {} + virtual std::pair get_run_arguments(); + virtual void compile(); + virtual void compile_and_run(); - virtual std::pair debug_get_run_arguments() {return {"", ""};} + virtual std::pair debug_get_run_arguments(); Tooltips debug_variable_tooltips; - virtual void debug_start() {} + virtual void debug_start(); virtual void debug_continue() {} virtual void debug_stop() {} virtual void debug_kill() {} diff --git a/src/project_build.cc b/src/project_build.cc index ff92836..1739eee 100644 --- a/src/project_build.cc +++ b/src/project_build.cc @@ -1,15 +1,12 @@ #include "project_build.h" #include "config.h" -#include "info.h" std::unique_ptr Project::Build::create(const boost::filesystem::path &path) { std::unique_ptr cmake(new CMakeBuild(path)); if(!cmake->project_path.empty()) return cmake; - else { - Info::get().print("Could not find a supported project"); + else return std::unique_ptr(new Project::Build()); - } } boost::filesystem::path Project::Build::get_default_path() {