fix C++11 build

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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -3,14 +3,15 @@
#include "gen.h"
#include "help.h"
#include <exception>
#include "fs.hpp"
#include <exception>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
namespace cmkr::args {
namespace cmkr {
namespace args {
const char *handle_args(int argc, char **argv) {
std::vector<std::string> 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 {

@ -10,7 +10,8 @@
#include <stdlib.h>
#include <system_error>
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 {

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

@ -2,7 +2,8 @@
#include <assert.h>
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<int>(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",

@ -12,7 +12,8 @@
#include <string.h>
#include <string>
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 {

@ -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(); }

Loading…
Cancel
Save