Skip to content

Commit 4f40f98

Browse files
committed
versioning
1 parent 8380e6f commit 4f40f98

File tree

4 files changed

+153
-3
lines changed

4 files changed

+153
-3
lines changed

__dependency_graph.dot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ digraph {
5050
ProgressData -> vector [color=red]
5151
Resources -> string [color=red]
5252
Resources -> vector [color=red]
53+
Version -> array [color=red]
54+
Version -> cstddef [color=red]
55+
Version -> cstdint [color=red]
56+
Version -> type_traits [color=red]
57+
Version -> utility [color=red]
5358
subgraph "cluster_D:/Dropbox/eclipse/pmGenerator\helper" {
5459
FctHelper
5560
FctHelper
@@ -62,8 +67,10 @@ digraph {
6267
ProgressData
6368
Resources
6469
Resources
70+
Version
6571
}
6672
main -> FctHelper [color=blue]
73+
main -> Version [color=blue]
6774
main -> DRuleReducer [color=blue]
6875
main -> DlProofEnumerator [color=blue]
6976
main -> cstring [color=blue]

helper/Hashing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef XAMID_HELPER_HASHING_H
22
#define XAMID_HELPER_HASHING_H
33

4-
// Idea: http://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set
4+
// Idea: http://stackoverflow.com/q/7110301
55

66
#include <cstddef>
77
#include <functional>
@@ -16,7 +16,7 @@ namespace helper {
1616
// Reciprocal of the golden ratio helps spread entropy
1717
// and handles duplicates.
1818
// See Mike Seymour in magic-numbers-in-boosthash-combine:
19-
// http://stackoverflow.com/questions/4948780
19+
// http://stackoverflow.com/q/4948780
2020

2121
// General function to combine sets of hashable values to one hash
2222
template<class T>

helper/Version.h

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#ifndef XAMID_HELPER_VERSION_H
2+
#define XAMID_HELPER_VERSION_H
3+
4+
#include <array>
5+
#include <cstddef>
6+
#include <cstdint>
7+
#include <type_traits>
8+
#include <utility>
9+
10+
#define TOOL_NAME "pmGenerator"
11+
#define TOOL_REPOSITORY "https://github.com/xamidi/pmGenerator"
12+
#define TOOL_VERSION_MAJOR 1
13+
#define TOOL_VERSION_MINOR 1
14+
#define TOOL_VERSION_PATCH 1
15+
#define TOOL_VERSION_SPEC "1.1.1"
16+
#define TOOL_VERSION_BRANCH "master"
17+
18+
#define BUILD_YEAR \
19+
( \
20+
(__DATE__[ 7] >= '0' && __DATE__[ 7] <= '9' && \
21+
__DATE__[ 8] >= '0' && __DATE__[ 8] <= '9' && \
22+
__DATE__[ 9] >= '0' && __DATE__[ 9] <= '9' && \
23+
__DATE__[10] >= '0' && __DATE__[10] <= '9') ? \
24+
(__DATE__[7] - '0') * 1000 + (__DATE__[8] - '0') * 100 + (__DATE__[9] - '0') * 10 + __DATE__[10] - '0' : UINT32_MAX \
25+
)
26+
static_assert(BUILD_YEAR != UINT32_MAX, "indeterminate build year");
27+
28+
#define BUILD_MONTH \
29+
( \
30+
(__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') ? 1 : \
31+
(__DATE__[0] == 'F') ? 2 : \
32+
(__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') ? 3 : \
33+
(__DATE__[0] == 'A' && __DATE__[1] == 'p') ? 4 : \
34+
(__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') ? 5 : \
35+
(__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') ? 6 : \
36+
(__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') ? 7 : \
37+
(__DATE__[0] == 'A' && __DATE__[1] == 'u') ? 8 : \
38+
(__DATE__[0] == 'S') ? 9 : \
39+
(__DATE__[0] == 'O') ? 10 : \
40+
(__DATE__[0] == 'N') ? 11 : \
41+
(__DATE__[0] == 'D') ? 12 : \
42+
UINT32_MAX \
43+
)
44+
static_assert(BUILD_MONTH != UINT32_MAX, "indeterminate build month");
45+
46+
#define BUILD_DAY \
47+
( \
48+
(__DATE__[4] >= '0' && __DATE__[4] <= '9' && \
49+
__DATE__[5] >= '0' && __DATE__[5] <= '9') ? \
50+
(__DATE__[4] - '0') * 10 + __DATE__[5] - '0' : UINT32_MAX \
51+
)
52+
static_assert(BUILD_DAY != UINT32_MAX, "indeterminate build day");
53+
54+
#define BUILD_HOUR \
55+
( \
56+
(__TIME__[0] >= '0' && __TIME__[0] <= '9' && \
57+
__TIME__[1] >= '0' && __TIME__[1] <= '9') ? \
58+
(__TIME__[0] - '0') * 10 + __TIME__[1] - '0' : UINT32_MAX \
59+
)
60+
static_assert(BUILD_HOUR != UINT32_MAX, "indeterminate build hour");
61+
62+
#define BUILD_MINUTE \
63+
( \
64+
(__TIME__[3] >= '0' && __TIME__[3] <= '9' && \
65+
__TIME__[4] >= '0' && __TIME__[4] <= '9') ? \
66+
(__TIME__[3] - '0') * 10 + __TIME__[4] - '0' : UINT32_MAX \
67+
)
68+
static_assert(BUILD_MINUTE != UINT32_MAX, "indeterminate build minute");
69+
70+
#define BUILD_SECOND \
71+
( \
72+
(__TIME__[6] >= '0' && __TIME__[6] <= '9' && \
73+
__TIME__[7] >= '0' && __TIME__[7] <= '9') ? \
74+
(__TIME__[6] - '0') * 10 + __TIME__[7] - '0' : UINT32_MAX \
75+
)
76+
static_assert(BUILD_SECOND != UINT32_MAX, "indeterminate build second");
77+
78+
namespace xamid {
79+
namespace helper {
80+
81+
// Functional programming with templates to obtain constexpr char arrays
82+
template<std::uint8_t ... Digits> constexpr std::array<char, sizeof...(Digits) + 1> num_array_string = { ('0' + Digits)..., 0 };
83+
template<std::size_t Add, std::uint8_t ... Digits> constexpr std::enable_if_t<Add == 0, std::array<char, sizeof...(Digits) + Add + 1>> add_leading_zeros() {
84+
return num_array_string<Digits...>;
85+
}
86+
template<std::size_t Add, std::uint8_t ... Digits> constexpr std::enable_if_t<Add != 0, std::array<char, sizeof...(Digits) + Add + 1>> add_leading_zeros() {
87+
return add_leading_zeros<Add - 1, 0, Digits...>();
88+
}
89+
template<typename UInt, UInt Num, std::size_t Len = 1, std::uint8_t ... Digits> constexpr std::enable_if_t<Num == 0, std::array<char, Len + 1>> num_to_string() {
90+
return add_leading_zeros<sizeof...(Digits) < Len ? Len - sizeof...(Digits) : 0, Digits...>();
91+
}
92+
template<typename UInt, UInt Num, std::size_t Len = 1, std::uint8_t ... Digits> constexpr std::enable_if_t<Num != 0, std::array<char, Len + 1>> num_to_string() {
93+
return num_to_string<UInt, Num / 10, Len, Num % 10, Digits...>();
94+
}
95+
96+
template<std::size_t N, std::size_t ... Indices> constexpr std::array<char, N> to_string(const char (&s)[N], std::index_sequence<Indices...>) {
97+
return { {s[Indices]...}};
98+
}
99+
template<std::size_t N> constexpr std::array<char, N> to_string(const char (&s)[N]) {
100+
return to_string(s, std::make_index_sequence<N>());
101+
}
102+
template<std::size_t N> constexpr std::array<char, N> to_string(std::array<char, N> s) {
103+
return s;
104+
}
105+
106+
template<typename T, std::size_t ... Lengths> constexpr auto _concatenate(const std::array<T, Lengths>& ... strings) { // for null-terminated strings
107+
std::array<T, ((Lengths - 1) + ...) + 1> result;
108+
std::size_t index = 0;
109+
((std::copy_n(strings.begin(), Lengths, result.begin() + index), index += (Lengths - 1)), ...);
110+
return result;
111+
}
112+
template<typename ... Strings> constexpr auto concatenate(const Strings& ... strings) {
113+
return _concatenate(to_string(strings)...);
114+
}
115+
116+
constexpr std::array<char, 5> __buildYear = num_to_string<std::uint32_t, BUILD_YEAR, 4>();
117+
constexpr std::array<char, 3> __buildMonth = num_to_string<std::uint32_t, BUILD_MONTH, 2>();
118+
constexpr std::array<char, 3> __buildDay = num_to_string<std::uint32_t, BUILD_DAY, 2>();
119+
constexpr std::array<char, 3> __buildHour = num_to_string<std::uint32_t, BUILD_HOUR, 2>();
120+
constexpr std::array<char, 3> __buildMinute = num_to_string<std::uint32_t, BUILD_MINUTE, 2>();
121+
constexpr std::array<char, 3> __buildSecond = num_to_string<std::uint32_t, BUILD_SECOND, 2>();
122+
constexpr std::array<char, 11> __buildDate = concatenate(__buildYear, ".", __buildMonth, ".", __buildDay);
123+
constexpr std::array<char, 9> __buildTime = concatenate(__buildHour, ":", __buildMinute, ":", __buildSecond);
124+
constexpr std::array<char, 16> __buildIdentifier = concatenate(__buildDate, ".", __buildHour, __buildMinute);
125+
constexpr auto __version = concatenate(TOOL_NAME, " ", TOOL_VERSION_SPEC, " ", __buildIdentifier, " ('", TOOL_VERSION_BRANCH, "' branch)");
126+
constexpr auto __repository = to_string(TOOL_REPOSITORY);
127+
128+
} // END namespace helper
129+
130+
constexpr const char* buildYear = helper::__buildYear.data();
131+
constexpr const char* buildMonth = helper::__buildMonth.data();
132+
constexpr const char* buildDay = helper::__buildDay.data();
133+
constexpr const char* buildDate = helper::__buildDate.data();
134+
constexpr const char* buildTime = helper::__buildTime.data();
135+
constexpr const char* buildIdentifier = helper::__buildIdentifier.data();
136+
constexpr const char* version = helper::__version.data();
137+
constexpr const char* repository = helper::__repository.data();
138+
139+
}
140+
141+
#endif // XAMID_HELPER_VERSION_H

main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "helper/FctHelper.h"
2+
#include "helper/Version.h"
23
#include "metamath/DRuleReducer.h"
34
#include "nortmann/DlProofEnumerator.h"
45

@@ -31,7 +32,8 @@ int main(int argc, char* argv[]) { // argc = 1 + N, argv = { <command>, <arg1>,
3132
auto printUsage = [](const string& error = "") {
3233
if (!error.empty())
3334
cerr << error << endl;
34-
cout << "Usage:\n"
35+
cout << "\n" << xamid::version << " ; repository at " << xamid::repository;
36+
cout << "\nUsage:\n"
3537
" pmGenerator ( -g <limit> [-u] [-c] | -r <pmproofs file> <output file> [-i <prefix>] [-c] [-d] | -a <initials> <replacements file> <pmproofs file> <output file> [-s] [-l] [-w] [-d] | -f ( 0 | 1 ) [-i <prefix>] [-o <prefix>] [-d] | -p [-i <prefix>] [-s] [-t] [-x <limit>] [-y <limit>] [-o <output file>] [-d] )+ | -m <limit> [-s]\n"
3638
" -g: Generate proof files\n"
3739
" -u: unfiltered (significantly faster, but generates redundant proofs)\n"

0 commit comments

Comments
 (0)