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

Commit b5717b9

Browse files
committed
Cleanup of meson implementation
1 parent 3864fc9 commit b5717b9

File tree

6 files changed

+14
-35
lines changed

6 files changed

+14
-35
lines changed

src/cmake.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@ CMake::CMake(const boost::filesystem::path &path) {
3434
}
3535

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

40-
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
41-
return false;
42-
43-
if(default_build_path.empty())
44-
return false;
4540
if(!boost::filesystem::exists(default_build_path)) {
4641
boost::system::error_code ec;
4742
boost::filesystem::create_directories(default_build_path, ec);
@@ -82,14 +77,9 @@ bool CMake::update_default_build(const boost::filesystem::path &default_build_pa
8277
}
8378

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

88-
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
89-
return false;
90-
91-
if(debug_build_path.empty())
92-
return false;
9383
if(!boost::filesystem::exists(debug_build_path)) {
9484
boost::system::error_code ec;
9585
boost::filesystem::create_directories(debug_build_path, ec);

src/compile_commands.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
3232
bool backslash=false;
3333
bool single_quote=false;
3434
bool double_quote=false;
35-
size_t parameter_start_pos=-1;
35+
size_t parameter_start_pos=std::string::npos;
3636
size_t parameter_size=0;
3737
auto add_parameter=[&parameters, &parameters_str, &parameter_start_pos, &parameter_size] {
3838
auto parameter=parameters_str.substr(parameter_start_pos, parameter_size);
@@ -49,9 +49,9 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
4949
else if(parameters_str[c]=='\\')
5050
backslash=true;
5151
else if((parameters_str[c]==' ' || parameters_str[c]=='\t') && !backslash && !single_quote && !double_quote) {
52-
if(parameter_start_pos!=static_cast<size_t>(-1)) {
52+
if(parameter_start_pos!=std::string::npos) {
5353
add_parameter();
54-
parameter_start_pos=-1;
54+
parameter_start_pos=std::string::npos;
5555
parameter_size=0;
5656
}
5757
continue;
@@ -65,11 +65,11 @@ CompileCommands::CompileCommands(const boost::filesystem::path &build_path) {
6565
continue;
6666
}
6767

68-
if(parameter_start_pos==static_cast<size_t>(-1))
68+
if(parameter_start_pos==std::string::npos)
6969
parameter_start_pos=c;
7070
++parameter_size;
7171
}
72-
if(parameter_start_pos!=static_cast<size_t>(-1))
72+
if(parameter_start_pos!=std::string::npos)
7373
add_parameter();
7474

7575
commands.emplace_back(Command{directory, parameters, boost::filesystem::absolute(file, build_path)});

src/compile_commands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class CompileCommands {
2020
std::vector<Command> commands;
2121
};
2222

23-
#endif // JUCI_COMPILE_COMMANDS_H_
23+
#endif // JUCI_COMPILE_COMMANDS_H_

src/meson.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,9 @@ Meson::Meson(const boost::filesystem::path &path) {
3333
}
3434

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

39-
if(!boost::filesystem::exists(project_path/"meson.build"))
40-
return false;
41-
42-
if(default_build_path.empty())
43-
return false;
4439
if(!boost::filesystem::exists(default_build_path)) {
4540
boost::system::error_code ec;
4641
boost::filesystem::create_directories(default_build_path, ec);
@@ -65,14 +60,9 @@ bool Meson::update_default_build(const boost::filesystem::path &default_build_pa
6560
}
6661

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

71-
if(!boost::filesystem::exists(project_path/"meson.build"))
72-
return false;
73-
74-
if(debug_build_path.empty())
75-
return false;
7666
if(!boost::filesystem::exists(debug_build_path)) {
7767
boost::system::error_code ec;
7868
boost::filesystem::create_directories(debug_build_path, ec);

src/project.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void Project::Clang::recreate_build() {
350350
std::pair<std::string, std::string> Project::Clang::debug_get_run_arguments() {
351351
auto debug_build_path=build->get_debug_path();
352352
auto default_build_path=build->get_default_path();
353-
if(debug_build_path.empty())
353+
if(debug_build_path.empty() || default_build_path.empty())
354354
return {"", ""};
355355

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

385385
void Project::Clang::debug_start() {
386386
auto debug_build_path=build->get_debug_path();
387-
if(debug_build_path.empty() || !build->update_debug())
388-
return;
389387
auto default_build_path=build->get_default_path();
390-
if(default_build_path.empty())
388+
if(debug_build_path.empty() || !build->update_debug() || default_build_path.empty())
391389
return;
390+
392391
auto project_path=std::make_shared<boost::filesystem::path>(build->project_path);
393392

394393
auto run_arguments_it=debug_run_arguments.find(project_path->string());

tests/meson_build_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ int main() {
3131

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

0 commit comments

Comments
 (0)