diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-05-02 00:48:35 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-05-04 19:53:21 +0300 |
commit | 8f9f4ba5e2b738fb63c2d6cdcfdce5c169d4e88c (patch) | |
tree | 71152c9eb7226c3cbb9f52b6c114210f2610a54d | |
parent | 35f1189ea7365c1fdaf7dd9ac5e90fc8af69eae7 (diff) |
refactor: Remove duplicated code
-rwxr-xr-x | share/genbuild.sh | 2 | ||||
-rw-r--r-- | src/clientversion.cpp | 30 |
2 files changed, 13 insertions, 19 deletions
diff --git a/share/genbuild.sh b/share/genbuild.sh index 1cf480b411..1153df933f 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -38,7 +38,7 @@ fi if [ -n "$GIT_TAG" ]; then NEWINFO="#define BUILD_GIT_TAG \"$GIT_TAG\"" elif [ -n "$GIT_COMMIT" ]; then - NEWINFO="#define BUILD_GIT_COMMIT $GIT_COMMIT" + NEWINFO="#define BUILD_GIT_COMMIT \"$GIT_COMMIT\"" else NEWINFO="// No build information available" fi diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 86f28e01c8..cd8eebc760 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -30,28 +30,22 @@ const std::string CLIENT_NAME("Satoshi"); #define GIT_COMMIT_DATE "$Format:%cD$" #endif -#define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \ - "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix) - -#define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \ - "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit - -#define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \ - "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk" - #ifdef BUILD_GIT_TAG -#define BUILD_DESC BUILD_GIT_TAG + #define BUILD_DESC BUILD_GIT_TAG + #define BUILD_SUFFIX "" #else -#ifdef BUILD_GIT_COMMIT -#define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_GIT_COMMIT) -#elif defined(GIT_COMMIT_ID) -#define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) -#else -#define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) -#endif + #define BUILD_DESC "v" STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) \ + "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) + #ifdef BUILD_GIT_COMMIT + #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT + #elif defined(GIT_COMMIT_ID) + #define BUILD_SUFFIX "-g" GIT_COMMIT_ID + #else + #define BUILD_SUFFIX "-unk" + #endif #endif -const std::string CLIENT_BUILD(BUILD_DESC); +const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX); static std::string FormatVersion(int nVersion) { |