diff --git a/CMakeLists.txt b/CMakeLists.txt index 698b4953e..d5baa7647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,11 +220,14 @@ if (WITH_HTTPD) else() message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support") endif() + + add_definitions(/DXMRIG_FEATURE_HTTP) + add_definitions(/DXMRIG_FEATURE_API) else() set(HTTPD_SOURCES "") set(MHD_LIBRARY "") - add_definitions(/DXMRIG_NO_HTTPD) - add_definitions(/DXMRIG_NO_API) + remove_definitions(/DXMRIG_FEATURE_HTTP) + remove_definitions(/DXMRIG_FEATURE_API) endif() include_directories(src) diff --git a/src/App.cpp b/src/App.cpp index f33140c92..b404c831f 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -45,7 +45,7 @@ #include "workers/Workers.h" -#ifndef XMRIG_NO_HTTPD +#ifdef XMRIG_FEATURE_HTTP # include "common/api/Httpd.h" #endif @@ -72,7 +72,7 @@ xmrig::App::~App() delete m_console; delete m_controller; -# ifndef XMRIG_NO_HTTPD +# ifdef XMRIG_FEATURE_HTTP delete m_httpd; # endif } @@ -98,11 +98,11 @@ int xmrig::App::exec() return 0; } -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API Api::start(m_controller); # endif -# ifndef XMRIG_NO_HTTPD +# ifdef XMRIG_FEATURE_HTTP m_httpd = new Httpd( m_controller->config()->apiPort(), m_controller->config()->apiToken(), @@ -185,7 +185,7 @@ void xmrig::App::onSignal(int signum) void xmrig::App::close() { -# ifndef XMRIG_NO_HTTPD +# ifdef XMRIG_FEATURE_HTTP m_httpd->stop(); # endif diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index 5b335453e..5af4db78d 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -27,11 +27,6 @@ #include -#ifndef XMRIG_NO_HTTPD -# include -#endif - - #ifdef XMRIG_FEATURE_TLS # include #endif @@ -73,10 +68,6 @@ static int showVersion() printf("\nlibuv/%s\n", uv_version_string()); -# ifndef XMRIG_NO_HTTPD - printf("microhttpd/%s\n", MHD_get_version()); -# endif - # if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT) { constexpr const char *v = OPENSSL_VERSION_TEXT + 8; diff --git a/src/common/config/CommonConfig.cpp b/src/common/config/CommonConfig.cpp index 94a20f80b..e42402d48 100644 --- a/src/common/config/CommonConfig.cpp +++ b/src/common/config/CommonConfig.cpp @@ -30,7 +30,7 @@ #include -#ifndef XMRIG_NO_HTTPD +#ifdef XMRIG_FEATURE_HTTP # include #endif @@ -82,7 +82,7 @@ xmrig::CommonConfig::CommonConfig() : void xmrig::CommonConfig::printAPI() { -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API if (apiPort() == 0) { return; } @@ -131,7 +131,7 @@ void xmrig::CommonConfig::printVersions() # else memset(buf, 0, 16); -# if !defined(XMRIG_NO_HTTPD) || defined(XMRIG_FEATURE_TLS) +# if defined(XMRIG_FEATURE_HTTP) || defined(XMRIG_FEATURE_TLS) int length = 0; # endif # endif @@ -143,7 +143,7 @@ void xmrig::CommonConfig::printVersions() } # endif -# ifndef XMRIG_NO_HTTPD +# ifdef XMRIG_FEATURE_HTTP length += snprintf(buf + length, (sizeof buf) - length, "microhttpd/%s ", MHD_get_version()); # endif diff --git a/src/interfaces/IThread.h b/src/interfaces/IThread.h index 3a8708e63..e74b5bca4 100644 --- a/src/interfaces/IThread.h +++ b/src/interfaces/IThread.h @@ -51,7 +51,7 @@ public: PentaWay }; - virtual ~IThread() {} + virtual ~IThread() = default; virtual Algo algorithm() const = 0; virtual int priority() const = 0; @@ -61,7 +61,7 @@ public: virtual size_t index() const = 0; virtual Type type() const = 0; -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API virtual rapidjson::Value toAPI(rapidjson::Document &doc) const = 0; # endif diff --git a/src/net/Network.cpp b/src/net/Network.cpp index fbb6d8a11..b8e2e012b 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -197,7 +197,7 @@ void xmrig::Network::tick() m_donate->tick(now); } -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API Api::tick(m_state); # endif } diff --git a/src/workers/CpuThread.cpp b/src/workers/CpuThread.cpp index 529027f5b..2481162ce 100644 --- a/src/workers/CpuThread.cpp +++ b/src/workers/CpuThread.cpp @@ -706,7 +706,7 @@ void xmrig::CpuThread::print() const #endif -#ifndef XMRIG_NO_API +#ifdef XMRIG_FEATURE_API rapidjson::Value xmrig::CpuThread::toAPI(rapidjson::Document &doc) const { using namespace rapidjson; diff --git a/src/workers/CpuThread.h b/src/workers/CpuThread.h index 05d4a0661..2af421be9 100644 --- a/src/workers/CpuThread.h +++ b/src/workers/CpuThread.h @@ -90,7 +90,7 @@ protected: void print() const override; # endif -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API rapidjson::Value toAPI(rapidjson::Document &doc) const override; # endif diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index 08c168289..79045df7d 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -237,7 +237,7 @@ void Workers::submit(const xmrig::JobResult &result) } -#ifndef XMRIG_NO_API +#ifdef XMRIG_FEATURE_API void Workers::threadsSummary(rapidjson::Document &doc) { uv_mutex_lock(&m_mutex); diff --git a/src/workers/Workers.h b/src/workers/Workers.h index 4b6fc9cf1..5b084fc2d 100644 --- a/src/workers/Workers.h +++ b/src/workers/Workers.h @@ -68,7 +68,7 @@ public: static inline void pause() { m_active = false; m_paused = 1; m_sequence++; } static inline void setListener(xmrig::IJobResultListener *listener) { m_listener = listener; } -# ifndef XMRIG_NO_API +# ifdef XMRIG_FEATURE_API static void threadsSummary(rapidjson::Document &doc); # endif