From ee0e0d71d98c28a83d35074e43bcb2b4bd5d3c38 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 24 Mar 2023 10:56:53 +0000 Subject: [PATCH] Remove a bunch of dead code --- .clang-format | 2 +- .gitignore | 3 ++- CMakeLists.txt | 2 -- include/build.hpp | 6 ------ include/error.hpp | 27 ------------------------ include/help.hpp | 4 ---- include/project_parser.hpp | 5 +++-- src/arguments.cpp | 4 +--- src/build.cpp | 42 ++++---------------------------------- src/error.cpp | 31 ---------------------------- src/help.cpp | 8 -------- 11 files changed, 11 insertions(+), 123 deletions(-) delete mode 100644 include/error.hpp delete mode 100644 src/error.cpp diff --git a/.clang-format b/.clang-format index b89d8a4..f6341fd 100644 --- a/.clang-format +++ b/.clang-format @@ -72,7 +72,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right ReflowComments: true -SortIncludes: true +SortIncludes: false SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: true diff --git a/.gitignore b/.gitignore index a1b9f9c..088450b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ build*/ .idea/ cmake-build*/ CMakeLists.txt.user -.vscode/ \ No newline at end of file +.vscode/ +.DS_Store \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ad0953..3f15d88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,14 +61,12 @@ set(cmkr_SOURCES "src/arguments.cpp" "src/build.cpp" "src/cmake_generator.cpp" - "src/error.cpp" "src/help.cpp" "src/main.cpp" "src/project_parser.cpp" "include/arguments.hpp" "include/build.hpp" "include/cmake_generator.hpp" - "include/error.hpp" "include/fs.hpp" "include/help.hpp" "include/literals.hpp" diff --git a/include/build.hpp b/include/build.hpp index 068d2b0..5c159e6 100644 --- a/include/build.hpp +++ b/include/build.hpp @@ -11,9 +11,3 @@ int install(); } // namespace build } // namespace cmkr - -int cmkr_build_run(int argc, char **argv); - -int cmkr_build_clean(); - -int cmkr_build_install(); diff --git a/include/error.hpp b/include/error.hpp deleted file mode 100644 index a7b3e3d..0000000 --- a/include/error.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -namespace cmkr { -namespace error { - -struct Status { - enum class Code { - Success = 0, - RuntimeError, - InitError, - GenerationError, - BuildError, - CleanError, - InstallError, - }; - Status(Code ec) noexcept; - operator int() const noexcept; - Code code() const noexcept; - - private: - Code ec_ = Code::Success; -}; - -} // namespace error -} // namespace cmkr - -const char *cmkr_error_status_string(int); diff --git a/include/help.hpp b/include/help.hpp index a2da1b4..e5ac201 100644 --- a/include/help.hpp +++ b/include/help.hpp @@ -9,7 +9,3 @@ const char *message() noexcept; } // namespace help } // namespace cmkr - -const char *cmkr_help_version(void); - -const char *cmkr_help_message(void); diff --git a/include/project_parser.hpp b/include/project_parser.hpp index 2e6b07b..7b7a855 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -1,10 +1,11 @@ #pragma once -#include +#include #include + +#include #include #include -#include namespace cmkr { namespace parser { diff --git a/src/arguments.cpp b/src/arguments.cpp index 952b28a..96a4520 100644 --- a/src/arguments.cpp +++ b/src/arguments.cpp @@ -2,10 +2,8 @@ #include "build.hpp" #include "cmake_generator.hpp" #include "help.hpp" - #include "fs.hpp" -#include -#include + #include #include #include diff --git a/src/build.cpp b/src/build.cpp index cd95544..fe2a0a6 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -1,14 +1,10 @@ #include "build.hpp" #include "cmake_generator.hpp" -#include "error.hpp" #include "project_parser.hpp" #include "fs.hpp" -#include #include #include -#include -#include namespace cmkr { namespace build { @@ -17,7 +13,7 @@ int run(int argc, char **argv) { parser::Project project(nullptr, ".", true); if (argc > 2) { for (int i = 2; i < argc; ++i) { - project.build_args.push_back(argv[i]); + project.build_args.emplace_back(argv[i]); } } std::stringstream ss; @@ -48,13 +44,13 @@ int run(int argc, char **argv) { } int clean() { - bool ret = false; + bool success = false; parser::Project project(nullptr, ".", true); if (fs::exists(project.build_dir)) { - ret = fs::remove_all(project.build_dir); + success = fs::remove_all(project.build_dir); fs::create_directory(project.build_dir); } - return !ret; + return success ? EXIT_SUCCESS : EXIT_FAILURE; } int install() { @@ -64,33 +60,3 @@ int install() { } } // namespace build } // namespace cmkr - -int cmkr_build_run(int argc, char **argv) { - try { - return cmkr::build::run(argc, argv); - } catch (const std::system_error &e) { - return e.code().value(); - } catch (...) { - return cmkr::error::Status(cmkr::error::Status::Code::BuildError); - } -} - -int cmkr_build_clean(void) { - try { - return cmkr::build::clean(); - } catch (const std::system_error &e) { - return e.code().value(); - } catch (...) { - return cmkr::error::Status(cmkr::error::Status::Code::CleanError); - } -} - -int cmkr_build_install(void) { - try { - return cmkr::build::install(); - } catch (const std::system_error &e) { - return e.code().value(); - } catch (...) { - return cmkr::error::Status(cmkr::error::Status::Code::InstallError); - } -} diff --git a/src/error.cpp b/src/error.cpp deleted file mode 100644 index 2fe3081..0000000 --- a/src/error.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "error.hpp" - -#include -#include - -namespace cmkr { -namespace error { - -Status::Status(Code ec) noexcept : ec_(ec) { -} - -Status::operator int() const noexcept { - return static_cast(ec_); -} - -Status::Code Status::code() const noexcept { - return ec_; -} - -} // namespace error -} // namespace cmkr - -// strings for cmkr::error::Status::Code -static const char *err_string[] = { - "Success", "Runtime error", "Initialization error", "CMake generation error", "Build error", "Clean error", "Install error", -}; - -const char *cmkr_error_status(int i) { - assert(i >= 0 && static_cast(i) < (sizeof(err_string) / sizeof(*(err_string)))); - return err_string[i]; -} diff --git a/src/help.cpp b/src/help.cpp index 6e9513f..0a56367 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -23,11 +23,3 @@ arguments: } } // namespace help } // namespace cmkr - -const char *cmkr_help_version(void) { - return cmkr::help::version(); -} - -const char *cmkr_help_message(void) { - return cmkr::help::message(); -} \ No newline at end of file