From 16e68d7542e7be8dce91abeec3e9f7c7ae812a4f Mon Sep 17 00:00:00 2001 From: MoAlyousef Date: Fri, 27 Nov 2020 17:38:40 +0300 Subject: [PATCH] fix C++11 build --- include/args.h | 5 +++-- include/build.h | 6 ++++-- include/error.h | 6 ++++-- include/gen.h | 6 ++++-- include/help.h | 6 ++++-- src/args.cpp | 15 +++++++++------ src/build.cpp | 7 ++++--- src/cmake.cpp | 6 ++++-- src/cmake.hpp | 6 ++++-- src/error.cpp | 6 ++++-- src/gen.cpp | 6 ++++-- src/help.cpp | 6 ++++-- 12 files changed, 52 insertions(+), 29 deletions(-) diff --git a/include/args.h b/include/args.h index 3dfa47e..8edf821 100644 --- a/include/args.h +++ b/include/args.h @@ -1,10 +1,11 @@ #pragma once #ifdef __cplusplus -namespace cmkr::args { - +namespace cmkr { +namespace args { const char *handle_args(int argc, char **argv); } +} // namespace cmkr extern "C" { #endif diff --git a/include/build.h b/include/build.h index 46dfdba..58663d1 100644 --- a/include/build.h +++ b/include/build.h @@ -2,7 +2,8 @@ #ifdef __cplusplus -namespace cmkr::build { +namespace cmkr { +namespace build { int run(int argc, char **argv); @@ -10,7 +11,8 @@ int clean(); int install(); -} // namespace cmkr::build +} // namespace build +} // namespace cmkr extern "C" { #endif diff --git a/include/error.h b/include/error.h index 7d18305..ca795c1 100644 --- a/include/error.h +++ b/include/error.h @@ -1,7 +1,8 @@ #pragma once #ifdef __cplusplus -namespace cmkr::error { +namespace cmkr { +namespace error { struct Status { enum class Code { @@ -21,7 +22,8 @@ struct Status { Code ec_ = Code::Success; }; -} // namespace cmkr::error +} // namespace error +} // namespace cmkr extern "C" { #endif diff --git a/include/gen.h b/include/gen.h index 9fdf6ca..0e808af 100644 --- a/include/gen.h +++ b/include/gen.h @@ -1,13 +1,15 @@ #pragma once #ifdef __cplusplus -namespace cmkr::gen { +namespace cmkr { +namespace gen { int generate_project(const char *typ); int generate_cmake(const char *path); -} // namespace cmkr::gen +} // namespace gen +} // namespace cmkr extern "C" { #endif diff --git a/include/help.h b/include/help.h index 1be4374..6c4f2e6 100644 --- a/include/help.h +++ b/include/help.h @@ -1,13 +1,15 @@ #pragma once #ifdef __cplusplus -namespace cmkr::help { +namespace cmkr { +namespace help { const char *version() noexcept; const char *message() noexcept; -} // namespace cmkr::help +} // namespace help +} // namespace cmkr extern "C" { #endif diff --git a/src/args.cpp b/src/args.cpp index 0c43eec..e8476f1 100644 --- a/src/args.cpp +++ b/src/args.cpp @@ -3,14 +3,15 @@ #include "gen.h" #include "help.h" -#include #include "fs.hpp" +#include #include #include #include #include -namespace cmkr::args { +namespace cmkr { +namespace args { const char *handle_args(int argc, char **argv) { std::vector args; for (int i = 0; i < argc; ++i) @@ -25,9 +26,10 @@ const char *handle_args(int argc, char **argv) { cont = true; auto current_path = fs::current_path(); if (fs::exists(current_path / "CMakeLists.txt") && cont == false) { - std::cout << "A CMakeLists.txt file already exists in the current directory.\nWould you " - "like to overwrite it?[y/n]" - << std::endl; + std::cout + << "A CMakeLists.txt file already exists in the current directory.\nWould you " + "like to overwrite it?[y/n]" + << std::endl; std::string resp; std::cin >> resp; if (resp != "y") @@ -68,7 +70,8 @@ const char *handle_args(int argc, char **argv) { return "Unknown argument!"; } } -} // namespace cmkr::args +} // namespace args +} // namespace cmkr const char *cmkr_args_handle_args(int argc, char **argv) { try { diff --git a/src/build.cpp b/src/build.cpp index ee0c3af..e82d2c1 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -10,7 +10,8 @@ #include #include -namespace cmkr::build { +namespace cmkr { +namespace build { int run(int argc, char **argv) { cmake::CMake cmake(".", true); @@ -63,8 +64,8 @@ int install() { auto cmd = "cmake --install " + cmake.bin_dir; return ::system(cmd.c_str()); } - -} // namespace cmkr::build +} // namespace build +} // namespace cmkr int cmkr_build_run(int argc, char **argv) { try { diff --git a/src/cmake.cpp b/src/cmake.cpp index a69ef56..29343ac 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -4,7 +4,8 @@ #include #include -namespace cmkr::cmake { +namespace cmkr { +namespace cmake { namespace detail { std::vector to_string_vec( @@ -233,4 +234,5 @@ CMake::CMake(const std::string &path, bool build) { } } } -} // namespace cmkr::cmake +} // namespace cmake +} // namespace cmkr diff --git a/src/cmake.hpp b/src/cmake.hpp index f9902cb..534ee4b 100644 --- a/src/cmake.hpp +++ b/src/cmake.hpp @@ -5,7 +5,8 @@ #include #include -namespace cmkr::cmake { +namespace cmkr { +namespace cmake { namespace detail { template @@ -106,4 +107,5 @@ struct CMake { CMake(const std::string &path, bool build); }; -} // namespace cmkr::cmake \ No newline at end of file +} // namespace cmake +} // namespace cmkr \ No newline at end of file diff --git a/src/error.cpp b/src/error.cpp index 69706fc..d5245c6 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -2,7 +2,8 @@ #include -namespace cmkr::error { +namespace cmkr { +namespace error { Status::Status(Code ec) noexcept : ec_(ec) {} @@ -10,7 +11,8 @@ Status::operator int() const noexcept { return static_cast(ec_); } Status::Code Status::code() const noexcept { return ec_; } -} // namespace cmkr::error +} // namespace error +} // namespace cmkr const char *err_string[] = { "Success", "Runtime error", "Initialization error", "CMake generation error", "Build error", diff --git a/src/gen.cpp b/src/gen.cpp index 34dea32..920a2db 100644 --- a/src/gen.cpp +++ b/src/gen.cpp @@ -12,7 +12,8 @@ #include #include -namespace cmkr::gen { +namespace cmkr { +namespace gen { namespace detail { @@ -394,7 +395,8 @@ int generate_cmake(const char *path) { } return 0; } -} // namespace cmkr::gen +} // namespace gen +} // namespace cmkr int cmkr_gen_generate_project(const char *typ) { try { diff --git a/src/help.cpp b/src/help.cpp index 41ab015..20f4726 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -1,6 +1,7 @@ #include "help.h" -namespace cmkr::help { +namespace cmkr { +namespace help { const char *version() noexcept { return "cmkr version 0.1.2"; } @@ -17,7 +18,8 @@ arguments: version Current cmkr version. )lit"; } -} // namespace cmkr::help +} // namespace help +} // namespace cmkr const char *cmkr_help_version(void) { return cmkr::help::version(); }