-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcppkg.hpp
More file actions
99 lines (91 loc) · 3.31 KB
/
cppkg.hpp
File metadata and controls
99 lines (91 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once
#ifndef __CPPM_CORE_CPPKG_HPP__
#define __CPPM_CORE_CPPKG_HPP__
#include <serdepp/utility.hpp>
#include <cppm/core/dependency.hpp>
namespace cppm::core {
enum class cppkg_type {
bin,
lib,
test,
example,
cmake,
};
enum class cppkg_type_detail {
STATIC,
BINARY,
SHARED,
HEADER_ONLY,
};
struct Cppkg {
DERIVE_SERDE(Cppkg,
(&Self::name, "name")
(&Self::namespace_, "namespace")
(&Self::install, "install", default_{true})
(&Self::source, "source", make_optional)
(&Self::exclude, "flag", default_{false})
)
std::string name;
cppkg_type type;
cppkg_type_detail cppkg_type_d;
std::optional<std::string> namespace_;
bool install;
std::vector<std::string> source;
std::string exclude_var;
bool exclude;
virtual ~Cppkg() = default;
};
struct CppkgLib : Cppkg {
template<class Context>
constexpr static void serde(Context& context, CppkgLib& value) {
using namespace serde::attribute;
using Self = CppkgLib;
Cppkg& upcast = static_cast<Cppkg&>(value);
Cppkg::serde(context, upcast);
serde::serde_struct(context, value)
(&Self::type, "cppkg_type", default_{cppkg_type::lib})
(&Self::cppkg_type_d, "type", default_{cppkg_type_detail::STATIC}, under_to_dash, to_lower)
;
}
};
struct CppkgBin : Cppkg {
template<class Context>
constexpr static void serde(Context& context, CppkgBin& value) {
using namespace serde::attribute;
using Self = CppkgBin;
Cppkg& upcast = static_cast<Cppkg&>(value);
Cppkg::serde(context, upcast);
serde::serde_struct(context, value)
(&Self::type, "cppkg_type", default_{cppkg_type::bin})
(&Self::cppkg_type_d, "type", default_{cppkg_type_detail::BINARY}, under_to_dash, to_lower)
;
}
};
struct CppkgExample : Cppkg {
template<class Context>
constexpr static void serde(Context& context, CppkgExample& value) {
using namespace serde::attribute;
using Self = CppkgExample;
Cppkg& upcast = static_cast<Cppkg&>(value);
Cppkg::serde(context, upcast);
serde::serde_struct(context, value)
(&Self::type, "cppkg_type", default_{cppkg_type::example})
(&Self::cppkg_type_d, "type", default_{cppkg_type_detail::BINARY}, under_to_dash, to_lower)
;
}
};
struct CppkgTest : Cppkg {
template<class Context>
constexpr static void serde(Context& context, CppkgTest& value) {
using namespace serde::attribute;
using Self = CppkgTest;
Cppkg& upcast = static_cast<Cppkg&>(value);
Cppkg::serde(context, upcast);
serde::serde_struct(context, value)
(&Self::type, "cppkg_type", default_{cppkg_type::test})
(&Self::cppkg_type_d, "type", default_{cppkg_type_detail::BINARY}, under_to_dash, to_lower)
;
}
};
}
#endif