Browse Source

Fixed Project::Build::get_debug_path() that was not correctly changing <project_directory_name> when inserted from <default_build_path>. Reported in #394

merge-requests/391/head
eidheim 7 years ago
parent
commit
88dc16d1f2
  1. 40
      src/project_build.cc

40
src/project_build.cc

@ -1,6 +1,7 @@
#include "project_build.h" #include "project_build.h"
#include "config.h" #include "config.h"
#include "filesystem.h" #include "filesystem.h"
#include <boost/algorithm/string.hpp>
std::unique_ptr<Project::Build> Project::Build::create(const boost::filesystem::path &path) { std::unique_ptr<Project::Build> Project::Build::create(const boost::filesystem::path &path) {
auto search_path = boost::filesystem::is_directory(path) ? path : path.parent_path(); auto search_path = boost::filesystem::is_directory(path) ? path : path.parent_path();
@ -51,17 +52,10 @@ boost::filesystem::path Project::Build::get_default_path() {
return boost::filesystem::path(); return boost::filesystem::path();
boost::filesystem::path default_build_path = Config::get().project.default_build_path; boost::filesystem::path default_build_path = Config::get().project.default_build_path;
const std::string path_variable_project_directory_name = "<project_directory_name>";
size_t pos = 0;
auto default_build_path_string = default_build_path.string(); auto default_build_path_string = default_build_path.string();
auto path_filename_string = project_path.filename().string();
while((pos = default_build_path_string.find(path_variable_project_directory_name, pos)) != std::string::npos) { boost::replace_all(default_build_path_string, "<project_directory_name>", project_path.filename().string());
default_build_path_string.replace(pos, path_variable_project_directory_name.size(), path_filename_string); default_build_path = default_build_path_string;
pos += path_filename_string.size();
}
if(pos != 0)
default_build_path = default_build_path_string;
if(default_build_path.is_relative()) if(default_build_path.is_relative())
default_build_path = project_path / default_build_path; default_build_path = project_path / default_build_path;
@ -74,28 +68,12 @@ boost::filesystem::path Project::Build::get_debug_path() {
return boost::filesystem::path(); return boost::filesystem::path();
boost::filesystem::path debug_build_path = Config::get().project.debug_build_path; boost::filesystem::path debug_build_path = Config::get().project.debug_build_path;
const std::string path_variable_project_directory_name = "<project_directory_name>";
size_t pos = 0;
auto debug_build_path_string = debug_build_path.string(); auto debug_build_path_string = debug_build_path.string();
auto path_filename_string = project_path.filename().string();
while((pos = debug_build_path_string.find(path_variable_project_directory_name, pos)) != std::string::npos) { boost::replace_all(debug_build_path_string, "<default_build_path>", Config::get().project.default_build_path);
debug_build_path_string.replace(pos, path_variable_project_directory_name.size(), path_filename_string);
pos += path_filename_string.size(); boost::replace_all(debug_build_path_string, "<project_directory_name>", project_path.filename().string());
} debug_build_path = debug_build_path_string;
if(pos != 0)
debug_build_path = debug_build_path_string;
const std::string path_variable_default_build_path = "<default_build_path>";
pos = 0;
debug_build_path_string = debug_build_path.string();
auto default_build_path = Config::get().project.default_build_path;
while((pos = debug_build_path_string.find(path_variable_default_build_path, pos)) != std::string::npos) {
debug_build_path_string.replace(pos, path_variable_default_build_path.size(), default_build_path);
pos += default_build_path.size();
}
if(pos != 0)
debug_build_path = debug_build_path_string;
if(debug_build_path.is_relative()) if(debug_build_path.is_relative())
debug_build_path = project_path / debug_build_path; debug_build_path = project_path / debug_build_path;

Loading…
Cancel
Save