Now repo builds
This commit is contained in:
parent
93c1285026
commit
e2c61ecd77
|
@ -8,7 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
|||
message("${CMAKE_CXX_COMPILER_ID}")
|
||||
|
||||
# Set c++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Set c++ compiler options
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
mkdir build
|
||||
cd build
|
||||
conan install ..
|
||||
conan install .. --build missing
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j9
|
||||
cd ..
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[requires]
|
||||
boost/1.72.0
|
||||
zlib/1.2.11@conan/stable
|
||||
boost/1.70.0
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
|
|
22
src/main.cpp
22
src/main.cpp
|
@ -5,10 +5,14 @@
|
|||
|
||||
#include "module.h"
|
||||
|
||||
#include "modules/init.h"
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
using namespace boost::program_options;
|
||||
using namespace std;
|
||||
std::map<string, Module> modules;
|
||||
std::map<string, Module> lmodules;
|
||||
modules::init::_mod init;
|
||||
lmodules["init"] = init;
|
||||
|
||||
try {
|
||||
options_description general("General Options.");
|
||||
|
@ -33,32 +37,30 @@ int main(int argc, const char* argv[]) {
|
|||
if (vm.count("help")) {
|
||||
if (vm.count("help-module")) {
|
||||
auto name = vm["help-module"].as<string>();
|
||||
if (modules.find(name) == modules.end()) {
|
||||
if (lmodules.find(name) == lmodules.end()) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
auto module = modules[name];
|
||||
auto module = lmodules[name];
|
||||
std::cout << module._desc << "\n";
|
||||
}
|
||||
else std::cout << general << "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (vm.count("module")) {
|
||||
} else if (vm.count("module")) {
|
||||
auto name = vm["module"].as<string>();
|
||||
|
||||
if (modules.find(name) == modules.end()) {
|
||||
if (lmodules.find(name) == lmodules.end()) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
auto module = modules[name];
|
||||
auto module = lmodules[name];
|
||||
auto args = string{""};
|
||||
|
||||
if (vm.count("module-args"))
|
||||
args = vm["module-args"].as<string>();
|
||||
|
||||
module._dispatcher(args);
|
||||
if (args != "")
|
||||
module._dispatcher(args);
|
||||
}
|
||||
}
|
||||
catch (const error &ex) {
|
||||
|
|
16
src/module.h
16
src/module.h
|
@ -10,13 +10,19 @@
|
|||
#define MODFNSIG(name) \
|
||||
void name(std::string arguments);
|
||||
#define MODFNIMPL(name, code) \
|
||||
void name(std::string arguments) {code};
|
||||
void name(std::string arguments) {code}
|
||||
|
||||
#define MODDISPATCHFN(name, code) \
|
||||
void name(std::string arguments) {code}
|
||||
#define MODARGS(name, code) \
|
||||
struct name {code};
|
||||
#define MAKEMOD(argsname) \
|
||||
struct _mod : argsname {argsname _args;};
|
||||
#define MODDISPATCHFNSIG(name) \
|
||||
void name(std::string arguments);
|
||||
#define MODDISPATCHFNIMPL(name, code) \
|
||||
void name(std::string arguments) {code}
|
||||
|
||||
#define MODARGS(code) \
|
||||
struct _args {code}
|
||||
#define MAKEMOD() \
|
||||
struct _mod : _args, Module {}
|
||||
|
||||
using ModuleFn = std::function<void(std::string arguments)>;
|
||||
using ModuleFnDispatcher = std::function<void(std::string arguments)>;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "init.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace modules {
|
||||
namespace init {
|
||||
MODFNIMPL(init_create, {
|
||||
std::cout << "CREATE";
|
||||
});
|
||||
|
||||
MODDISPATCHFNIMPL(init__dispatch, {
|
||||
std::cout << arguments;
|
||||
});
|
||||
}
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef MODULE_INIT_H
|
||||
#define MODULE_INIT_H
|
||||
|
||||
#include "module.h"
|
||||
|
||||
namespace modules {
|
||||
namespace init {
|
||||
MODARGS(
|
||||
std::string _location;
|
||||
);
|
||||
MAKEMOD();
|
||||
|
||||
MODDISPATCHFNSIG(init__dispatch);
|
||||
|
||||
MODFNSIG(init__create);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue