Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Cleanup of meson implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Nov 15, 2016
1 parent 3864fc9 commit b5717b9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
14 changes: 2 additions & 12 deletions src/cmake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ CMake::CMake(const boost::filesystem::path &path) {
}

bool CMake::update_default_build(const boost::filesystem::path &default_build_path, bool force) {
if(project_path.empty())
if(project_path.empty() || !boost::filesystem::exists(project_path/"CMakeLists.txt") || default_build_path.empty())
return false;

if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return false;

if(default_build_path.empty())
return false;
if(!boost::filesystem::exists(default_build_path)) {
boost::system::error_code ec;
boost::filesystem::create_directories(default_build_path, ec);
Expand Down Expand Up @@ -82,14 +77,9 @@ bool CMake::update_default_build(const boost::filesystem::path &default_build_pa
}

bool CMake::update_debug_build(const boost::filesystem::path &debug_build_path, bool force) {
if(project_path.empty())
if(project_path.empty() || !boost::filesystem::exists(project_path/"CMakeLists.txt") || debug_build_path.empty())
return false;

if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return false;

if(debug_build_path.empty())
return false;
if(!boost::filesystem::exists(debug_build_path)) {
boost::system::error_code ec;
boost::filesystem::create_directories(debug_build_path, ec);
Expand Down
10 changes: 5 additions & 5 deletions src/compile_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
bool backslash=false;
bool single_quote=false;
bool double_quote=false;
size_t parameter_start_pos=-1;
size_t parameter_start_pos=std::string::npos;
size_t parameter_size=0;
auto add_parameter=[&parameters, &parameters_str, &parameter_start_pos, &parameter_size] {
auto parameter=parameters_str.substr(parameter_start_pos, parameter_size);
Expand All @@ -49,9 +49,9 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
else if(parameters_str[c]=='\\')
backslash=true;
else if((parameters_str[c]==' ' || parameters_str[c]=='\t') && !backslash && !single_quote && !double_quote) {
if(parameter_start_pos!=static_cast<size_t>(-1)) {
if(parameter_start_pos!=std::string::npos) {
add_parameter();
parameter_start_pos=-1;
parameter_start_pos=std::string::npos;
parameter_size=0;
}
continue;
Expand All @@ -65,11 +65,11 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
continue;
}

if(parameter_start_pos==static_cast<size_t>(-1))
if(parameter_start_pos==std::string::npos)
parameter_start_pos=c;
++parameter_size;
}
if(parameter_start_pos!=static_cast<size_t>(-1))
if(parameter_start_pos!=std::string::npos)
add_parameter();

commands.emplace_back(Command{directory, parameters, boost::filesystem::absolute(file, build_path)});
Expand Down
2 changes: 1 addition & 1 deletion src/compile_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class CompileCommands {
std::vector<Command> commands;
};

#endif // JUCI_COMPILE_COMMANDS_H_
#endif // JUCI_COMPILE_COMMANDS_H_
14 changes: 2 additions & 12 deletions src/meson.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ Meson::Meson(const boost::filesystem::path &path) {
}

bool Meson::update_default_build(const boost::filesystem::path &default_build_path, bool force) {
if(project_path.empty())
if(project_path.empty() || !boost::filesystem::exists(project_path/"meson.build") || default_build_path.empty())
return false;

if(!boost::filesystem::exists(project_path/"meson.build"))
return false;

if(default_build_path.empty())
return false;
if(!boost::filesystem::exists(default_build_path)) {
boost::system::error_code ec;
boost::filesystem::create_directories(default_build_path, ec);
Expand All @@ -65,14 +60,9 @@ bool Meson::update_default_build(const boost::filesystem::path &default_build_pa
}

bool Meson::update_debug_build(const boost::filesystem::path &debug_build_path, bool force) {
if(project_path.empty())
if(project_path.empty() || !boost::filesystem::exists(project_path/"meson.build") || debug_build_path.empty())
return false;

if(!boost::filesystem::exists(project_path/"meson.build"))
return false;

if(debug_build_path.empty())
return false;
if(!boost::filesystem::exists(debug_build_path)) {
boost::system::error_code ec;
boost::filesystem::create_directories(debug_build_path, ec);
Expand Down
7 changes: 3 additions & 4 deletions src/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void Project::Clang::recreate_build() {
std::pair<std::string, std::string> Project::Clang::debug_get_run_arguments() {
auto debug_build_path=build->get_debug_path();
auto default_build_path=build->get_default_path();
if(debug_build_path.empty())
if(debug_build_path.empty() || default_build_path.empty())
return {"", ""};

auto project_path=build->project_path.string();
Expand Down Expand Up @@ -384,11 +384,10 @@ Gtk::Popover *Project::Clang::debug_get_options() {

void Project::Clang::debug_start() {
auto debug_build_path=build->get_debug_path();
if(debug_build_path.empty() || !build->update_debug())
return;
auto default_build_path=build->get_default_path();
if(default_build_path.empty())
if(debug_build_path.empty() || !build->update_debug() || default_build_path.empty())
return;

auto project_path=std::make_shared<boost::filesystem::path>(build->project_path);

auto run_arguments_it=debug_run_arguments.find(project_path->string());
Expand Down
2 changes: 1 addition & 1 deletion tests/meson_build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ int main() {

build=Project::Build::create(meson_test_files_path/"a_subdir");
g_assert(dynamic_cast<Project::MesonBuild*>(build.get()));
}
}

0 comments on commit b5717b9

Please sign in to comment.