diff --git a/CMakeLists.txt b/CMakeLists.txt index f1e0be69..3a71e57e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ include(CheckCXXCompilerFlag) include(CheckLinkerFlag) include(CheckLibraryExists) include(CheckFunctionExists) - if (IOS) INCLUDE(CmakeLists_IOS.txt) endif() @@ -886,4 +885,9 @@ endif() option(BUILD_GUI_DEPS "Build GUI dependencies." OFF) CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11) +# Define the two required variables before including +# the source code for watching a git repository. +set(PRE_CONFIGURE_FILE "${CMAKE_SOURCE_DIR}/src/git_version.h.in") +set(POST_CONFIGURE_FILE "${CMAKE_SOURCE_DIR}/src/version.h") +include(cmake/git-watcher.cmake) diff --git a/Makefile b/Makefile index a903d9fa..fb875539 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ debug-test: debug-all: mkdir -p build/debug - cd build/debug && cmake -D BUILD_TESTS=OFF -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Debug ../.. && $(MAKE) + cd build/debug && cmake -D BUILD_TESTS=OFF -D STATIC=OFF -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Debug ../.. && $(MAKE) debug-static-all: mkdir -p build/debug @@ -94,6 +94,10 @@ release-static-linux-x86_64: mkdir -p build/release cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-x64" ../.. && $(MAKE) +release-static-archlinux-x86_64: + mkdir -p build/release + cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -DBUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="archlinux-x64" -DCMAKE_CXX_COMPILER=/usr/bin/g++-8 -DCMAKE_C_COMPILER=/usr/bin/gcc-8 ../.. && $(MAKE) + release-static-freebsd-x86_64: mkdir -p build/release cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="freebsd-x64" ../.. && $(MAKE) diff --git a/cmake/GenVersion.cmake b/cmake/GenVersion.cmake deleted file mode 100644 index 28911517..00000000 --- a/cmake/GenVersion.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2014-2018, The Monero Project -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -# Check what commit we're on -execute_process(COMMAND "${GIT}" rev-parse --short HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(RET) - # Something went wrong, set the version tag to -unknown - - message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.") - set(VERSIONTAG "unknown") - configure_file("src/version.cpp.in" "${TO}") -else() - message(STATUS "You are currently on commit ${COMMIT}") - - # Get all the tags - execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) - - if(NOT TAGGEDCOMMIT) - message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.") - set(VERSIONTAG "${COMMIT}") - else() - message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}") - - # Check if we're building that tagged commit or a different one - if(COMMIT STREQUAL TAGGEDCOMMIT) - message(STATUS "You are building a tagged release") - set(VERSIONTAG "release") - else() - message(STATUS "You are ahead of or behind a tagged release") - set(VERSIONTAG "${COMMIT}") - endif() - endif() - - configure_file("src/version.cpp.in" "${TO}") -endif() diff --git a/cmake/Version.cmake b/cmake/Version.cmake deleted file mode 100644 index 439c4c5a..00000000 --- a/cmake/Version.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2014-2018, The Monero Project -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -function (write_static_version_header hash) - set(VERSIONTAG "${hash}") - configure_file("src/version.cpp.in" "version.cpp") -endfunction () - -find_package(Git QUIET) -if ("$Format:$" STREQUAL "") - # We're in a tarball; use hard-coded variables. - write_static_version_header("release") -elseif (GIT_FOUND OR Git_FOUND) - message(STATUS "Found Git: ${GIT_EXECUTABLE}") - add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/version.cpp" - COMMAND "${CMAKE_COMMAND}" - "-D" "GIT=${GIT_EXECUTABLE}" - "-D" "TO=${CMAKE_BINARY_DIR}/version.cpp" - "-P" "cmake/GenVersion.cmake" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") -else() - message(STATUS "WARNING: Git was not found!") - write_static_version_header("unknown") -endif () -add_custom_target(genversion ALL - DEPENDS "${CMAKE_BINARY_DIR}/version.cpp") diff --git a/cmake/git-watcher.cmake b/cmake/git-watcher.cmake new file mode 100644 index 00000000..9fff0314 --- /dev/null +++ b/cmake/git-watcher.cmake @@ -0,0 +1,211 @@ +# git_watcher.cmake +# +# License: MIT +# Source: https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/git_watcher.cmake + + +# This file defines the functions and targets needed to monitor +# the state of a git repo. If the state changes (e.g. a commit is made), +# then a file gets reconfigured. +# +# The behavior of this script can be modified by defining any of these variables: +# +# PRE_CONFIGURE_FILE (REQUIRED) +# -- The path to the file that'll be configured. +# +# POST_CONFIGURE_FILE (REQUIRED) +# -- The path to the configured PRE_CONFIGURE_FILE. +# +# GIT_STATE_FILE (OPTIONAL) +# -- The path to the file used to store the previous build's git state. +# Defaults to the current binary directory. +# +# GIT_WORKING_DIR (OPTIONAL) +# -- The directory from which git commands will be run. +# Defaults to the directory with the top level CMakeLists.txt. +# +# GIT_EXECUTABLE (OPTIONAL) +# -- The path to the git executable. It'll automatically be set if the +# user doesn't supply a path. +# +# Script design: +# - This script was designed similar to a Python application +# with a Main() function. I wanted to keep it compact to +# simplify "copy + paste" usage. +# +# - This script is made to operate in two CMake contexts: +# 1. Configure time context (when build files are created). +# 2. Build time context (called via CMake -P) +# If you see something odd (e.g. the NOT DEFINED clauses), +# consider that it can run in one of two contexts. + +# Short hand for converting paths to absolute. +macro(PATH_TO_ABSOLUTE var_name) + get_filename_component(${var_name} "${${var_name}}" ABSOLUTE) +endmacro() + +# Check that a required variable is set. +macro(CHECK_REQUIRED_VARIABLE var_name) + if(NOT DEFINED ${var_name}) + message(FATAL_ERROR "The \"${var_name}\" variable must be defined.") + endif() + PATH_TO_ABSOLUTE(${var_name}) +endmacro() + +# Check that an optional variable is set, or, set it to a default value. +macro(CHECK_OPTIONAL_VARIABLE var_name default_value) + if(NOT DEFINED ${var_name}) + set(${var_name} ${default_value}) + endif() + PATH_TO_ABSOLUTE(${var_name}) +endmacro() + +CHECK_REQUIRED_VARIABLE(PRE_CONFIGURE_FILE) +CHECK_REQUIRED_VARIABLE(POST_CONFIGURE_FILE) +CHECK_OPTIONAL_VARIABLE(GIT_STATE_FILE "${CMAKE_BINARY_DIR}/git-state") +CHECK_OPTIONAL_VARIABLE(GIT_WORKING_DIR "${CMAKE_SOURCE_DIR}") + +# Check the optional git variable. +# If it's not set, we'll try to find it using the CMake packaging system. +if(NOT DEFINED GIT_EXECUTABLE) + find_package(Git QUIET REQUIRED) +endif() +CHECK_REQUIRED_VARIABLE(GIT_EXECUTABLE) + + + +# Function: GitStateChangedAction +# Description: this function is executed when the state of the git +# repo changes (e.g. a commit is made). +function(GitStateChangedAction _state_as_list) + # Set variables by index, then configure the file w/ these variables defined. + LIST(GET _state_as_list 0 GIT_RETRIEVED_STATE) + LIST(GET _state_as_list 1 GIT_HEAD_SHA1) + LIST(GET _state_as_list 2 GIT_IS_DIRTY) + configure_file("${PRE_CONFIGURE_FILE}" "${POST_CONFIGURE_FILE}" @ONLY) +endfunction() + + + +# Function: GetGitState +# Description: gets the current state of the git repo. +# Args: +# _working_dir (in) string; the directory from which git commands will be executed. +# _state (out) list; a collection of variables representing the state of the +# repository (e.g. commit SHA). +function(GetGitState _working_dir _state) + + # Get the hash for HEAD. + set(_success "true") + execute_process(COMMAND + "${GIT_EXECUTABLE}" rev-parse --verify HEAD + WORKING_DIRECTORY "${_working_dir}" + RESULT_VARIABLE res + OUTPUT_VARIABLE _hashvar + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(_success "false") + set(_hashvar "GIT-NOTFOUND") + endif() + + # Get whether or not the working tree is dirty. + execute_process(COMMAND + "${GIT_EXECUTABLE}" status --porcelain + WORKING_DIRECTORY "${_working_dir}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(_success "false") + set(_dirty "false") + else() + if(NOT "${out}" STREQUAL "") + set(_dirty "true") + else() + set(_dirty "false") + endif() + endif() + + # Return a list of our variables to the parent scope. + set(${_state} ${_success} ${_hashvar} ${_dirty} PARENT_SCOPE) +endfunction() + + + +# Function: CheckGit +# Description: check if the git repo has changed. If so, update the state file. +# Args: +# _working_dir (in) string; the directory from which git commands will be ran. +# _state_changed (out) bool; whether or no the state of the repo has changed. +# _state (out) list; the repository state as a list (e.g. commit SHA). +function(CheckGit _working_dir _state_changed _state) + + # Get the current state of the repo. + GetGitState("${_working_dir}" state) + + # Set the output _state variable. + # (Passing by reference in CMake is awkward...) + set(${_state} ${state} PARENT_SCOPE) + + # Check if the state has changed compared to the backup on disk. + if(EXISTS "${GIT_STATE_FILE}") + file(READ "${GIT_STATE_FILE}" OLD_HEAD_CONTENTS) + if(OLD_HEAD_CONTENTS STREQUAL "${state}") + # State didn't change. + set(${_state_changed} "false" PARENT_SCOPE) + return() + endif() + endif() + + # The state has changed. + # We need to update the state file on disk. + # Future builds will compare their state to this file. + file(WRITE "${GIT_STATE_FILE}" "${state}") + set(${_state_changed} "true" PARENT_SCOPE) +endfunction() + + + +# Function: SetupGitMonitoring +# Description: this function sets up custom commands that make the build system +# check the state of git before every build. If the state has +# changed, then a file is configured. +function(SetupGitMonitoring) + add_custom_target(check_git_repository + ALL + DEPENDS ${PRE_CONFIGURE_FILE} + BYPRODUCTS ${POST_CONFIGURE_FILE} + COMMENT "Checking the git repository for changes..." + COMMAND + ${CMAKE_COMMAND} + -D_BUILD_TIME_CHECK_GIT=TRUE + -DGIT_WORKING_DIR=${GIT_WORKING_DIR} + -DGIT_EXECUTABLE=${GIT_EXECUTABLE} + -DGIT_STATE_FILE=${GIT_STATE_FILE} + -DPRE_CONFIGURE_FILE=${PRE_CONFIGURE_FILE} + -DPOST_CONFIGURE_FILE=${POST_CONFIGURE_FILE} + -P "${CMAKE_CURRENT_LIST_FILE}") +endfunction() + + + +# Function: Main +# Description: primary entry-point to the script. Functions are selected based +# on whether it's configure or build time. +function(Main) + if(_BUILD_TIME_CHECK_GIT) + # Check if the repo has changed. + # If so, run the change action. + CheckGit("${GIT_WORKING_DIR}" did_change state) + if(did_change) + GitStateChangedAction("${state}") + endif() + else() + # >> Executes at configure time. + SetupGitMonitoring() + endif() +endfunction() + +main() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8318eee..f31ae5a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,6 +59,7 @@ function (monero_add_executable name) add_executable("${name}" ${ARGN}) + add_dependencies("${name}" check_git_repository) target_link_libraries("${name}" PRIVATE ${EXTRA_LIBRARIES}) @@ -93,16 +94,15 @@ function (monero_add_library_with_deps) PRIVATE $) endfunction () -include(Version) -monero_add_library(version SOURCES ${CMAKE_BINARY_DIR}/version.cpp DEPENDS genversion) - add_subdirectory(common) add_subdirectory(crypto) add_subdirectory(ringct) add_subdirectory(checkpoints) add_subdirectory(cryptonote_basic) add_subdirectory(cryptonote_core) +add_subdirectory(cryptonote_protocol) add_subdirectory(multisig) +add_subdirectory(p2p) if(NOT IOS) add_subdirectory(blockchain_db) endif() @@ -112,10 +112,6 @@ if(NOT IOS) add_subdirectory(serialization) endif() add_subdirectory(wallet) -if(NOT IOS) - add_subdirectory(p2p) -endif() -add_subdirectory(cryptonote_protocol) if(NOT IOS) add_subdirectory(simplewallet) add_subdirectory(gen_multisig) diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index d32f5211..20266ab4 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -102,7 +102,6 @@ target_link_libraries(blockchain_import cryptonote_core blockchain_db p2p - version epee ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -129,7 +128,6 @@ target_link_libraries(blockchain_export cryptonote_core blockchain_db p2p - version epee ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -152,7 +150,6 @@ target_link_libraries(blockchain_blackball cryptonote_core blockchain_db p2p - version epee ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -175,7 +172,6 @@ target_link_libraries(blockchain_usage cryptonote_core blockchain_db p2p - version epee ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index b1c9cac3..5d85d0ba 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -45,6 +45,7 @@ #include "include_base_utils.h" #include "blockchain_db/db_types.h" #include "cryptonote_core/cryptonote_core.h" +#include "version.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "bcutil" diff --git a/src/blockchain_utilities/blockchain_utilities.h b/src/blockchain_utilities/blockchain_utilities.h index e690305c..03fe9f5d 100644 --- a/src/blockchain_utilities/blockchain_utilities.h +++ b/src/blockchain_utilities/blockchain_utilities.h @@ -28,8 +28,6 @@ #pragma once -#include "version.h" - // bounds checking is done before writing to buffer, but buffer size // should be a sensible maximum diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h index 187db093..a34f0cb7 100644 --- a/src/blockchain_utilities/bootstrap_file.h +++ b/src/blockchain_utilities/bootstrap_file.h @@ -45,7 +45,6 @@ #include #include "common/command_line.h" -#include "version.h" #include "blockchain_utilities.h" diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt index 72844db6..d16bb5b1 100644 --- a/src/cryptonote_core/CMakeLists.txt +++ b/src/cryptonote_core/CMakeLists.txt @@ -55,7 +55,6 @@ monero_add_library(cryptonote_core ${cryptonote_core_private_headers}) target_link_libraries(cryptonote_core PUBLIC - version common cncrypto blockchain_db diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 29716cae..5fb62749 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -52,7 +52,6 @@ using namespace epee; #include "ringct/rctTypes.h" #include "blockchain_db/blockchain_db.h" #include "ringct/rctSigs.h" -#include "version.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "cn" diff --git a/src/cryptonote_protocol/CMakeLists.txt b/src/cryptonote_protocol/CMakeLists.txt index 1189ccf2..27822537 100644 --- a/src/cryptonote_protocol/CMakeLists.txt +++ b/src/cryptonote_protocol/CMakeLists.txt @@ -26,16 +26,35 @@ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -cmake_minimum_required (VERSION 2.6) -project (monero CXX) +set(cryptonote_protocol_sources + block_queue.cpp + cryptonote_protocol_handler-base.cpp) -file(GLOB CRYPTONOTE_PROTOCOL *) -source_group(cryptonote_protocol FILES ${CRYPTONOTE_PROTOCOL}) +set(cryptonote_protocol_headers) -#monero_private_headers(cryptonote_protocol ${CRYPTONOTE_PROTOCOL}) -monero_add_library(cryptonote_protocol ${CRYPTONOTE_PROTOCOL}) +set(cryptonote_protocol_private_headers + block_queue.h + cryptonote_protocol_defs.h + cryptonote_protocol_handler.inl + cryptonote_protocol_handler.h + cryptonote_protocol_handler_common.h) + +monero_private_headers(cryptonote_protocol + ${cryptonote_protocol_private_headers}) +monero_add_library(cryptonote_protocol + ${cryptonote_protocol_sources} + ${cryptonote_protocol_headers} + ${cryptonote_protocol_private_headers}) target_link_libraries(cryptonote_protocol PUBLIC p2p + ${Boost_DATE_TIME_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_SERIALIZATION_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} PRIVATE + ${Blocks} ${EXTRA_LIBRARIES}) + diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 7687eebf..1b687dcf 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -1029,11 +1029,9 @@ namespace cryptonote bool parent_requested = m_block_queue.requested(new_block.prev_id); if (!parent_requested) { - std::ostringstream new_block_hash(NULL); + std::ostringstream new_block_hash(0); epee::to_hex::formatted(new_block_hash, epee::as_byte_span(get_block_hash(new_block))); MERROR("Got block " << new_block_hash.str() << " with unknown parent " << new_block.prev_id << " which was not requested - querying block hashes"); - context.m_needed_objects.clear(); - context.m_last_response_height = 0; } // parent was requested, so we wait for it to be retrieved diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index d213f444..317d7f06 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -83,6 +83,7 @@ monero_add_executable(daemon ${daemon_private_headers} ${blocksdat} ${BACKWARD_ENABLE}) +add_dependencies(daemon check_git_repository) add_backward(daemon) @@ -100,7 +101,6 @@ target_link_libraries(daemon daemon_rpc_server epee ${EPEE_READLINE} - version ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} @@ -133,7 +133,6 @@ target_link_libraries(daemon daemon_rpc_server epee ${EPEE_READLINE} - version ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 5e7ff00c..df804a12 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -313,7 +313,7 @@ bool t_command_server::help(const std::vector& args) std::string t_command_server::get_commands_str() { std::stringstream ss; - ss << "BLUR '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << std::endl; + ss << "BLUR '" << cryptonote::MONERO_RELEASE_NAME << "' (v" << cryptonote::MONERO_VERSION_FULL << ")" << std::endl; ss << "Commands: " << std::endl; std::string usage = m_command_lookup.get_usage(); boost::replace_all(usage, "\n", "\n "); diff --git a/src/daemon/executor.cpp b/src/daemon/executor.cpp index 047c3508..267f8f3a 100644 --- a/src/daemon/executor.cpp +++ b/src/daemon/executor.cpp @@ -41,8 +41,6 @@ namespace daemonize { - std::string const t_executor::NAME = "Blur Network Daemon"; - void t_executor::init_options( boost::program_options::options_description & configurable_options ) @@ -50,16 +48,17 @@ namespace daemonize t_daemon::init_options(configurable_options); } - std::string const & t_executor::name() + std::string const t_executor::name() { - return NAME; + std::string const ret = "Blur Network Daemon"; + return ret; } t_daemon t_executor::create_daemon( boost::program_options::variables_map const & vm ) { - LOG_PRINT_L0("Blur Network '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ") Daemonised"); + LOG_PRINT_L0("Blur Network '" << cryptonote::MONERO_RELEASE_NAME << "' (v" << cryptonote::MONERO_VERSION_FULL << ") Daemonised"); return t_daemon{vm}; } diff --git a/src/daemon/executor.h b/src/daemon/executor.h index 79d70567..5b689558 100644 --- a/src/daemon/executor.h +++ b/src/daemon/executor.h @@ -43,13 +43,11 @@ namespace daemonize public: typedef ::daemonize::t_daemon t_daemon; - static std::string const NAME; - static void init_options( boost::program_options::options_description & configurable_options ); - std::string const & name(); + std::string const name(); t_daemon create_daemon( boost::program_options::variables_map const & vm diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 6816a0e9..db12e179 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) if (command_line::get_arg(vm, command_line::arg_help)) { - std::cout << "Blur Network '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL; + std::cout << "Blur Network '" << cryptonote::MONERO_RELEASE_NAME << "' (v" << cryptonote::MONERO_VERSION_FULL << ")" << ENDL << ENDL; std::cout << "Usage: " + std::string{argv[0]} + " [options|settings] [daemon_command...]" << std::endl << std::endl; std::cout << visible_options << std::endl; return 0; @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) // Monero Version if (command_line::get_arg(vm, command_line::arg_version)) { - std::cout << "Blur Network '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL; + std::cout << "Blur Network '" << cryptonote::MONERO_RELEASE_NAME << "' (v" << cryptonote::MONERO_VERSION_FULL << ")" << ENDL; return 0; } @@ -282,7 +282,7 @@ int main(int argc, char* argv[]) } // logging is now set up - MGINFO("Blur Network '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"); + MGINFO("Blur Network '" << cryptonote::MONERO_RELEASE_NAME << "' (v" << cryptonote::MONERO_VERSION_FULL << ")"); MINFO("Moving from main() into the daemonize now."); diff --git a/src/gen_multisig/CMakeLists.txt b/src/gen_multisig/CMakeLists.txt index d274fdc2..cbeb890a 100644 --- a/src/gen_multisig/CMakeLists.txt +++ b/src/gen_multisig/CMakeLists.txt @@ -46,8 +46,6 @@ target_link_libraries(gen_multisig ${CMAKE_THREAD_LIBS_INIT} ${GNU_READLINE_LIBRARY} ${EXTRA_LIBRARIES}) -add_dependencies(gen_multisig - version) set_property(TARGET gen_multisig PROPERTY OUTPUT_NAME "blur-gen-trusted-multisig") diff --git a/src/git_version.h.in b/src/git_version.h.in new file mode 100644 index 00000000..f5ea9ac3 --- /dev/null +++ b/src/git_version.h.in @@ -0,0 +1,18 @@ +#pragma once + +#define GIT_RETRIEVED_STATE @GIT_RETRIEVED_STATE@ +#define GIT_HEAD_SHA1 "@GIT_HEAD_SHA1@" +#define GIT_IS_DIRTY @GIT_IS_DIRTY@ + +#define DEF_MONERO_VERSION "0.1.9.9.2" +#define DEF_MONERO_RELEASE_NAME "Radiance" +#define DEF_MONERO_VERSION_FULL(s,y) DEF_MONERO_VERSION#s#y + +namespace cryptonote { + +static char const* MONERO_VERSION_TAG = MONERO_VERSION_TAG; +static char const* MONERO_VERSION = DEF_MONERO_VERSION; +static char const* MONERO_RELEASE_NAME = DEF_MONERO_RELEASE_NAME; +static char const* MONERO_VERSION_FULL = DEF_MONERO_VERSION_FULL(-,@GIT_HEAD_SHA1@); + +} diff --git a/src/p2p/CMakeLists.txt b/src/p2p/CMakeLists.txt index 83bdffab..6a0433a4 100644 --- a/src/p2p/CMakeLists.txt +++ b/src/p2p/CMakeLists.txt @@ -26,20 +26,30 @@ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -cmake_minimum_required (VERSION 2.6) -project (monero CXX) +set(p2p_sources + net_node.cpp) -file(GLOB P2P *) -source_group(p2p FILES ${P2P}) +set(p2p_headers) -#add_library(p2p ${P2P}) +set(p2p_private_headers + net_node.inl + net_node.h + net_node_common.h + net_peerlist.h + net_peerlist_boost_serialization.h + p2p_protocol_defs.h + stdafx.h) + +monero_private_headers(cryptonote_core + ${cryptonote_core_private_headers}) +monero_add_library(p2p + ${p2p_sources} + ${p2p_headers} + ${p2p_private_headers}) -#monero_private_headers(p2p ${P2P}) -monero_add_library(p2p ${P2P}) target_link_libraries(p2p PUBLIC epee - version cryptonote_core ${UPNP_LIBRARIES} ${Boost_CHRONO_LIBRARY} diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 9d967a2a..7e5dff1a 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -37,7 +37,6 @@ #include #include -#include "version.h" #include "string_tools.h" #include "common/util.h" #include "net/net_helper.h" diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 4806846e..86dc5c33 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -37,7 +37,6 @@ #include "string_tools.h" #include "time_helper.h" #include "cryptonote_config.h" -#include "version.h" namespace nodetool { diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index d82d13a7..e77a2e07 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -48,7 +48,6 @@ using namespace epee; #include "rpc/rpc_args.h" #include "core_rpc_server_error_codes.h" #include "p2p/net_node.h" -#include "version.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "daemon.rpc" @@ -206,7 +205,6 @@ namespace cryptonote boost::shared_lock lock(m_bootstrap_daemon_mutex); res.was_bootstrap_ever_used = m_was_bootstrap_ever_used; } - res.version = MONERO_VERSION; return true; } //----------------------------------------------------------------------------------------------------------------- @@ -1786,7 +1784,6 @@ namespace cryptonote boost::shared_lock lock(m_bootstrap_daemon_mutex); res.was_bootstrap_ever_used = m_was_bootstrap_ever_used; } - res.version = MONERO_VERSION; return true; } //------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/serialization/CMakeLists.txt b/src/serialization/CMakeLists.txt index 5a6bebf0..03c40f34 100644 --- a/src/serialization/CMakeLists.txt +++ b/src/serialization/CMakeLists.txt @@ -49,6 +49,4 @@ target_link_libraries(serialization ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${EXTRA_LIBRARIES}) -add_dependencies(serialization - version) diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt index e3f78743..504ed4eb 100644 --- a/src/simplewallet/CMakeLists.txt +++ b/src/simplewallet/CMakeLists.txt @@ -50,7 +50,6 @@ target_link_libraries(simplewallet common mnemonics ${EPEE_READLINE} - version ${Boost_CHRONO_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index d60c84d2..6aea02fe 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -63,7 +63,7 @@ #include "multisig/multisig.h" #include "wallet/wallet_args.h" #include - +#include "version.h" #ifdef WIN32 #include #include @@ -1889,6 +1889,7 @@ bool simple_wallet::help(const std::vector &args/* = std::vector) # matches naming convention in src/CMakeLists.txt diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp index 592591c3..f3087d89 100644 --- a/src/wallet/wallet_args.cpp +++ b/src/wallet/wallet_args.cpp @@ -35,7 +35,6 @@ #include "common/util.h" #include "misc_log_ex.h" #include "string_tools.h" -#include "version.h" #if defined(WIN32) #include @@ -135,7 +134,6 @@ namespace wallet_args if (command_line::get_arg(vm, command_line::arg_help)) { - Print(print) << "BLUR '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL; Print(print) << wallet_args::tr("This is the command line blur wallet. It needs to connect to a blur\n" "daemon to work correctly.") << ENDL; Print(print) << wallet_args::tr("Usage:") << ENDL << " " << usage; @@ -144,7 +142,6 @@ namespace wallet_args } else if (command_line::get_arg(vm, command_line::arg_version)) { - Print(print) << "BLUR '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; return false; } @@ -187,8 +184,6 @@ namespace wallet_args if (!command_line::is_arg_defaulted(vm, arg_max_concurrency)) tools::set_max_concurrency(command_line::get_arg(vm, arg_max_concurrency)); - Print(print) << "BLUR '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; - if (!command_line::is_arg_defaulted(vm, arg_log_level)) MINFO("Setting log level = " << command_line::get_arg(vm, arg_log_level)); else diff --git a/tests/core_proxy/CMakeLists.txt b/tests/core_proxy/CMakeLists.txt index 105c20d2..6add5214 100644 --- a/tests/core_proxy/CMakeLists.txt +++ b/tests/core_proxy/CMakeLists.txt @@ -40,7 +40,6 @@ target_link_libraries(core_proxy cryptonote_core cryptonote_protocol p2p - version epee ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBRARIES}) diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt index c8ee7d9d..98a36805 100644 --- a/tests/core_tests/CMakeLists.txt +++ b/tests/core_tests/CMakeLists.txt @@ -68,7 +68,6 @@ target_link_libraries(core_tests multisig cryptonote_core p2p - version epee device ${CMAKE_THREAD_LIBS_INIT} diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index e2d9a183..9886eb2b 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -60,7 +60,7 @@ set(unit_tests_sources test_tx_utils.cpp test_peerlist.cpp test_protocol_pack.cpp - hardfork.cpp +# hardfork.cpp varint.cpp ringct.cpp output_selection.cpp @@ -81,7 +81,6 @@ target_link_libraries(unit_tests rpc wallet p2p - version epee ${Boost_CHRONO_LIBRARY} ${Boost_THREAD_LIBRARY} diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index 72d8f320..10e62c16 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -294,7 +294,7 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_initial TEST_F(positive_test_connection_to_levin_protocol_handler_calls, concurent_handler_initialization_and_destruction_is_correct) { const size_t connection_count = 10000; - auto create_and_destroy_connections = [this, connection_count]() + auto create_and_destroy_connections = [this]() { std::vector connections(connection_count); for (size_t i = 0; i < connection_count; ++i)