From 01f0b860d37a0beb3e3d296facac205ace7ccc93 Mon Sep 17 00:00:00 2001 From: Russel Waters Date: Tue, 29 Jan 2019 16:26:06 -0500 Subject: [PATCH] PATCH to indicate RC, Updated Version responses (#1643) * Use Patch Version to indicate if RC or not. If Patch version == 0 Final Release else RC appended * add defines for NANO_MAJOR_MINOR_VERSION and NANO_MAJOR_MINOR_RC_VERSION * Revert "add defines for NANO_MAJOR_MINOR_VERSION and NANO_MAJOR_MINOR_RC_VERSION" This reverts commit 8c569d631146eba1dd30ca18193bfcdaa6c7e8a6. * use static const char --- CMakeLists.txt | 6 ++---- appveyor.yml | 4 +--- nano/core_test/CMakeLists.txt | 3 ++- nano/core_test/rpc.cpp | 9 ++++++++- nano/nano_node/CMakeLists.txt | 3 ++- nano/nano_node/entry.cpp | 9 ++++++++- nano/node/CMakeLists.txt | 3 ++- nano/node/node.cpp | 10 +++++++++- nano/node/node.hpp | 9 +++++++++ nano/node/rpc.cpp | 9 ++++++++- nano/qt/qt.cpp | 9 ++++++++- 11 files changed, 59 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a9b2f21..a79482da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,6 @@ project (nano-node) set (CPACK_PACKAGE_VERSION_MAJOR "18") set (CPACK_PACKAGE_VERSION_MINOR "0") set (CPACK_PACKAGE_VERSION_PATCH "0") -if (DEFINED GIT_COMMIT) - set (CPACK_PACKAGE_VERSION_PATCH "GIT-${GIT_COMMIT}") -endif () set (CPACK_PACKAGE_VENDOR "Nano Currency") set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") @@ -307,7 +304,8 @@ if (NANO_GUI OR RAIBLOCKS_GUI) target_compile_definitions(qt PRIVATE -DNANO_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} - -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR}) + -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} + -DNANO_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}) if (WIN32) set (PLATFORM_GUI_TARGET_PROPERTIES WIN32) diff --git a/appveyor.yml b/appveyor.yml index a1b50a16..2f1987c3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,11 +13,9 @@ environment: clone_folder: C:\projects\myproject install: - cmd: >- - SET GIT_COMMIT=%APPVEYOR_REPO_COMMIT:~0,3% - git submodule update --init --recursive - cmake -DNANO_GUI=ON -DACTIVE_NETWORK=%NETWORK% -DQt5_DIR="C:\Qt\5.9\msvc2017_64\lib\cmake\Qt5" -DNANO_SIMD_OPTIMIZATIONS=TRUE -DBoost_COMPILER="-vc141" -DBOOST_ROOT="C:/Libraries/boost_1_66_0" -DBOOST_LIBRARYDIR="C:/Libraries/boost_1_66_0/lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -DIPHLPAPI_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/iphlpapi.lib" -DWINSOCK2_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/WS2_32.lib" -DGIT_COMMIT=%GIT_COMMIT% + cmake -DNANO_GUI=ON -DACTIVE_NETWORK=%NETWORK% -DQt5_DIR="C:\Qt\5.9\msvc2017_64\lib\cmake\Qt5" -DNANO_SIMD_OPTIMIZATIONS=TRUE -DBoost_COMPILER="-vc141" -DBOOST_ROOT="C:/Libraries/boost_1_66_0" -DBOOST_LIBRARYDIR="C:/Libraries/boost_1_66_0/lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -DIPHLPAPI_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/iphlpapi.lib" -DWINSOCK2_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/WS2_32.lib" diff --git a/nano/core_test/CMakeLists.txt b/nano/core_test/CMakeLists.txt index e4c0979a..125d1bac 100644 --- a/nano/core_test/CMakeLists.txt +++ b/nano/core_test/CMakeLists.txt @@ -27,5 +27,6 @@ add_executable (core_test target_compile_definitions(core_test PRIVATE -DNANO_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} - -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR}) + -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} + -DNANO_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}) target_link_libraries (core_test node secure gtest_main gtest libminiupnpc-static Boost::boost) diff --git a/nano/core_test/rpc.cpp b/nano/core_test/rpc.cpp index 442c6add..7a90ac53 100644 --- a/nano/core_test/rpc.cpp +++ b/nano/core_test/rpc.cpp @@ -1748,7 +1748,14 @@ TEST (rpc, version) ASSERT_EQ (std::to_string (node1->store.version_get (transaction)), response1.json.get ("store_version")); } ASSERT_EQ (std::to_string (nano::protocol_version), response1.json.get ("protocol_version")); - ASSERT_EQ (boost::str (boost::format ("Nano %1%.%2%") % NANO_VERSION_MAJOR % NANO_VERSION_MINOR), response1.json.get ("node_vendor")); + if (NANO_VERSION_PATCH == 0) + { + ASSERT_EQ (boost::str (boost::format ("Nano %1%") % NANO_MAJOR_MINOR_VERSION), response1.json.get ("node_vendor")); + } + else + { + ASSERT_EQ (boost::str (boost::format ("Nano %1%") % NANO_MAJOR_MINOR_RC_VERSION), response1.json.get ("node_vendor")); + } auto headers (response1.resp.base ()); auto allowed_origin (headers.at ("Access-Control-Allow-Origin")); auto allowed_headers (headers.at ("Access-Control-Allow-Headers")); diff --git a/nano/nano_node/CMakeLists.txt b/nano/nano_node/CMakeLists.txt index fa714a67..4640572f 100644 --- a/nano/nano_node/CMakeLists.txt +++ b/nano/nano_node/CMakeLists.txt @@ -14,7 +14,8 @@ target_link_libraries (nano_node target_compile_definitions(nano_node PRIVATE -DNANO_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} - -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR}) + -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} + -DNANO_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}) set_target_properties (nano_node PROPERTIES diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index ca35dbff..71c6826f 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -826,7 +826,14 @@ int main (int argc, char * const * argv) } else if (vm.count ("version")) { - std::cout << "Version " << NANO_VERSION_MAJOR << "." << NANO_VERSION_MINOR << std::endl; + if (NANO_VERSION_PATCH == 0) + { + std::cout << "Version " << NANO_MAJOR_MINOR_VERSION << std::endl; + } + else + { + std::cout << "Version " << NANO_MAJOR_MINOR_RC_VERSION << std::endl; + } } else { diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index d634c5f5..299d9a48 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -72,4 +72,5 @@ target_link_libraries (node target_compile_definitions(node PRIVATE -DNANO_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} - -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR}) + -DNANO_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} + -DNANO_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index c531fc6a..7654f0ca 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1971,7 +1971,15 @@ startup_time (std::chrono::steady_clock::now ()) } } }); - BOOST_LOG (log) << "Node starting, version: " << NANO_VERSION_MAJOR << "." << NANO_VERSION_MINOR; + if (NANO_VERSION_PATCH == 0) + { + BOOST_LOG (log) << "Node starting, version: " << NANO_MAJOR_MINOR_VERSION; + } + else + { + BOOST_LOG (log) << "Node starting, version: " << NANO_MAJOR_MINOR_RC_VERSION; + } + BOOST_LOG (log) << boost::str (boost::format ("Work pool running %1% threads") % work.threads.size ()); if (!init_a.error ()) { diff --git a/nano/node/node.hpp b/nano/node/node.hpp index 85573551..41f5ecd8 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -24,6 +24,15 @@ #include #include +#define xstr(a) ver_str (a) +#define ver_str(a) #a + +/** +* Returns build version information +*/ +static const char * NANO_MAJOR_MINOR_VERSION = xstr (NANO_VERSION_MAJOR) "." xstr (NANO_VERSION_MINOR); +static const char * NANO_MAJOR_MINOR_RC_VERSION = xstr (NANO_VERSION_MAJOR) "." xstr (NANO_VERSION_MINOR) "RC" xstr (NANO_VERSION_PATCH); + namespace nano { class node; diff --git a/nano/node/rpc.cpp b/nano/node/rpc.cpp index 8c3c7e0a..5bca5a2f 100644 --- a/nano/node/rpc.cpp +++ b/nano/node/rpc.cpp @@ -3231,7 +3231,14 @@ void nano::rpc_handler::version () response_l.put ("rpc_version", "1"); response_l.put ("store_version", std::to_string (node.store_version ())); response_l.put ("protocol_version", std::to_string (nano::protocol_version)); - response_l.put ("node_vendor", boost::str (boost::format ("Nano %1%.%2%") % NANO_VERSION_MAJOR % NANO_VERSION_MINOR)); + if (NANO_VERSION_PATCH == 0) + { + response_l.put ("node_vendor", boost::str (boost::format ("Nano %1%") % NANO_MAJOR_MINOR_VERSION)); + } + else + { + response_l.put ("node_vendor", boost::str (boost::format ("Nano %1%") % NANO_MAJOR_MINOR_RC_VERSION)); + } response_errors (); } diff --git a/nano/qt/qt.cpp b/nano/qt/qt.cpp index 3d640fc5..21e180fd 100644 --- a/nano/qt/qt.cpp +++ b/nano/qt/qt.cpp @@ -81,7 +81,14 @@ wallet (wallet_a) { network = "Test"; } - version = new QLabel (boost::str (boost::format ("Version %1%.%2% %3% network") % NANO_VERSION_MAJOR % NANO_VERSION_MINOR % network).c_str ()); + if (NANO_VERSION_PATCH == 0) + { + version = new QLabel (boost::str (boost::format ("Version %1% %2% network") % NANO_MAJOR_MINOR_VERSION % network).c_str ()); + } + else + { + version = new QLabel (boost::str (boost::format ("Version %1% %2% network") % NANO_MAJOR_MINOR_RC_VERSION % network).c_str ()); + } self_layout->addWidget (your_account_label); self_layout->addStretch (); self_layout->addWidget (version);