diff --git a/CMakeLists.txt b/CMakeLists.txt index 1274994d4..c3913777f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ message(STATUS "CMake version ${CMAKE_VERSION}") set(VERSION "11.1.0") project(wownero VERSION ${VERSION}) enable_language(C ASM) +include(functions) set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_C_STANDARD 11) @@ -44,10 +45,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -ftemplate-depth=900") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=900") +set_arch_id() option(STATIC "Link libraries statically" off) option(ARM "ARM build" OFF) @@ -62,9 +61,11 @@ if(STATIC) set(MINIUPNPC_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) + set(Boost_DEBUG ON) set(sodium_USE_STATIC_LIBS ON) set(OPENSSL_USE_STATIC_LIBS ON) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -static") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif() @@ -72,16 +73,15 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) set(USE_LTO_DEFAULT false) set(PER_BLOCK_CHECKPOINT 1) -# @TODO: ARM -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") -option(NO_OPTIMIZED_MULTIPLY_ON_ARM "Compute multiply using generic C implementation instead of ARM ASM" OFF) +if(APPLE) + include(cmake/platform_apple_aarch64.cmake) +elseif(UNIX) + include(cmake/platform_linux.cmake) +endif() -include(FindPythonInterp) include(ExternalProject) include(FindCcache) include(FetchContent) -include(functions) # CMake build type if(NOT CMAKE_BUILD_TYPE) @@ -98,12 +98,13 @@ endif() find_package(Git) find_package(Threads) find_package(Backtrace) -find_package(PythonInterp) find_package(miniupnpc REQUIRED) find_package(ZMQ REQUIRED) find_package(Libunbound 1.12 REQUIRED) find_package(sodium REQUIRED) find_package(OpenSSL REQUIRED) +find_package(rapidjson REQUIRED) + find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options locale) include(ExternalProject) diff --git a/README.md b/README.md index 0429a63eb..ebf750708 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,25 @@ # wownero-ng -This is a version of Wownero that is easier to integrate for third-party applications. +Wownero Next Generation™℗ is a fork of Wownero that: -Support: Linux only for now +- is easier to compile (fewer dependencies) +- installs as a library with a CMake config for easy consumption -### Example +Supported platforms: + +- Linux amd64 +- MacOS aarch64 (m1/m2/m3) + +## Install + +### Dependencies + +MacOS: +``` +brew install boost zeromq openssl libpgm libsodium expat libunwind-headers protobuf libgcrypt qrencode ccache cmake pkgconfig git rapidjson +``` + +Then install, on all platforms it is: ```bash cmake -Bbuild . @@ -12,7 +27,11 @@ make -Cbuild -j12 sudo make -Cbuild install ``` -wownero-ng will be installed to `/usr/local/`, including a CMake config, which then allows: +wownero-ng will be installed to `/usr/local/`. + +## CMake hello world + +Using Wownero in your project: ```cmake cmake_minimum_required(VERSION 3.25) @@ -51,99 +70,4 @@ Add `-DSTATIC=1` to the cmake command, as well as: - `-DOPENSSL_ROOT_DIR=/usr/local/openssl` - `-DBOOST_ROOT=/usr/local` -You'll need these dependencies in the static version: - -```bash -#!/bin/bash -#run as root/sudo - -export OPENSSL_ROOT_DIR=/usr/local/openssl/ -export CFLAGS="-fPIC" -export CPPFLAGS="-fPIC" -export CXXFLAGS="-fPIC" - -# boost -wget https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.gz -tar -xzf boost_1_73_0.tar.gz -pushd boost_1_73_0 -./bootstrap.sh -./b2 --with-atomic --with-system --with-filesystem --with-thread --with-date_time --with-chrono --with-regex --with-serialization --with-program_options --with-locale variant=release link=static runtime-link=static cflags="-fPIC" cxxflags="-fPIC" install -a --prefix=/usr/local/ -popd -rm -rf boost_1_73_0 - -# openssl -wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz -tar -xvf openssl-1.1.1i.tar.gz -rm -xvf openssl-1.1.1i.tar.gz -pushd openssl-1.1.1i -./config no-shared no-dso --prefix=/usr/local/openssl -make -j8 -make install -popd -rm -rf openssl-1.1.1i - -# expat -wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 -tar -xf expat-2.4.8.tar.bz2 -rm expat-2.4.8.tar.bz2 -pushd expat-2.4.8 -./configure --enable-static --disable-shared --prefix=/usr/local/expat/ -make -j8 -make -j8 install -popd -rm -rf expat-2.4.8 - -# libunbound -wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.16.2.tar.gz -tar -xzf unbound-1.16.2.tar.gz -rm unbound-1.16.2.tar.gz -pushd unbound-1.16.2 -./configure --disable-shared --enable-static --without-pyunbound --with-libexpat=/usr/local/expat/ --with-ssl=/usr/local/openssl/ --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only --with-pic -make -j8 -make -j8 install -popd -rm -rf unbound-1.16.2 - -# zmq -git clone -b v4.3.2 --depth 1 https://github.com/zeromq/libzmq -pushd libzmq -git reset --hard a84ffa12b2eb3569ced199660bac5ad128bff1f0 -./autogen.sh -./configure --disable-shared --enable-static --disable-libunwind --with-libsodium -make -j8 -make -j8 install -popd -rm -rf libzmq - -# zlib -git clone -b v1.2.11 --depth 1 https://github.com/madler/zlib -pushd zlib -git reset --hard cacf7f1d4e3d44d871b605da3b647f07d718623f -./configure --static --prefix=/usr/local/zlib -make -j8 -make -j8 install -popd -rm -rf zlib - -# libusb -git clone -b v1.0.23 --depth 1 https://github.com/libusb/libusb -pushd libusb -git reset --hard e782eeb2514266f6738e242cdcb18e3ae1ed06fa -./autogen.sh --disable-shared --enable-static -make -j8 -make -j8 install -popd -rm -rf libusb - -# libsodium -# on ubuntu, `libsodium-dev` already comes with a static .a - -# miniupnp -git clone -b miniupnpc_2_2_1 --depth 1 https://github.com/miniupnp/miniupnp.git -pushd miniupnp/miniupnpc -git reset --hard 544e6fcc73c5ad9af48a8985c94f0f1d742ef2e0 -cmake -Bbuild -DUPNPC_BUILD_STATIC=1 -DUPNPC_BUILD_SHARED=OFF -DUPNPC_BUILD_TESTS=OFF -DUPNPC_BUILD_SAMPLE=OFF . -sudo make -Cbuild -j8 install -popd -rm -rf miniupnp -``` \ No newline at end of file +Note: you'll need these dependencies to be static too. diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake deleted file mode 100644 index ad2004afc..000000000 --- a/cmake/FindMiniupnpc.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# --------------------------------- FindMiniupnpc Start --------------------------------- -# Locate miniupnp library -# This module defines -# MINIUPNP_FOUND, if false, do not try to link to miniupnp -# MINIUPNP_LIBRARY, the miniupnp variant -# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family) -# MINIUPNPC_VERSION_1_7_OR_HIGHER, set if we detect the version of miniupnpc is 1.7 or higher -# -# Note that the expected include convention is -# #include "miniupnpc.h" -# and not -# #include -# This is because, the miniupnpc location is not standardized and may exist -# in locations other than miniupnpc/ - -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - # Already in cache, be silent - set(MINIUPNP_FIND_QUIETLY TRUE) -endif () - -find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h - HINTS $ENV{MINIUPNP_INCLUDE_DIR} - PATH_SUFFIXES miniupnpc -) - -find_library(MINIUPNP_LIBRARY miniupnpc - HINTS $ENV{MINIUPNP_LIBRARY} -) - -find_library(MINIUPNP_STATIC_LIBRARY libminiupnpc.a - HINTS $ENV{MINIUPNP_STATIC_LIBRARY} -) - -set(MINIUPNP_INCLUDE_DIRS ${MINIUPNP_INCLUDE_DIR}) -set(MINIUPNP_LIBRARIES ${MINIUPNP_LIBRARY}) -set(MINIUPNP_STATIC_LIBRARIES ${MINIUPNP_STATIC_LIBRARY}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - MiniUPnPc DEFAULT_MSG - MINIUPNP_INCLUDE_DIR - MINIUPNP_LIBRARY -) - -IF(MINIUPNPC_FOUND) - file(STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+") - if(MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)") - set(MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}") - if (${MINIUPNPC_API_VERSION} GREATER "10" OR ${MINIUPNPC_API_VERSION} EQUAL "10") - message(STATUS "Found miniupnpc API version " ${MINIUPNPC_API_VERSION}) - set(MINIUPNP_FOUND true) - set(MINIUPNPC_VERSION_1_7_OR_HIGHER true) - endif() - endif() - -ENDIF() - -mark_as_advanced(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY) -# --------------------------------- FindMiniupnpc End --------------------------------- diff --git a/cmake/Findrapidjson.cmake b/cmake/Findrapidjson.cmake new file mode 100644 index 000000000..aee8cc46f --- /dev/null +++ b/cmake/Findrapidjson.cmake @@ -0,0 +1,97 @@ +# Copyright (c) 2011 Milo Yip (miloyip@gmail.com) +# Copyright (c) 2013 Rafal Jeczalik (rjeczalik@gmail.com) +# Distributed under the MIT License (see license.txt file) + +# ----------------------------------------------------------------------------------- +# +# Finds the rapidjson library +# +# ----------------------------------------------------------------------------------- +# +# Variables used by this module, they can change the default behaviour. +# Those variables need to be either set before calling find_package +# or exported as environment variables before running CMake: +# +# RAPIDJSON_INCLUDEDIR - Set custom include path, useful when rapidjson headers are +# outside system paths +# RAPIDJSON_USE_SSE2 - Configure rapidjson to take advantage of SSE2 capabilities +# RAPIDJSON_USE_SSE42 - Configure rapidjson to take advantage of SSE4.2 capabilities +# +# ----------------------------------------------------------------------------------- +# +# Variables defined by this module: +# +# RAPIDJSON_FOUND - True if rapidjson was found +# RAPIDJSON_INCLUDE_DIRS - Path to rapidjson include directory +# RAPIDJSON_CXX_FLAGS - Extra C++ flags required for compilation with rapidjson +# +# ----------------------------------------------------------------------------------- +# +# Example usage: +# +# set(RAPIDJSON_USE_SSE2 ON) +# set(RAPIDJSON_INCLUDEDIR "/opt/github.com/rjeczalik/rapidjson/include") +# +# find_package(rapidjson REQUIRED) +# +# include_directories("${RAPIDJSON_INCLUDE_DIRS}") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}") +# add_executable(foo foo.cc) +# +# ----------------------------------------------------------------------------------- + +foreach(opt RAPIDJSON_INCLUDEDIR RAPIDJSON_USE_SSE2 RAPIDJSON_USE_SSE42) + if(${opt} AND DEFINED ENV{${opt}} AND NOT ${opt} STREQUAL "$ENV{${opt}}") + message(WARNING "Conflicting ${opt} values: ignoring environment variable and using CMake cache entry.") + elseif(DEFINED ENV{${opt}} AND NOT ${opt}) + set(${opt} "$ENV{${opt}}") + endif() +endforeach() + +find_path( + RAPIDJSON_INCLUDE_DIRS + NAMES rapidjson/rapidjson.h + PATHS ${RAPIDJSON_INCLUDEDIR} + DOC "Include directory for the rapidjson library." +) + +mark_as_advanced(RAPIDJSON_INCLUDE_DIRS) + +if(RAPIDJSON_INCLUDE_DIRS) + set(RAPIDJSON_FOUND TRUE) +endif() + +mark_as_advanced(RAPIDJSON_FOUND) + +if(RAPIDJSON_USE_SSE42) + set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE42") + if(MSVC) + set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE4.2") + else() + set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse4.2") + endif() +else() + if(RAPIDJSON_USE_SSE2) + set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE2") + if(MSVC) + set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE2") + else() + set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse2") + endif() + endif() +endif() + +mark_as_advanced(RAPIDJSON_CXX_FLAGS) + +if(RAPIDJSON_FOUND) + if(NOT rapidjson_FIND_QUIETLY) + message(STATUS "Found rapidjson header files in ${RAPIDJSON_INCLUDE_DIRS}") + if(DEFINED RAPIDJSON_CXX_FLAGS) + message(STATUS "Found rapidjson C++ extra compilation flags: ${RAPIDJSON_CXX_FLAGS}") + endif() + endif() +elseif(rapidjson_FIND_REQUIRED) + message(FATAL_ERROR "Could not find rapidjson") +else() + message(STATUS "Optional package rapidjson was not found") +endif() \ No newline at end of file diff --git a/cmake/WowneroConfig.cmake.in b/cmake/WowneroConfig.cmake.in index 02ba78676..98c8075b8 100644 --- a/cmake/WowneroConfig.cmake.in +++ b/cmake/WowneroConfig.cmake.in @@ -3,6 +3,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules/") include("${CMAKE_CURRENT_LIST_DIR}/modules/functions.cmake") include("${CMAKE_CURRENT_LIST_DIR}/WowneroTargets.cmake") +set_arch_id() if(STATIC) set(BUILD_SHARED_LIBS OFF) @@ -18,6 +19,7 @@ find_package(Backtrace) find_package(PythonInterp) find_package(miniupnpc REQUIRED) find_package(ZMQ REQUIRED) +find_package(rapidjson REQUIRED) find_package(OpenSSL REQUIRED) find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options locale) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 95dd2301f..d2926d31d 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -33,9 +33,7 @@ function(print_cmake_summary) else() message(STATUS "[+] STATIC: no") endif() -# message(STATUS "[+] ARM: ${ARM}") -# message(STATUS "[+] Android: ${ANDROID}") -# message(STATUS "[+] iOS: ${IOS}") + message(STATUS "[+] arch: ${ARCH_ID}") if(GIT_FOUND) execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_HEAD OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -95,3 +93,18 @@ macro(install_with_directory) INSTALL(FILES ${FILE} DESTINATION ${CAS_DESTINATION}/${DIR}) endforeach() endmacro(install_with_directory) + +function(set_arch_id) + # possible values: amd64, x86, aarch64 + set(ARCH_ID ${CMAKE_SYSTEM_PROCESSOR}) + string(TOLOWER ${ARCH_ID} ARCH_ID) + + if(ARCH_ID STREQUAL "x86_64") + set(ARCH_ID "amd64") + elseif(ARCH_ID STREQUAL "i386") + set(ARCH_ID "x86") + elseif(ARCH_ID STREQUAL "aarch64") + set(ARCH_ID "arm64") + endif() + set(ARCH_ID "${ARCH_ID}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/platform_apple_aarch64.cmake b/cmake/platform_apple_aarch64.cmake new file mode 100644 index 000000000..f30fc69c6 --- /dev/null +++ b/cmake/platform_apple_aarch64.cmake @@ -0,0 +1,21 @@ +SET(CLANG_TARGET "arm64-apple-darwin") +SET(CONF_TRIPLE "aarch64-apple-darwin") +SET(BUILD_TAG "mac-armv8") +SET(CMAKE_OSX_ARCHITECTURES "arm64") +set(ARM ON) +set(ARM_ID "armv8-a") +SET(LLVM_ENABLE_PIC OFF) +SET(LLVM_ENABLE_PIE OFF) + +set(WALLET_CRYPTO_LIBRARY "cn") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -D_GNU_SOURCE -fvisibility=default -march=armv8-a+crypto -mfix-cortex-a53-835769") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -D_GNU_SOURCE -fvisibility=default -march=armv8-a+crypto -mfix-cortex-a53-835769") + +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -fno-strict-aliasing -D_GNU_SOURCE -Wpointer-arith -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-range-loop-construct -Wno-unused-variable -Wno-error=inline-asm -Wno-reorder -Wno-missing-field-initializers -fPIC -Wno-uninitialized -Wformat -Wformat-security -fstack-protector -fstack-protector-strong -Werror=switch -Werror=return-type -fno-strict-aliasing -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0 -fno-aligned-allocation") +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -D_GNU_SOURCE -Wpointer-arith -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-range-loop-construct -Wno-error=undef -Wno-error=inline-asm -Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wno-uninitialized -Wformat -Wformat-security -fstack-protector -fstack-protector-strong -Werror=switch -Werror=return-type -fno-strict-aliasing") + +execute_process(COMMAND brew --prefix openssl OUTPUT_VARIABLE OPENSSL_ROOT_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND brew --prefix boost OUTPUT_VARIABLE BOOST_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE) + +find_library(IOKIT_LIBRARY IOKit) diff --git a/cmake/platform_linux.cmake b/cmake/platform_linux.cmake new file mode 100644 index 000000000..f8a3080ad --- /dev/null +++ b/cmake/platform_linux.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") + +set(WALLET_CRYPTO_LIBRARY "amd64-64-24k") \ No newline at end of file diff --git a/contrib/epee/src/readline_buffer.cpp b/contrib/epee/src/readline_buffer.cpp deleted file mode 100644 index 1047d1696..000000000 --- a/contrib/epee/src/readline_buffer.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include "readline_buffer.h" -#include -#include -#include -#include -#include -#include - -static bool same_as_last_line(const std::string&); -static void install_line_handler(); -static void remove_line_handler(); - -static boost::mutex sync_mutex; -static rdln::linestatus line_stat; -static char *the_line; - -namespace -{ - rdln::readline_buffer* current = NULL; -} - -rdln::suspend_readline::suspend_readline() -: m_buffer(NULL), m_restart(false) -{ - m_buffer = current; - if(!m_buffer) - return; - m_restart = m_buffer->is_running(); - if(m_restart) - m_buffer->stop(); -} - -rdln::suspend_readline::~suspend_readline() -{ - if(!m_buffer) - return; - if(m_restart) - m_buffer->start(); -} - -std::vector& rdln::readline_buffer::completion_commands() -{ - static std::vector commands = {"exit"}; - return commands; -} - -rdln::readline_buffer::readline_buffer() -: std::stringbuf(), m_cout_buf(NULL), m_prompt_length(0) -{ - current = this; -} - -void rdln::readline_buffer::start() -{ - boost::lock_guard lock(sync_mutex); - if(m_cout_buf != NULL) - return; - m_cout_buf = std::cout.rdbuf(); - std::cout.rdbuf(this); - install_line_handler(); -} - -void rdln::readline_buffer::stop() -{ - boost::lock_guard lock(sync_mutex); - if(m_cout_buf == NULL) - return; - std::cout.rdbuf(m_cout_buf); - m_cout_buf = NULL; - remove_line_handler(); -} - -rdln::linestatus rdln::readline_buffer::get_line(std::string& line) const -{ - boost::lock_guard lock(sync_mutex); - line_stat = rdln::partial; - if (!m_cout_buf) - { - line = ""; - return rdln::full; - } - rl_callback_read_char(); - if (line_stat == rdln::full) - { - line = the_line; - free(the_line); - the_line = NULL; - } - return line_stat; -} - -void rdln::readline_buffer::set_prompt(const std::string& prompt) -{ - boost::lock_guard lock(sync_mutex); - if(m_cout_buf == NULL) - return; - rl_set_prompt(std::string(m_prompt_length, ' ').c_str()); - rl_redisplay(); - rl_set_prompt(prompt.c_str()); - rl_redisplay(); - m_prompt_length = prompt.size(); -} - -void rdln::readline_buffer::add_completion(const std::string& command) -{ - if(std::find(completion_commands().begin(), completion_commands().end(), command) != completion_commands().end()) - return; - completion_commands().push_back(command); -} - -const std::vector& rdln::readline_buffer::get_completions() -{ - return completion_commands(); -} - -int rdln::readline_buffer::sync() -{ - boost::lock_guard lock(sync_mutex); - - if (m_cout_buf == nullptr) - { - return -1; - } - -#if RL_READLINE_VERSION < 0x0700 - char lbuf[2] = {0,0}; - char *line = NULL; - int end = 0, point = 0; -#endif - - if (rl_end || (rl_prompt && *rl_prompt)) - { -#if RL_READLINE_VERSION >= 0x0700 - rl_clear_visible_line(); -#else - line = rl_line_buffer; - end = rl_end; - point = rl_point; - rl_line_buffer = lbuf; - rl_end = 0; - rl_point = 0; - rl_save_prompt(); - rl_redisplay(); -#endif - } - - do - { - m_cout_buf->sputc( this->sgetc() ); - } - while ( this->snextc() != EOF ); - -#if RL_READLINE_VERSION < 0x0700 - if (end || (rl_prompt && *rl_prompt)) - { - rl_restore_prompt(); - rl_line_buffer = line; - rl_end = end; - rl_point = point; - } -#endif - rl_on_new_line(); - rl_redisplay(); - - return 0; -} - -static void handle_line(char* line) -{ - bool exit = false; - if (line) - { - line_stat = rdln::full; - the_line = line; - std::string test_line = line; - boost::trim_right(test_line); - if(!test_line.empty()) - { - if (!same_as_last_line(test_line)) - { - add_history(test_line.c_str()); - history_set_pos(history_length); - } - if (test_line == "exit" || test_line == "q") - exit = true; - } - } else - /* EOF */ - { - line_stat = rdln::empty; - exit = true; - } - rl_done = 1; - if (exit) - rl_set_prompt(""); - return; -} - -// same_as_last_line returns true, if the last line in the history is -// equal to test_line. -static bool same_as_last_line(const std::string& test_line) -{ - // Note that state->offset == state->length, when a new line was entered. - HISTORY_STATE* state = history_get_history_state(); - return state->length > 0 - && test_line.compare(state->entries[state->length-1]->line) == 0; -} - -static char* completion_matches(const char* text, int state) -{ - static size_t list_index; - static size_t len; - - if(state == 0) - { - list_index = 0; - len = strlen(text); - } - - const std::vector& completions = rdln::readline_buffer::get_completions(); - for(; list_index PUBLIC $ PUBLIC $ + ${Backtrace_INCLUDE_DIRS} ) target_link_libraries(easylogging diff --git a/external/supercop b/external/supercop index 772267cb2..cc2b9c081 160000 --- a/external/supercop +++ b/external/supercop @@ -1 +1 @@ -Subproject commit 772267cb20db1d9c4ddd9271d1024fd5a3ba3adb +Subproject commit cc2b9c0815b7ca03280f961bbef512d4eadbc2f2 diff --git a/src/blockchain_db/CMakeLists.txt b/src/blockchain_db/CMakeLists.txt index 820fb39f5..50eb278d3 100644 --- a/src/blockchain_db/CMakeLists.txt +++ b/src/blockchain_db/CMakeLists.txt @@ -35,8 +35,6 @@ set(BCDB_HEADERS testdb.h lmdb/db_lmdb.h) -message(STATUS "${BCDB_HEADERS}") - add_library(blockchain_db) target_sources(blockchain_db PRIVATE diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt index 3d0ece676..9b37509aa 100644 --- a/src/blocks/CMakeLists.txt +++ b/src/blocks/CMakeLists.txt @@ -69,6 +69,7 @@ target_include_directories(blocks PUBLIC $ PUBLIC $ PUBLIC $ + PUBLIC ${Boost_INCLUDE_DIRS} ) wownero_install_library(blocks diff --git a/src/checkpoints/CMakeLists.txt b/src/checkpoints/CMakeLists.txt index 71b169965..eeb325814 100644 --- a/src/checkpoints/CMakeLists.txt +++ b/src/checkpoints/CMakeLists.txt @@ -40,7 +40,8 @@ target_link_libraries(checkpoints PUBLIC Boost::serialization Boost::filesystem Boost::system - Boost::thread) + Boost::thread + ${IOKIT_LIBRARY}) target_include_directories(checkpoints PUBLIC $ diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7dfb40232..e32bc6b8b 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -26,7 +26,26 @@ # 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. -file(GLOB COMMON_SOURCES "*.cpp" "*.c") +set(COMMON_SOURCES + base58.cpp + command_line.cpp + dns_utils.cpp + download.cpp + error.cpp + expect.cpp + util.cpp + i18n.cpp + notify.cpp + password.cpp + perf_timer.cpp + pruning.cpp + spawn.cpp + threadpool.cpp + updates.cpp + aligned.c + timings.cc + combinator.cpp) + set(COMMON_HEADERS aligned.h apply_permutation.h @@ -53,7 +72,6 @@ set(COMMON_HEADERS scoped_message_writer.h sfinae_helpers.h spawn.h - stack_trace.h threadpool.h timings.h unordered_containers_boost_serialization.h diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index de246e728..08d8c9c28 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -76,9 +76,7 @@ set(crypto_headers variant2_int_sqrt.h variant4_random_math.h) -message(STATUS "${crypto_headers}") - -if(NOT ARM) +if(ARCH_ID STREQUAL "x86" OR ARCH_ID STREQUAL "amd64") list(APPEND crypto_sources CryptonightR_template.S) endif() @@ -93,7 +91,7 @@ target_link_libraries(cncrypto epee randomx Boost::system - ${sodium_LIBRARY_RELEASE} + sodium OpenSSL::SSL OpenSSL::Crypto ${CMAKE_DL_LIBS}) @@ -102,7 +100,6 @@ target_include_directories(cncrypto PUBLIC $ PUBLIC $ PUBLIC $ - PUBLIC ${sodium_INCLUDE_DIR} ) if (ARM AND NO_OPTIMIZED_MULTIPLY_ON_ARM) @@ -118,6 +115,9 @@ if (ANDROID OR IOS) add_definitions(-DFORCE_USE_HEAP=1) endif() +set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS "${ARCH_ID}") + # cheat because cmake and ccache hate each other set_property(SOURCE CryptonightR_template.S PROPERTY LANGUAGE ASM) set_property(SOURCE CryptonightR_template.S PROPERTY XCODE_EXPLICIT_FILE_TYPE sourcecode.asm) diff --git a/src/crypto/wallet/CMakeLists.txt b/src/crypto/wallet/CMakeLists.txt index 3941ca00c..ee272a9b2 100644 --- a/src/crypto/wallet/CMakeLists.txt +++ b/src/crypto/wallet/CMakeLists.txt @@ -30,16 +30,24 @@ include(CheckLanguage) check_language(ASM-ATT) -add_library(wallet-crypto crypto.h) +# write crypto/ops.h based on platform +if(ARCH_ID STREQUAL "x86" OR ARCH_ID STREQUAL "amd64") + include(${CMAKE_SOURCE_DIR}/external/supercop/functions.cmake) + generate_supercop_config() -target_include_directories(wallet-crypto - PUBLIC $ - PUBLIC $ - PUBLIC $ - ) + target_include_directories(wallet-crypto + PUBLIC $ + PUBLIC $ + PUBLIC $ + ) -target_link_libraries(wallet-crypto PUBLIC cncrypto) + target_link_libraries(wallet-crypto PUBLIC cncrypto) -wownero_install_library(wallet-crypto - INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/wownero/wallet-crypto/" - HEADERS crypto.h) \ No newline at end of file + wownero_install_library(wallet-crypto + INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/wownero/wallet-crypto/" + HEADERS crypto.h) +else() + set(generated_include "${CMAKE_BINARY_DIR}/generated_include") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/empty.h.in ${generated_include}/crypto/wallet/ops.h) + add_library(wallet-crypto ALIAS cncrypto) +endif() diff --git a/src/cryptonote_basic/CMakeLists.txt b/src/cryptonote_basic/CMakeLists.txt index 6f0f946a7..057e0f1e0 100644 --- a/src/cryptonote_basic/CMakeLists.txt +++ b/src/cryptonote_basic/CMakeLists.txt @@ -78,7 +78,8 @@ target_link_libraries(cryptonote_basic Boost::serialization Boost::filesystem Boost::system - Boost::thread) + Boost::thread + "${IOKIT_LIBRARY}") target_include_directories(cryptonote_basic PUBLIC $ @@ -90,4 +91,5 @@ target_include_directories(cryptonote_basic wownero_install_library(cryptonote_format_utils_basic) wownero_install_library(cryptonote_basic INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/wownero/cryptonote_basic/" - HEADERS ${CN_BASIC_HEADERS}) \ No newline at end of file + HEADERS ${CN_BASIC_HEADERS}) + diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt index 695dfc049..a8136105b 100644 --- a/src/cryptonote_core/CMakeLists.txt +++ b/src/cryptonote_core/CMakeLists.txt @@ -58,6 +58,7 @@ target_include_directories(cryptonote_core PRIVATE PUBLIC $ PUBLIC $ PUBLIC $ + PUBLIC ${ZMQ_INCLUDE_DIRS} ) if(PER_BLOCK_CHECKPOINT) diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index d3a194c18..eac64974a 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -47,19 +47,28 @@ target_link_libraries(device cryptonote_format_utils_basic ringct_basic wallet-crypto - monero-crypto-amd64-64-24k + #monero-crypto-amd64-64-24k OpenSSL::Crypto Boost::serialization PRIVATE version blocks) -target_include_directories(device - PUBLIC $ - PUBLIC $ - PUBLIC $ - PUBLIC $ - ) +if(ARCH_ID STREQUAL "x86" OR ARCH_ID STREQUAL "amd64") + target_include_directories(device + PUBLIC $ + PUBLIC $ + PUBLIC $ + PUBLIC $ + ) +else() + target_include_directories(device + PUBLIC $ + PUBLIC $ + PUBLIC $ + PUBLIC $ + ) +endif() wownero_install_library(device INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/wownero/device/" diff --git a/src/device_trezor/CMakeLists.txt b/src/device_trezor/CMakeLists.txt index 6688a317b..e13f3f173 100644 --- a/src/device_trezor/CMakeLists.txt +++ b/src/device_trezor/CMakeLists.txt @@ -88,7 +88,7 @@ if(DEVICE_TREZOR_READY) ringct_basic cryptonote_core common - ${SODIUM_LIBRARY} + sodium ${Boost_CHRONO_LIBRARY} ${Protobuf_LIBRARY} ${TREZOR_LIBUSB_LIBRARIES} diff --git a/src/mnemonics/CMakeLists.txt b/src/mnemonics/CMakeLists.txt index d1eeb6b34..f1817a7f9 100644 --- a/src/mnemonics/CMakeLists.txt +++ b/src/mnemonics/CMakeLists.txt @@ -55,6 +55,7 @@ target_link_libraries(mnemonics PUBLIC epee easylogging + sodium Boost::system) target_include_directories(mnemonics diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index beff7f8e8..a51aa1278 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -57,7 +57,7 @@ target_include_directories(net PUBLIC $ PUBLIC $ PUBLIC $ - PRIVATE ${ZMQ_INCLUDE_DIRS} + PUBLIC ${ZMQ_INCLUDE_DIRS} PRIVATE ${OPENSSL_INCLUDE_DIR} ) diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index 61267f145..9923a44e8 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -53,6 +53,7 @@ target_include_directories(rpc_base PUBLIC $ PRIVATE ${ZMQ_INCLUDE_DIRS} PRIVATE ${OPENSSL_INCLUDE_DIR} + PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ) wownero_install_library(rpc_base @@ -97,6 +98,7 @@ target_include_directories(rpc PUBLIC $ PRIVATE ${ZMQ_INCLUDE_DIRS} PRIVATE ${OPENSSL_INCLUDE_DIR} + PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ) wownero_install_library(rpc @@ -127,6 +129,7 @@ target_include_directories(rpc_pub PUBLIC $ PRIVATE ${ZMQ_INCLUDE_DIRS} PRIVATE ${OPENSSL_INCLUDE_DIR} + PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ) wownero_install_library(rpc_pub @@ -178,4 +181,5 @@ target_link_libraries(daemon_rpc_server target_include_directories(daemon_rpc_server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ PRIVATE ${ZMQ_INCLUDE_DIRS} - PRIVATE ${OPENSSL_INCLUDE_DIR}) + PRIVATE ${OPENSSL_INCLUDE_DIR} + PRIVATE ${RAPIDJSON_INCLUDE_DIRS}) diff --git a/src/serialization/CMakeLists.txt b/src/serialization/CMakeLists.txt index 085f4f0a1..af3d0b5b8 100644 --- a/src/serialization/CMakeLists.txt +++ b/src/serialization/CMakeLists.txt @@ -67,6 +67,7 @@ target_include_directories(serialization PUBLIC $ PUBLIC $ PUBLIC $ + PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ) wownero_install_library(serialization diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index 295d3fb9d..f7be07cbe 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -92,6 +92,7 @@ target_include_directories(wallet PUBLIC $ PUBLIC $ PRIVATE ${OPENSSL_INCLUDE_DIR} + PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ) wownero_install_library(wallet diff --git a/src/wallet/api/CMakeLists.txt b/src/wallet/api/CMakeLists.txt index 7d2f719df..1a648118f 100644 --- a/src/wallet/api/CMakeLists.txt +++ b/src/wallet/api/CMakeLists.txt @@ -81,7 +81,8 @@ target_link_libraries(wallet_api target_include_directories(wallet_api PRIVATE ${OPENSSL_INCLUDE_DIR} - PUBLIC $) + PUBLIC $ + PRIVATE ${RAPIDJSON_INCLUDE_DIRS}) target_sources(wallet_api PRIVATE