Fixed windows build
This commit is contained in:
parent
0dc02587c1
commit
627321b6cc
9 changed files with 84 additions and 28 deletions
|
@ -255,7 +255,7 @@ if (WITH_CC)
|
||||||
if (CURL_FOUND)
|
if (CURL_FOUND)
|
||||||
include_directories(${CURL_INCLUDE_DIRS})
|
include_directories(${CURL_INCLUDE_DIRS})
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_CC=OFF` to build without CC Server support")
|
message(FATAL_ERROR "curl NOT found: use `-DWITH_CC=OFF` to build without CC Server support")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HEADERS_CC_COMMON
|
set(HEADERS_CC_COMMON
|
||||||
|
@ -295,7 +295,7 @@ include_directories(${UV_INCLUDE_DIR})
|
||||||
add_executable(xmrigMiner ${HEADERS} ${SOURCES} ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_CLIENT} ${HEADERS_CC_CLIENT})
|
add_executable(xmrigMiner ${HEADERS} ${SOURCES} ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_CLIENT} ${HEADERS_CC_CLIENT})
|
||||||
target_link_libraries(xmrigMiner ${UV_LIBRARIES} ${MHD_LIBRARY} ${CURL_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
target_link_libraries(xmrigMiner ${UV_LIBRARIES} ${MHD_LIBRARY} ${CURL_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||||
|
|
||||||
add_executable(xmrigDaemon src/xmrigd.cpp)
|
add_executable(xmrigDaemon src/xmrigd.cpp res/app.rc)
|
||||||
|
|
||||||
if (WITH_CC AND MHD_FOUND AND CURL_FOUND)
|
if (WITH_CC AND MHD_FOUND AND CURL_FOUND)
|
||||||
add_executable(xmrigCCServer ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${SOURCES_SYSLOG} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_SERVER} ${HEADERS_CC_SERVER})
|
add_executable(xmrigCCServer ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${SOURCES_SYSLOG} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_SERVER} ${HEADERS_CC_SERVER})
|
||||||
|
|
32
appveyor.yml
Normal file
32
appveyor.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# image
|
||||||
|
image: Visual Studio 2017
|
||||||
|
|
||||||
|
# build platform
|
||||||
|
platform: x64
|
||||||
|
configuration: Release
|
||||||
|
|
||||||
|
# clone directory
|
||||||
|
clone_folder: c:\xmrigCC
|
||||||
|
|
||||||
|
install:
|
||||||
|
- mkdir c:\xmrigCC-deps
|
||||||
|
- curl -sL https://github.com/xmrig/xmrig-deps/releases/download/v2/xmrig-deps-v2.zip -o xmrigCC-deps-v2.zip
|
||||||
|
- 7z x xmrigCC-deps-v2.zip -o"c:\xmrigCC-deps" -y > nul
|
||||||
|
- vcpkg install curl:x64-windows
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat"
|
||||||
|
- cd c:\xmrigCC
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- set CMAKE_PREFIX_PATH=c:\xmrigCC-deps\msvc2017\libuv\x64\;c:\xmrigCC-deps\msvc2017\libmicrohttpd\x64\;C:\Tools\vcpkg\installed\x64-windows\
|
||||||
|
- cmake -G "Visual Studio 15 2017 Win64" -T v141,host=x64 ..
|
||||||
|
- msbuild xmrig.sln /p:Configuration=Release
|
||||||
|
|
||||||
|
after_build:
|
||||||
|
- cd c:\xmrigCC
|
||||||
|
- cmd: 7z a xmrigCC.zip "c:\xmrigCC\build\Release\*.*" "c:\xmrigCC\src\*config*" "C:\Tools\vcpkg\installed\x64-windows\lib\*.dll" "c:\xmrigCC\index.html"
|
||||||
|
- cmd: dir
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
- path: xmrigCC.zip
|
13
src/App.cpp
13
src/App.cpp
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#include <zconf.h>
|
|
||||||
|
|
||||||
#include "api/Api.h"
|
#include "api/Api.h"
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
@ -111,7 +110,9 @@ App::~App()
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_NO_CC
|
# ifndef XMRIG_NO_CC
|
||||||
delete m_ccclient;
|
if (m_ccclient) {
|
||||||
|
delete m_ccclient;
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +147,11 @@ int App::start()
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_NO_CC
|
# ifndef XMRIG_NO_CC
|
||||||
m_ccclient = new CCClient(m_options);
|
if (m_options->ccUrl()) {
|
||||||
|
m_ccclient = new CCClient(m_options);
|
||||||
|
} else {
|
||||||
|
LOG_WARN("Please configure CC-Url and restart. CC feature is now deactivated.");
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
Workers::start(m_options->affinity(), m_options->priority());
|
Workers::start(m_options->affinity(), m_options->priority());
|
||||||
|
@ -156,7 +161,7 @@ int App::start()
|
||||||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||||
uv_loop_close(uv_default_loop());
|
uv_loop_close(uv_default_loop());
|
||||||
|
|
||||||
return m_restart ? ERESTART : r;
|
return m_restart ? EINTR : r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::onConsoleCommand(char command)
|
void App::onConsoleCommand(char command)
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <zconf.h>
|
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "interfaces/IConsoleListener.h"
|
#include "interfaces/IConsoleListener.h"
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,6 @@ Options::Options(int argc, char **argv) :
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifndef XMRIG_NO_CC
|
#ifndef XMRIG_NO_CC
|
||||||
if (!m_daemonized) {
|
if (!m_daemonized) {
|
||||||
fprintf(stderr, "\"" APP_ID "\" is compiled with CC support, please start the daemon instead.\n");
|
fprintf(stderr, "\"" APP_ID "\" is compiled with CC support, please start the daemon instead.\n");
|
||||||
|
|
|
@ -22,11 +22,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zconf.h>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <3rdparty/rapidjson/stringbuffer.h>
|
#include <3rdparty/rapidjson/stringbuffer.h>
|
||||||
#include <3rdparty/rapidjson/prettywriter.h>
|
#include <3rdparty/rapidjson/prettywriter.h>
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
|
# include "winsock2.h"
|
||||||
|
#else
|
||||||
|
# include "unistd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "CCClient.h"
|
#include "CCClient.h"
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
#include "ControlCommand.h"
|
#include "ControlCommand.h"
|
||||||
|
@ -42,6 +47,8 @@ uv_mutex_t CCClient::m_mutex;
|
||||||
CCClient::CCClient(const Options *options)
|
CCClient::CCClient(const Options *options)
|
||||||
: m_options(options)
|
: m_options(options)
|
||||||
{
|
{
|
||||||
|
uv_mutex_init(&m_mutex);
|
||||||
|
|
||||||
m_self = this;
|
m_self = this;
|
||||||
|
|
||||||
std::string clientId;
|
std::string clientId;
|
||||||
|
@ -75,10 +82,12 @@ void CCClient::updateHashrate(const Hashrate *hashrate)
|
||||||
{
|
{
|
||||||
uv_mutex_lock(&m_mutex);
|
uv_mutex_lock(&m_mutex);
|
||||||
|
|
||||||
m_self->m_clientStatus.setHashrateShort(hashrate->calc(Hashrate::ShortInterval));
|
if (m_self) {
|
||||||
m_self->m_clientStatus.setHashrateMedium(hashrate->calc(Hashrate::MediumInterval));
|
m_self->m_clientStatus.setHashrateShort(hashrate->calc(Hashrate::ShortInterval));
|
||||||
m_self->m_clientStatus.setHashrateLong(hashrate->calc(Hashrate::LargeInterval));
|
m_self->m_clientStatus.setHashrateMedium(hashrate->calc(Hashrate::MediumInterval));
|
||||||
m_self->m_clientStatus.setHashrateHighest(hashrate->highest());
|
m_self->m_clientStatus.setHashrateLong(hashrate->calc(Hashrate::LargeInterval));
|
||||||
|
m_self->m_clientStatus.setHashrateHighest(hashrate->highest());
|
||||||
|
}
|
||||||
|
|
||||||
uv_mutex_unlock(&m_mutex);
|
uv_mutex_unlock(&m_mutex);
|
||||||
}
|
}
|
||||||
|
@ -88,13 +97,14 @@ void CCClient::updateNetworkState(const NetworkState &network)
|
||||||
{
|
{
|
||||||
uv_mutex_lock(&m_mutex);
|
uv_mutex_lock(&m_mutex);
|
||||||
|
|
||||||
m_self->m_clientStatus.setCurrentStatus(Workers::isEnabled() ? ClientStatus::RUNNING : ClientStatus::PAUSED);
|
if (m_self) {
|
||||||
m_self->m_clientStatus.setCurrentPool(network.pool);
|
m_self->m_clientStatus.setCurrentStatus(Workers::isEnabled() ? ClientStatus::RUNNING : ClientStatus::PAUSED);
|
||||||
m_self->m_clientStatus.setSharesGood(network.accepted);
|
m_self->m_clientStatus.setCurrentPool(network.pool);
|
||||||
m_self->m_clientStatus.setSharesTotal(network.accepted + network.rejected);
|
m_self->m_clientStatus.setSharesGood(network.accepted);
|
||||||
m_self->m_clientStatus.setHashesTotal(network.total);
|
m_self->m_clientStatus.setSharesTotal(network.accepted + network.rejected);
|
||||||
m_self->m_clientStatus.setAvgTime(network.avgTime());
|
m_self->m_clientStatus.setHashesTotal(network.total);
|
||||||
|
m_self->m_clientStatus.setAvgTime(network.avgTime());
|
||||||
|
}
|
||||||
uv_mutex_unlock(&m_mutex);
|
uv_mutex_unlock(&m_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +220,9 @@ CURLcode CCClient::performCurl(const std::string& requestUrl, const std::string&
|
||||||
|
|
||||||
void CCClient::onReport(uv_timer_t *handle)
|
void CCClient::onReport(uv_timer_t *handle)
|
||||||
{
|
{
|
||||||
m_self->publishClientStatusReport();
|
if (m_self) {
|
||||||
|
m_self->publishClientStatusReport();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCClient::onResponse(char* data, size_t size, size_t nmemb, std::string* responseBuffer)
|
int CCClient::onResponse(char* data, size_t size, size_t nmemb, std::string* responseBuffer)
|
||||||
|
@ -224,4 +236,3 @@ int CCClient::onResponse(char* data, size_t size, size_t nmemb, std::string* res
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#ifndef __CC_CLIENT_H__
|
#ifndef __CC_CLIENT_H__
|
||||||
#define __CC_CLIENT_H__
|
#define __CC_CLIENT_H__
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_CC
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
@ -68,4 +69,5 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif /* __CC_CLIENT_H__ */
|
#endif /* __CC_CLIENT_H__ */
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#define __CONTROL_COMMAND_H__
|
#define __CONTROL_COMMAND_H__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
class ControlCommand
|
class ControlCommand
|
||||||
|
|
|
@ -24,12 +24,19 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define WIN32_LEAN_AND_MEAN /* avoid including junk */
|
||||||
|
#include <windows.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
std::string ownPath(argv[0]);
|
std::string ownPath(argv[0]);
|
||||||
std::string xmrigMinerPath = std::regex_replace(ownPath, std::regex(program_invocation_short_name), "xmrigMiner");
|
std::string xmrigDaemon("xmrigDaemon");
|
||||||
|
std::string xmrigMiner("xmrigMiner");
|
||||||
|
|
||||||
|
std::string xmrigMinerPath = ownPath.replace(ownPath.rfind(xmrigDaemon),xmrigDaemon.size(), xmrigMiner);
|
||||||
|
|
||||||
for (int i=1; i < argc; i++){
|
for (int i=1; i < argc; i++){
|
||||||
xmrigMinerPath += " ";
|
xmrigMinerPath += " ";
|
||||||
|
@ -40,7 +47,9 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
do {
|
//do {
|
||||||
status = system(xmrigMinerPath.c_str());
|
status = system(xmrigMinerPath.c_str());
|
||||||
} while (WEXITSTATUS(status) == ERESTART);
|
|
||||||
|
printf("Status: %d", status);
|
||||||
|
//} while (WEXITSTATUS(status) == EINTR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue