From b31adbd5ae27063b625032faef4b96c65c22e305 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 5 Sep 2021 11:50:56 +0200 Subject: [PATCH] Added macOS build --- .github/workflows/c-cpp.yml | 33 +++++++++++++++++++++++++++++++++ cmake/flags.cmake | 2 +- src/block_template.cpp | 4 ++-- src/crypto.cpp | 2 -- src/log.h | 1 + src/p2p_server.cpp | 10 +++++----- src/p2pool.cpp | 4 ++-- src/stratum_server.cpp | 2 +- src/wallet.cpp | 2 -- src/zmq_reader.cpp | 3 +-- src/zmq_reader.h | 3 +-- tests/CMakeLists.txt | 7 +++++++ 12 files changed, 54 insertions(+), 19 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3212a65..edbd259 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -110,3 +110,36 @@ jobs: run: | cd tests/build/Release ./p2pool_tests.exe + + build-macos: + + runs-on: macOS-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install dependencies + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake libuv zmq libpgm + + - name: Build p2pool + run: | + mkdir build + cd build + cmake .. + make + + - name: Build tests + run: | + cd tests + mkdir build + cd build + cmake .. + make + + - name: Run tests + run: | + cd tests/build + ./p2pool_tests diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 08f9999..fe1496e 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -39,7 +39,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${WARNING_FLAGS} ${SECURITY_FLAGS} /Ob1 /Ot /Zi /MT") elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) - set(WARNING_FLAGS "-Wall -Wextra") + set(WARNING_FLAGS "-Wall -Wextra -Wno-undefined-internal -Werror") set(OPTIMIZATION_FLAGS "-Ofast -funroll-loops -fmerge-all-constants") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") diff --git a/src/block_template.cpp b/src/block_template.cpp index 66b2ccc..9cdb2bf 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -204,7 +204,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet // Select 1000 transactions with the highest fee per byte if (m_mempoolTxs.size() > 1000) { std::nth_element(m_mempoolTxs.begin(), m_mempoolTxs.begin() + 1000, m_mempoolTxs.end(), - [this](const TxMempoolData& tx_a, const TxMempoolData& tx_b) + [](const TxMempoolData& tx_a, const TxMempoolData& tx_b) { return tx_a.fee * tx_b.weight > tx_b.fee * tx_a.weight; }); @@ -749,7 +749,7 @@ hash BlockTemplate::calc_miner_tx_hash(uint32_t extra_nonce) const // 1. Prefix (everything except vin_rct_type byte in the end) // Apply extra_nonce in-place because we can't write to the block template here - keccak_custom([this, data, extra_nonce_offset, &extra_nonce_buf](int offset) + keccak_custom([data, extra_nonce_offset, &extra_nonce_buf](int offset) { const uint32_t k = static_cast(offset - extra_nonce_offset); if (k < EXTRA_NONCE_SIZE) { diff --git a/src/crypto.cpp b/src/crypto.cpp index d4b7e54..88938b9 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -25,8 +25,6 @@ extern "C" { #include "crypto-ops.h" } -static constexpr char log_category_prefix[] = "Crypto "; - namespace p2pool { namespace { diff --git a/src/log.h b/src/log.h index 2a41c5c..e00614d 100644 --- a/src/log.h +++ b/src/log.h @@ -172,6 +172,7 @@ INT_ENTRY(uint32_t) INT_ENTRY(uint64_t) #ifdef __clang__ +INT_ENTRY(long) INT_ENTRY(unsigned long) #endif diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 7173829..60be525 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -667,7 +667,7 @@ void P2PServer::download_missing_blocks() } send(client, - [this, &id](void* buf) + [&id](void* buf) { uint8_t* p0 = reinterpret_cast(buf); uint8_t* p = p0; @@ -1093,7 +1093,7 @@ bool P2PServer::P2PClient::check_handshake_solution(const hash& solution, const hash check{}; keccak_custom( - [this, &challenge, &solution_salt, &consensus_id, consensus_id_size](int offset) -> uint8_t + [&challenge, &solution_salt, &consensus_id, consensus_id_size](int offset) -> uint8_t { if (offset < CHALLENGE_SIZE) { return challenge[offset]; @@ -1185,7 +1185,7 @@ bool P2PServer::P2PClient::on_handshake_solution(const uint8_t* buf) } return m_owner->send(this, - [this, &solution, &solution_salt](void* buf) + [this](void* buf) { uint8_t* p0 = reinterpret_cast(buf); uint8_t* p = p0; @@ -1243,7 +1243,7 @@ bool P2PServer::P2PClient::on_block_request(const uint8_t* buf) } return server->send(this, - [this, &blob](void* buf) + [&blob](void* buf) { uint8_t* p0 = reinterpret_cast(buf); uint8_t* p = p0; @@ -1526,7 +1526,7 @@ void P2PServer::P2PClient::post_handle_incoming_block(const uint32_t reset_count } const bool result = m_owner->send(this, - [this, &id](void* buf) + [&id](void* buf) { uint8_t* p0 = reinterpret_cast(buf); uint8_t* p = p0; diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 75f96f4..04ff054 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -810,7 +810,7 @@ void p2pool::api_update_network_stats() } m_api->set(p2pool_api::Category::NETWORK, "stats", - [this, mainnet_tip](log::Stream& s) + [mainnet_tip](log::Stream& s) { s << "{\"difficulty\":" << mainnet_tip.difficulty << ",\"hash\":\"" << mainnet_tip.id @@ -1000,7 +1000,7 @@ int p2pool::run() } { - ZMQReader z(m_params->m_host, m_params->m_rpcPort, m_params->m_zmqPort, this); + ZMQReader z(m_params->m_host, m_params->m_zmqPort, this); get_info(); const int rc = uv_run(uv_default_loop_checked(), UV_RUN_DEFAULT); LOGINFO(1, "uv_run exited, result = " << rc); diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 30a6eb7..27084b9 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -493,7 +493,7 @@ void StratumServer::on_blobs_ready() } const bool result = send(client, - [data, target, client, hashing_blob, &job_id](void* buf) + [data, target, hashing_blob, &job_id](void* buf) { log::hex_buf target_hex(reinterpret_cast(&target), sizeof(uint64_t)); diff --git a/src/wallet.cpp b/src/wallet.cpp index 65319d4..e31c45d 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -28,8 +28,6 @@ extern "C" { #include "crypto-ops.h" } -static constexpr char log_category_prefix[] = "Wallet "; - namespace { // public keys: 64 bytes -> 88 characters in base58 diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index 7a90496..220e7db 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -24,9 +24,8 @@ static constexpr char log_category_prefix[] = "ZMQReader "; namespace p2pool { -ZMQReader::ZMQReader(const char* address, uint32_t rpc_port, uint32_t zmq_port, MinerCallbackHandler* handler) +ZMQReader::ZMQReader(const char* address, uint32_t zmq_port, MinerCallbackHandler* handler) : m_address(address) - , m_rpcPort(rpc_port) , m_zmqPort(zmq_port) , m_handler(handler) , m_tx() diff --git a/src/zmq_reader.h b/src/zmq_reader.h index 33d1a2b..e690e18 100644 --- a/src/zmq_reader.h +++ b/src/zmq_reader.h @@ -24,7 +24,7 @@ namespace p2pool { class ZMQReader { public: - ZMQReader(const char* address, uint32_t rpc_port, uint32_t zmq_port, MinerCallbackHandler* handler); + ZMQReader(const char* address, uint32_t zmq_port, MinerCallbackHandler* handler); ~ZMQReader(); private: @@ -34,7 +34,6 @@ private: void parse(char* data, size_t size); const char* m_address; - uint32_t m_rpcPort; uint32_t m_zmqPort; MinerCallbackHandler* m_handler; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1d83cf5..61c59f7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,13 @@ cmake_minimum_required(VERSION 2.8.12) project(p2pool_tests) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 14) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + add_subdirectory(googletest) set(LIBS gtest)