diff --git a/src/cmake.cc b/src/cmake.cc index ea756f37..cd6e752e 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -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); @@ -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); diff --git a/src/compile_commands.cc b/src/compile_commands.cc index d3f6a387..8e69c3b9 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -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=[¶meters, ¶meters_str, ¶meter_start_pos, ¶meter_size] { auto parameter=parameters_str.substr(parameter_start_pos, parameter_size); @@ -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(-1)) { + if(parameter_start_pos!=std::string::npos) { add_parameter(); - parameter_start_pos=-1; + parameter_start_pos=std::string::npos; parameter_size=0; } continue; @@ -65,11 +65,11 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) { continue; } - if(parameter_start_pos==static_cast(-1)) + if(parameter_start_pos==std::string::npos) parameter_start_pos=c; ++parameter_size; } - if(parameter_start_pos!=static_cast(-1)) + if(parameter_start_pos!=std::string::npos) add_parameter(); commands.emplace_back(Command{directory, parameters, boost::filesystem::absolute(file, build_path)}); diff --git a/src/compile_commands.h b/src/compile_commands.h index 37476514..f065a2a0 100644 --- a/src/compile_commands.h +++ b/src/compile_commands.h @@ -20,4 +20,4 @@ class CompileCommands { std::vector commands; }; -#endif // JUCI_COMPILE_COMMANDS_H_ \ No newline at end of file +#endif // JUCI_COMPILE_COMMANDS_H_ diff --git a/src/meson.cc b/src/meson.cc index ccab7e15..7a8737af 100644 --- a/src/meson.cc +++ b/src/meson.cc @@ -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); @@ -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); diff --git a/src/project.cc b/src/project.cc index 05c05590..6b39b05c 100644 --- a/src/project.cc +++ b/src/project.cc @@ -350,7 +350,7 @@ void Project::Clang::recreate_build() { std::pair 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(); @@ -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(build->project_path); auto run_arguments_it=debug_run_arguments.find(project_path->string()); diff --git a/tests/meson_build_test.cc b/tests/meson_build_test.cc index 6584287f..97b5caa6 100644 --- a/tests/meson_build_test.cc +++ b/tests/meson_build_test.cc @@ -31,4 +31,4 @@ int main() { build=Project::Build::create(meson_test_files_path/"a_subdir"); g_assert(dynamic_cast(build.get())); -} \ No newline at end of file +}