diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f7afaa..4c37e24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,6 +382,12 @@ if (HAVE_PTHREAD_SETNAME_NP) add_definitions(-DHAVE_PTHREAD_SETNAME_NP) endif() +check_c_source_compiles("#include \nint main() { return (gnu_get_libc_version() && gnu_get_libc_release()) ? 0 : 1; }" HAVE_GLIBC) + +if (HAVE_GLIBC) + add_definitions(-DHAVE_GLIBC) +endif() + add_definitions("-DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag") if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Release")) diff --git a/src/console_commands.cpp b/src/console_commands.cpp index 62dbcda..db4311f 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -330,7 +330,7 @@ static void do_exit(p2pool *m_pool, const char * /* args */) // cppcheck-suppress constParameterCallback static void do_version(p2pool* m_pool, const char* /* args */) { - LOGINFO(0, log::LightCyan() << VERSION); + LOGINFO(0, log::LightCyan() << p2pool_version()); const P2PServer* p2p = m_pool->p2p_server(); if (p2p) { diff --git a/src/main.cpp b/src/main.cpp index 0f4ca2e..2128f77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -119,11 +119,6 @@ void p2pool_usage() ); } -void p2pool_version() -{ - printf("P2Pool %s\n", p2pool::VERSION); -} - int p2pool_test() { printf("Self-test started\n"); @@ -232,7 +227,7 @@ int main(int argc, char* argv[]) } if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "/version") || !strcmp(argv[i], "-v") || !strcmp(argv[i], "/v")) { - p2pool_version(); + puts(p2pool::p2pool_version().c_str()); return 0; } diff --git a/src/util.cpp b/src/util.cpp index e5da1b2..c2fd5c7 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -40,6 +40,19 @@ #include #endif +#include +#include + +#ifdef HAVE_GLIBC +#include +#endif + +#ifdef WITH_GRPC +#include +#endif + +#include + LOG_CATEGORY(Util) namespace p2pool { @@ -60,6 +73,36 @@ const char* VERSION = "v" STR2(P2POOL_VERSION_MAJOR) "." STR2(P2POOL_VERSION_MIN #endif " on " __DATE__ ")"; +std::string p2pool_version() +{ + const curl_version_info_data* curl_version = curl_version_info(CURLVERSION_NOW); + + int zmq_major, zmq_minor, zmq_patch; + zmq_version(&zmq_major, &zmq_minor, &zmq_patch); + + char buf[384] = {}; + log::Stream s(buf); + + s << "P2Pool " << VERSION << '\n' + << "\nDependencies:\n" +#ifdef HAVE_GLIBC + << " - glibc " << gnu_get_libc_version() << '-' << gnu_get_libc_release() << '\n' +#endif +#ifdef WITH_GRPC + << " - grpc " << GRPC_CPP_VERSION_STRING << '\n' +#endif + << " - libcurl " << (curl_version ? curl_version->version : "unknown") << '\n' + << " - libuv " << uv_version_string() << '\n' + << " - libzmq " << zmq_major << '.' << zmq_minor << '.' << zmq_patch << '\n' +#ifdef WITH_UPNP + << " - miniupnpc " << MINIUPNPC_VERSION << '\n' +#endif + << " - rapidjson " << RAPIDJSON_VERSION_STRING << '\n' + ; + + return std::string(buf, s.m_pos); +} + const uint8_t ED25519_MASTER_PUBLIC_KEY[32] = {51,175,37,73,203,241,188,115,195,255,123,53,218,120,90,74,186,240,82,178,67,139,124,91,180,106,188,181,187,51,236,10}; std::string DATA_DIR; diff --git a/src/util.h b/src/util.h index c35c5b2..fbbc460 100644 --- a/src/util.h +++ b/src/util.h @@ -381,12 +381,13 @@ void show_top_10_allocations(); void minidump_and_crash(size_t delay); #endif +std::string p2pool_version(); + } // namespace p2pool void memory_tracking_start(); bool memory_tracking_stop(); void p2pool_usage(); -void p2pool_version(); int p2pool_test(); namespace robin_hood {