fix C++11 build

self-hosting
MoAlyousef 4 years ago
parent 5dc71f9ba1
commit 16e68d7542

@ -1,10 +1,11 @@
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus
namespace cmkr::args { namespace cmkr {
namespace args {
const char *handle_args(int argc, char **argv); const char *handle_args(int argc, char **argv);
} }
} // namespace cmkr
extern "C" { extern "C" {
#endif #endif

@ -2,7 +2,8 @@
#ifdef __cplusplus #ifdef __cplusplus
namespace cmkr::build { namespace cmkr {
namespace build {
int run(int argc, char **argv); int run(int argc, char **argv);
@ -10,7 +11,8 @@ int clean();
int install(); int install();
} // namespace cmkr::build } // namespace build
} // namespace cmkr
extern "C" { extern "C" {
#endif #endif

@ -1,7 +1,8 @@
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus
namespace cmkr::error { namespace cmkr {
namespace error {
struct Status { struct Status {
enum class Code { enum class Code {
@ -21,7 +22,8 @@ struct Status {
Code ec_ = Code::Success; Code ec_ = Code::Success;
}; };
} // namespace cmkr::error } // namespace error
} // namespace cmkr
extern "C" { extern "C" {
#endif #endif

@ -1,13 +1,15 @@
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus
namespace cmkr::gen { namespace cmkr {
namespace gen {
int generate_project(const char *typ); int generate_project(const char *typ);
int generate_cmake(const char *path); int generate_cmake(const char *path);
} // namespace cmkr::gen } // namespace gen
} // namespace cmkr
extern "C" { extern "C" {
#endif #endif

@ -1,13 +1,15 @@
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus
namespace cmkr::help { namespace cmkr {
namespace help {
const char *version() noexcept; const char *version() noexcept;
const char *message() noexcept; const char *message() noexcept;
} // namespace cmkr::help } // namespace help
} // namespace cmkr
extern "C" { extern "C" {
#endif #endif

@ -3,14 +3,15 @@
#include "gen.h" #include "gen.h"
#include "help.h" #include "help.h"
#include <exception>
#include "fs.hpp" #include "fs.hpp"
#include <exception>
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
namespace cmkr::args { namespace cmkr {
namespace args {
const char *handle_args(int argc, char **argv) { const char *handle_args(int argc, char **argv) {
std::vector<std::string> args; std::vector<std::string> args;
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
@ -25,9 +26,10 @@ const char *handle_args(int argc, char **argv) {
cont = true; cont = true;
auto current_path = fs::current_path(); auto current_path = fs::current_path();
if (fs::exists(current_path / "CMakeLists.txt") && cont == false) { if (fs::exists(current_path / "CMakeLists.txt") && cont == false) {
std::cout << "A CMakeLists.txt file already exists in the current directory.\nWould you " std::cout
"like to overwrite it?[y/n]" << "A CMakeLists.txt file already exists in the current directory.\nWould you "
<< std::endl; "like to overwrite it?[y/n]"
<< std::endl;
std::string resp; std::string resp;
std::cin >> resp; std::cin >> resp;
if (resp != "y") if (resp != "y")
@ -68,7 +70,8 @@ const char *handle_args(int argc, char **argv) {
return "Unknown argument!"; return "Unknown argument!";
} }
} }
} // namespace cmkr::args } // namespace args
} // namespace cmkr
const char *cmkr_args_handle_args(int argc, char **argv) { const char *cmkr_args_handle_args(int argc, char **argv) {
try { try {

@ -10,7 +10,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <system_error> #include <system_error>
namespace cmkr::build { namespace cmkr {
namespace build {
int run(int argc, char **argv) { int run(int argc, char **argv) {
cmake::CMake cmake(".", true); cmake::CMake cmake(".", true);
@ -63,8 +64,8 @@ int install() {
auto cmd = "cmake --install " + cmake.bin_dir; auto cmd = "cmake --install " + cmake.bin_dir;
return ::system(cmd.c_str()); return ::system(cmd.c_str());
} }
} // namespace build
} // namespace cmkr::build } // namespace cmkr
int cmkr_build_run(int argc, char **argv) { int cmkr_build_run(int argc, char **argv) {
try { try {

@ -4,7 +4,8 @@
#include <stdexcept> #include <stdexcept>
#include <toml.hpp> #include <toml.hpp>
namespace cmkr::cmake { namespace cmkr {
namespace cmake {
namespace detail { namespace detail {
std::vector<std::string> to_string_vec( std::vector<std::string> to_string_vec(
@ -233,4 +234,5 @@ CMake::CMake(const std::string &path, bool build) {
} }
} }
} }
} // namespace cmkr::cmake } // namespace cmake
} // namespace cmkr

@ -5,7 +5,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace cmkr::cmake { namespace cmkr {
namespace cmake {
namespace detail { namespace detail {
template <typename T, typename O> template <typename T, typename O>
@ -106,4 +107,5 @@ struct CMake {
CMake(const std::string &path, bool build); CMake(const std::string &path, bool build);
}; };
} // namespace cmkr::cmake } // namespace cmake
} // namespace cmkr

@ -2,7 +2,8 @@
#include <assert.h> #include <assert.h>
namespace cmkr::error { namespace cmkr {
namespace error {
Status::Status(Code ec) noexcept : ec_(ec) {} Status::Status(Code ec) noexcept : ec_(ec) {}
@ -10,7 +11,8 @@ Status::operator int() const noexcept { return static_cast<int>(ec_); }
Status::Code Status::code() const noexcept { return ec_; } Status::Code Status::code() const noexcept { return ec_; }
} // namespace cmkr::error } // namespace error
} // namespace cmkr
const char *err_string[] = { const char *err_string[] = {
"Success", "Runtime error", "Initialization error", "CMake generation error", "Build error", "Success", "Runtime error", "Initialization error", "CMake generation error", "Build error",

@ -12,7 +12,8 @@
#include <string.h> #include <string.h>
#include <string> #include <string>
namespace cmkr::gen { namespace cmkr {
namespace gen {
namespace detail { namespace detail {
@ -394,7 +395,8 @@ int generate_cmake(const char *path) {
} }
return 0; return 0;
} }
} // namespace cmkr::gen } // namespace gen
} // namespace cmkr
int cmkr_gen_generate_project(const char *typ) { int cmkr_gen_generate_project(const char *typ) {
try { try {

@ -1,6 +1,7 @@
#include "help.h" #include "help.h"
namespace cmkr::help { namespace cmkr {
namespace help {
const char *version() noexcept { return "cmkr version 0.1.2"; } const char *version() noexcept { return "cmkr version 0.1.2"; }
@ -17,7 +18,8 @@ arguments:
version Current cmkr version. version Current cmkr version.
)lit"; )lit";
} }
} // namespace cmkr::help } // namespace help
} // namespace cmkr
const char *cmkr_help_version(void) { return cmkr::help::version(); } const char *cmkr_help_version(void) { return cmkr::help::version(); }

Loading…
Cancel
Save