diff --git a/.dockerignore b/.dockerignore index 84610780c..1e8aa85b4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,10 @@ build .idea +poolstate_lmdb_v1 +blockchain_lmdb_v1 +lethean-* +lock.lck +market.bin +miner_conf.json +p2pstate.bin +profile_details.log diff --git a/.github/workflows/cli-testnet.yml b/.github/workflows/cli-testnet.yml index c3568cf38..ca8543b4a 100644 --- a/.github/workflows/cli-testnet.yml +++ b/.github/workflows/cli-testnet.yml @@ -11,6 +11,7 @@ on: - '**.md' env: + HUNTER_CACHE_TOKEN: ${{ secrets.HUNTER_CACHE_TOKEN }} CCACHE_SETTINGS: | ccache --max-size=150M ccache --set-config=compression=true @@ -29,21 +30,28 @@ jobs: with: fetch-depth: 0 submodules: recursive - - uses: actions/cache@v3 + - name: Process Hunter Cache + uses: actions/cache@v3 + with: + path: /home/runner/.hunter + key: hunter-${{ runner.os }} + restore-keys: hunter-${{ runner.os }} + - name: Process Ccache + uses: actions/cache@v3 with: path: ~/.ccache - key: ccache-${{ runner.os }}-build-testnet-cli-${{ github.sha }} - restore-keys: ccache-${{ runner.os }}-build-testnet-cli- + key: ccache-${{ runner.os }}-build-testnet-cli + restore-keys: ccache-${{ runner.os }}-build-testnet-cli - name: update apt - run: sudo apt update & sudo apt-get upgrade -y + run: sudo apt update - name: install dependencies - run: sudo apt-get install -y python-dev autotools-dev libboost-all-dev libicu-dev libbz2-dev git screen checkinstall zlib1g-dev ccache miniupnpc + run: | + sudo apt-get install -y python-dev autotools-dev libbz2-dev git screen checkinstall zlib1g-dev ccache miniupnpc + pip install gitpython requests - name: build server run: | ${{env.CCACHE_SETTINGS}} ./utils/build/testnet_linux_cli.sh - - name: Move Tarball - run: cd build/release && mv lethean-linux-cli-*.tar.bz2 ../../ - uses: actions/upload-artifact@v3 with: name: lethean-linux-cli @@ -67,26 +75,28 @@ jobs: with: fetch-depth: 0 submodules: recursive - - uses: actions/cache@v3 + - name: Process Hunter Cache + uses: actions/cache@v3 + with: + path: /Users/runner/.hunter + key: hunter-${{ runner.os }} + restore-keys: hunter-${{ runner.os }} + - name: Process ccache + uses: actions/cache@v3 with: path: /Users/runner/Library/Caches/ccache key: ccache-${{ runner.os }}-build-testnet-cli restore-keys: ccache-${{ runner.os }}-build-testnet-cli + - name: hacky python fix + run: | + cd /usr/local/Frameworks/Python.framework/Versions/3.11/bin/ + ./pip3 install requests gitpython - name: install dependencies - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl boost icu4c ccache miniupnpc + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache miniupnpc - name: build server - env: - PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig" - OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3" - ZANO_BOOST_ROOT: "/opt/homebrew/opt/boost" - ZANO_BOOST_LIBS_PATH: "/opt/homebrew/opt/boost/lib" - CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" run: | ${{env.CCACHE_SETTINGS}} - export LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/icu4c/lib ./utils/build/testnet_mac_osx_cli.sh - - name: Move Tarball - run: cd build/release && mv lethean-macos-cli-*.tar.bz2 ../../ - uses: actions/upload-artifact@v3 with: name: lethean-macos-cli @@ -115,36 +125,21 @@ jobs: restore-keys: ccache-${{ runner.os }}-build-testnet-cli - name: Eat the Choco run: | - choco install openssl --version 1.1.1.1500 -y choco install ccache -y choco install zip -y - - name: install msvc toolset - uses: ilammy/msvc-dev-cmd@v1 - - name: Install boost - uses: MarkusJx/install-boost@v2.4.1 - id: install-boost - with: - # REQUIRED: Specify the required boost version - # A list of supported versions can be found here: - # https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json - boost_version: 1.80.0 - platform_version: 2022 - toolset: msvc - link: static - - name: Set up Visual Studio shell - uses: egor-tensin/vs-shell@v2 - with: - arch: x64 + - name: hacky python fix + shell: cmd + working-directory: C:/hostedtoolcache/windows/Python/3.11.1/x86/ + run: | + curl https://bootstrap.pypa.io/get-pip.py -o C:/hostedtoolcache/windows/Python/3.11.1/x86/get-pip.py + C:/hostedtoolcache/windows/Python/3.11.1/x86/python C:/hostedtoolcache/windows/Python/3.11.1/x86/get-pip.py + C:/hostedtoolcache/windows/Python/3.11.1/x86/Scripts/pip.exe install requests gitpython - name: build server env: QT_PREFIX_PATH: C:\ProgramData\chocolatey\lib\Qt5.11.2\5.11.2 - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - LOCAL_BOOST_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }} - OPENSSL_ROOT_DIR: "C:\\Program Files\\OpenSSL-Win64" run: | - refreshenv ${{env.CCACHE_SETTINGS}} - .\utils\build\testnet_windows_cli.bat + ./utils/build/testnet_windows_cli.bat - uses: actions/upload-artifact@v3 with: name: lethean-windows-cli diff --git a/.idea/jsonSchemas.xml b/.idea/jsonSchemas.xml new file mode 100644 index 000000000..163b98f02 --- /dev/null +++ b/.idea/jsonSchemas.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b87f562be..aedd753b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,17 @@ cmake_minimum_required(VERSION 2.8.6) list(INSERT CMAKE_MODULE_PATH 0 - "${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake") + "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(HunterGate) +include(Hunter/HunterCacheServers) +set(HUNTER_CONFIGURATION_TYPES Release CACHE STRING "Build type of Hunter packages") +set(HUNTER_JOBS_NUMBER 6 CACHE STRING "Number of parallel builds used by Hunter") +HunterGate( + URL "https://github.com/cpp-pm/hunter/archive/v0.24.15.tar.gz" + SHA1 "8010d63d5ae611c564889d5fe12d3cb7a45703ac" + LOCAL +) PROJECT(Lethean) @@ -43,7 +53,8 @@ set(VERSION "1.0") # cmake_policy(SET CMP0020 OLD) # endif() -include(ConfigOpenSSL) +hunter_add_package(OpenSSL) +find_package(OpenSSL REQUIRED) if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android") add_definitions(-DMOBILE_WALLET_BUILD) @@ -62,22 +73,29 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# build types -if (UNIX AND NOT APPLE) - # single configurations, defaults to Release - if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - endif() -else() - # multi configurations for MSVC and XCode - if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - set(CMAKE_CONFIGURATION_TYPES "Release") - elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") - set(CMAKE_CONFIGURATION_TYPES "Debug;Release") - else() - set(CMAKE_CONFIGURATION_TYPES "Debug;Release") - endif() + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") endif() +if (NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES "Debug;Release") +endif() +# build types +#if (UNIX AND NOT APPLE) +# # single configurations, defaults to Release +# if (NOT CMAKE_BUILD_TYPE) +# set(CMAKE_BUILD_TYPE "Release") +# endif() +#else() +# # multi configurations for MSVC and XCode +# if(CMAKE_SYSTEM_NAME STREQUAL "iOS") +# set(CMAKE_CONFIGURATION_TYPES "Release") +# elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") +# set(CMAKE_CONFIGURATION_TYPES "Debug;Release") +# else() +# set(CMAKE_CONFIGURATION_TYPES "Debug;Release") +# endif() +#endif() message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}") enable_testing() @@ -220,6 +238,8 @@ else() endif() endif() +hunter_add_package(ICU) +find_package(ICU CONFIG REQUIRED) if(MSVC) set(Boost_USE_STATIC_LIBS ON) @@ -244,11 +264,10 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") set(Boost_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}/${CMAKE_ANDROID_ARCH_ABI}/") set(Boost_LIBRARIES "${Boost_LIBRARY_DIRS}libboost_system.a;${Boost_LIBRARY_DIRS}libboost_filesystem.a;${Boost_LIBRARY_DIRS}libboost_thread.a;${Boost_LIBRARY_DIRS}libboost_timer.a;${Boost_LIBRARY_DIRS}libboost_date_time.a;${Boost_LIBRARY_DIRS}libboost_chrono.a;${Boost_LIBRARY_DIRS}libboost_regex.a;${Boost_LIBRARY_DIRS}libboost_serialization.a;${Boost_LIBRARY_DIRS}libboost_atomic.a;${Boost_LIBRARY_DIRS}libboost_program_options.a") else() - find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) + hunter_add_package(Boost COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale log) + find_package(Boost 1.80 CONFIG REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) endif() - - message(STATUS "Boost: ${Boost_VERSION} from ${Boost_LIBRARY_DIRS}") diff --git a/Makefile b/Makefile index f78897d20..d3b57d83b 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ endif cmake = cmake $(cmake_gen) -cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug -D MUTE_ERRORS=FALSE -cmake_release = $(cmake) -D CMAKE_BUILD_TYPE=Release +cmake_debug = -D CMAKE_BUILD_TYPE=Debug -D MUTE_ERRORS=FALSE +cmake_release = -D CMAKE_BUILD_TYPE=Release cmake_gui = -D BUILD_GUI=ON cmake_testnet = -D TESTNET=ON @@ -28,7 +28,7 @@ build = build dir_debug = $(build)/debug dir_release = $(build)/release -all: release +all: help release: $(eval command += $(cmake_release)) @@ -51,9 +51,9 @@ static-release: $(eval command += $(cmake_release) $(cmake_static)) $(call CMAKE,$(dir_release),$(command)) && $(MAKE) -static-release-testnet: - $(eval command += $(cmake_release) $(cmake_static) $(cmake_testnet)) - $(call CMAKE,$(dir_release),$(command)) && $(MAKE) +static-release-testnet: ## Compile static CLI binaries + cmake -H. -B$(dir_release) $(cmake_release) $(cmake_static) $(cmake_testnet) + cmake --build $(dir_release) -- # # GUI @@ -96,10 +96,28 @@ test-debug: clean: rm -rf build -macos-gui: - bash ./utils/build_script_mac_osx.sh +macos-gui-testnet: + bash ./utils/build/testnet_mac_osx_gui.sh + +linux-gui-testnet: ## Build Linux GUI packaged archive + bash ./utils/build/testnet_linux_gui.sh + +macos-cli-testnet: ## Build Macos CLI packaged archive + bash ./utils/build/testnet_mac_osx_cli.sh + +linux-cli-testnet: ## Build Linux CLI packaged archive + bash ./utils/build/testnet_linux_cli.sh + +windows-cli-testnet: ## Build Windows CLI packaged archive + ./utils/build/testnet_windows_cli.sh + + +help: ## Show this help + @egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m make %-30s\033[0m %s\n", $$1, $$2}' + tags: ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest .PHONY: all release debug static static-release gui gui-release gui-static gui-release-static gui-debug test test-release test-debug clean tags macos-gui +.PHONY: linux-cli-testnet macos-cli-testnet macos-gui-testnet linux-gui-testnet windows-cli-testnet help diff --git a/contrib/cmake/ConfigOpenSSL.cmake b/cmake/ConfigOpenSSL.cmake similarity index 96% rename from contrib/cmake/ConfigOpenSSL.cmake rename to cmake/ConfigOpenSSL.cmake index 713095638..8ce2e1729 100644 --- a/contrib/cmake/ConfigOpenSSL.cmake +++ b/cmake/ConfigOpenSSL.cmake @@ -7,7 +7,7 @@ if (APPLE AND NOT IOS) message(STATUS "Using OpenSSL found at ${OPENSSL_ROOT_DIR}") endif() endif() - +hunter_add_package(OpenSSL) find_package(OpenSSL REQUIRED) message(STATUS "Using OpenSSL include dir at ${OPENSSL_INCLUDE_DIR}") include_directories(${OPENSSL_INCLUDE_DIR}) diff --git a/contrib/cmake/FindCcache.cmake b/cmake/FindCcache.cmake similarity index 100% rename from contrib/cmake/FindCcache.cmake rename to cmake/FindCcache.cmake diff --git a/contrib/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake similarity index 100% rename from contrib/cmake/FindMiniupnpc.cmake rename to cmake/FindMiniupnpc.cmake diff --git a/cmake/Hunter/HunterCacheServers-passwords.cmake b/cmake/Hunter/HunterCacheServers-passwords.cmake new file mode 100644 index 000000000..b4da3acf7 --- /dev/null +++ b/cmake/Hunter/HunterCacheServers-passwords.cmake @@ -0,0 +1,18 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2018 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. See the LICENSE file. + +# Hunter passwords file used by HunterCacheServers.cmake. +# Do not include directly. + +hunter_upload_password( + # REPO_OWNER + REPO = https://github.com/letheanVPN/hunter-cache + REPO_OWNER letheanVPN + REPO hunter-cache + + # USERNAME = https://github.com/snider + USERNAME snider + + # PASSWORD = GitHub token saved as a secure environment variable + PASSWORD "$ENV{HUNTER_CACHE_TOKEN}" +) diff --git a/cmake/Hunter/HunterCacheServers.cmake b/cmake/Hunter/HunterCacheServers.cmake new file mode 100644 index 000000000..30504c93e --- /dev/null +++ b/cmake/Hunter/HunterCacheServers.cmake @@ -0,0 +1,27 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2018 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. See the LICENSE file. + +# This module, when included, sets default values for params related to +# Hunter cache servers, including upload options. + +# Default Hunter cache servers. +set(HUNTER_CACHE_SERVERS + "https://github.com/letheanVPN/hunter-cache" + CACHE STRING "Hunter cache servers") + +# Default path to Hunter passwords file containing information how to access +# Ethereum's cache server. +set(HUNTER_PASSWORDS_PATH + ${CMAKE_CURRENT_LIST_DIR}/HunterCacheServers-passwords.cmake + CACHE STRING "Hunter passwords file") + +# In CI builds upload the binaries if the HUNTER_CACHE_TOKEN was decrypted +# (only for branches and internal PRs). +if(NOT "$ENV{HUNTER_CACHE_TOKEN}" STREQUAL "") + set(run_upload YES) +else() + set(run_upload NO) +endif() +option(HUNTER_RUN_UPLOAD "Upload binaries to the Hunter cache server" ${run_upload}) +unset(run_upload) diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake new file mode 100644 index 000000000..68fae988c --- /dev/null +++ b/cmake/Hunter/config.cmake @@ -0,0 +1 @@ +hunter_config(Boost VERSION 1.81.0 CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON) diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake new file mode 100644 index 000000000..64ccde563 --- /dev/null +++ b/cmake/HunterGate.cmake @@ -0,0 +1,537 @@ +# Copyright (c) 2013-2019, Ruslan Baratov +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * 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. +# +# 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. + +# This is a gate file to Hunter package manager. +# Include this file using `include` command and add package you need, example: +# +# cmake_minimum_required(VERSION 3.2) +# +# include("cmake/HunterGate.cmake") +# HunterGate( +# URL "https://github.com/path/to/hunter/archive.tar.gz" +# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" +# ) +# +# project(MyProject) +# +# hunter_add_package(Foo) +# hunter_add_package(Boo COMPONENTS Bar Baz) +# +# Projects: +# * https://github.com/hunter-packages/gate/ +# * https://github.com/ruslo/hunter + +option(HUNTER_ENABLED "Enable Hunter package manager support" ON) + +if(HUNTER_ENABLED) + if(CMAKE_VERSION VERSION_LESS "3.2") + message( + FATAL_ERROR + "At least CMake version 3.2 required for Hunter dependency management." + " Update CMake or set HUNTER_ENABLED to OFF." + ) + endif() +endif() + +include(CMakeParseArguments) # cmake_parse_arguments + +option(HUNTER_STATUS_PRINT "Print working status" ON) +option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) +option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) +set(HUNTER_ROOT "" CACHE FILEPATH "Override the HUNTER_ROOT.") + +set(HUNTER_ERROR_PAGE "https://hunter.readthedocs.io/en/latest/reference/errors") + +function(hunter_gate_status_print) + if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) + message(STATUS "[hunter] ${print_message}") + endforeach() + endif() +endfunction() + +function(hunter_gate_status_debug) + if(HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) + string(TIMESTAMP timestamp) + message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") + endforeach() + endif() +endfunction() + +function(hunter_gate_error_page error_page) + message("------------------------------ ERROR ------------------------------") + message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") + message("-------------------------------------------------------------------") + message("") + message(FATAL_ERROR "") +endfunction() + +function(hunter_gate_internal_error) + message("") + foreach(print_message ${ARGV}) + message("[hunter ** INTERNAL **] ${print_message}") + endforeach() + message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_error_page("error.internal") +endfunction() + +function(hunter_gate_fatal_error) + cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") + if("${hunter_ERROR_PAGE}" STREQUAL "") + hunter_gate_internal_error("Expected ERROR_PAGE") + endif() + message("") + foreach(x ${hunter_UNPARSED_ARGUMENTS}) + message("[hunter ** FATAL ERROR **] ${x}") + endforeach() + message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_error_page("${hunter_ERROR_PAGE}") +endfunction() + +function(hunter_gate_user_error) + hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") +endfunction() + +function(hunter_gate_self root version sha1 result) + string(COMPARE EQUAL "${root}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("root is empty") + endif() + + string(COMPARE EQUAL "${version}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("version is empty") + endif() + + string(COMPARE EQUAL "${sha1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("sha1 is empty") + endif() + + string(SUBSTRING "${sha1}" 0 7 archive_id) + + if(EXISTS "${root}/cmake/Hunter") + set(hunter_self "${root}") + else() + set( + hunter_self + "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" + ) + endif() + + set("${result}" "${hunter_self}" PARENT_SCOPE) +endfunction() + +# Set HUNTER_GATE_ROOT cmake variable to suitable value. +function(hunter_gate_detect_root) + # Check CMake variable + if(HUNTER_ROOT) + set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") + return() + endif() + + # Check environment variable + if(DEFINED ENV{HUNTER_ROOT}) + set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") + return() + endif() + + # Check HOME environment variable + if(DEFINED ENV{HOME}) + set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") + return() + endif() + + # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) + if(WIN32) + if(DEFINED ENV{SYSTEMDRIVE}) + set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug( + "HUNTER_ROOT set using SYSTEMDRIVE environment variable" + ) + return() + endif() + + if(DEFINED ENV{USERPROFILE}) + set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug( + "HUNTER_ROOT set using USERPROFILE environment variable" + ) + return() + endif() + endif() + + hunter_gate_fatal_error( + "Can't detect HUNTER_ROOT" + ERROR_PAGE "error.detect.hunter.root" + ) +endfunction() + +function(hunter_gate_download dir) + string( + COMPARE + NOTEQUAL + "$ENV{HUNTER_DISABLE_AUTOINSTALL}" + "" + disable_autoinstall + ) + if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) + hunter_gate_fatal_error( + "Hunter not found in '${dir}'" + "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" + "Settings:" + " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" + " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" + ERROR_PAGE "error.run.install" + ) + endif() + string(COMPARE EQUAL "${dir}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("Empty 'dir' argument") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_URL empty") + endif() + + set(done_location "${dir}/DONE") + set(sha1_location "${dir}/SHA1") + + set(build_dir "${dir}/Build") + set(cmakelists "${dir}/CMakeLists.txt") + + hunter_gate_status_debug("Locking directory: ${dir}") + file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) + hunter_gate_status_debug("Lock done") + + if(EXISTS "${done_location}") + # while waiting for lock other instance can do all the job + hunter_gate_status_debug("File '${done_location}' found, skip install") + return() + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(MAKE_DIRECTORY "${build_dir}") # check directory permissions + + # Disabling languages speeds up a little bit, reduces noise in the output + # and avoids path too long windows error + file( + WRITE + "${cmakelists}" + "cmake_minimum_required(VERSION 3.2)\n" + "project(HunterDownload LANGUAGES NONE)\n" + "include(ExternalProject)\n" + "ExternalProject_Add(\n" + " Hunter\n" + " URL\n" + " \"${HUNTER_GATE_URL}\"\n" + " URL_HASH\n" + " SHA1=${HUNTER_GATE_SHA1}\n" + " DOWNLOAD_DIR\n" + " \"${dir}\"\n" + " TLS_VERIFY\n" + " ${HUNTER_TLS_VERIFY}\n" + " SOURCE_DIR\n" + " \"${dir}/Unpacked\"\n" + " CONFIGURE_COMMAND\n" + " \"\"\n" + " BUILD_COMMAND\n" + " \"\"\n" + " INSTALL_COMMAND\n" + " \"\"\n" + ")\n" + ) + + if(HUNTER_STATUS_DEBUG) + set(logging_params "") + else() + set(logging_params OUTPUT_QUIET) + endif() + + hunter_gate_status_debug("Run generate") + + # Need to add toolchain file too. + # Otherwise on Visual Studio + MDD this will fail with error: + # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" + if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") + get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") + else() + # 'toolchain_arg' can't be empty + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") + endif() + + string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) + if(no_make) + set(make_arg "") + else() + # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM + set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") + endif() + + execute_process( + COMMAND + "${CMAKE_COMMAND}" + "-H${dir}" + "-B${build_dir}" + "-G${CMAKE_GENERATOR}" + "${toolchain_arg}" + ${make_arg} + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error( + "Configure project failed." + "To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}" + "In directory ${dir}" + ) + endif() + + hunter_gate_status_print( + "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" + " ${HUNTER_GATE_URL}" + " -> ${dir}" + ) + execute_process( + COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error("Build project failed") + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") + file(WRITE "${done_location}" "DONE") + + hunter_gate_status_debug("Finished") +endfunction() + +# Must be a macro so master file 'cmake/Hunter' can +# apply all variables easily just by 'include' command +# (otherwise PARENT_SCOPE magic needed) +macro(HunterGate) + if(HUNTER_GATE_DONE) + # variable HUNTER_GATE_DONE set explicitly for external project + # (see `hunter_download`) + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() + + # First HunterGate command will init Hunter, others will be ignored + get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) + + if(NOT HUNTER_ENABLED) + # Empty function to avoid error "unknown function" + function(hunter_add_package) + endfunction() + + set( + _hunter_gate_disabled_mode_dir + "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode" + ) + if(EXISTS "${_hunter_gate_disabled_mode_dir}") + hunter_gate_status_debug( + "Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}" + ) + list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}") + endif() + elseif(_hunter_gate_done) + hunter_gate_status_debug("Secondary HunterGate (use old settings)") + hunter_gate_self( + "${HUNTER_CACHED_ROOT}" + "${HUNTER_VERSION}" + "${HUNTER_SHA1}" + _hunter_self + ) + include("${_hunter_self}/cmake/Hunter") + else() + set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") + + string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) + if(_have_project_name) + hunter_gate_fatal_error( + "Please set HunterGate *before* 'project' command. " + "Detected project: ${PROJECT_NAME}" + ERROR_PAGE "error.huntergate.before.project" + ) + endif() + + cmake_parse_arguments( + HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} + ) + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) + string( + COMPARE + NOTEQUAL + "${HUNTER_GATE_UNPARSED_ARGUMENTS}" + "" + _have_unparsed + ) + string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) + string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) + + if(_have_unparsed) + hunter_gate_user_error( + "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" + ) + endif() + if(_empty_sha1) + hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") + endif() + if(_empty_url) + hunter_gate_user_error("URL suboption of HunterGate is mandatory") + endif() + if(_have_global) + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") + endif() + endif() + if(HUNTER_GATE_LOCAL) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") + endif() + endif() + if(_have_filepath) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") + endif() + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") + endif() + endif() + + hunter_gate_detect_root() # set HUNTER_GATE_ROOT + + # Beautify path, fix probable problems with windows path slashes + get_filename_component( + HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE + ) + hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") + if(NOT HUNTER_ALLOW_SPACES_IN_PATH) + string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) + if(NOT _contain_spaces EQUAL -1) + hunter_gate_fatal_error( + "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." + "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" + "(Use at your own risk!)" + ERROR_PAGE "error.spaces.in.hunter.root" + ) + endif() + endif() + + string( + REGEX + MATCH + "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" + HUNTER_GATE_VERSION + "${HUNTER_GATE_URL}" + ) + string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) + if(_is_empty) + set(HUNTER_GATE_VERSION "unknown") + endif() + + hunter_gate_self( + "${HUNTER_GATE_ROOT}" + "${HUNTER_GATE_VERSION}" + "${HUNTER_GATE_SHA1}" + _hunter_self + ) + + set(_master_location "${_hunter_self}/cmake/Hunter") + if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") + # Hunter downloaded manually (e.g. by 'git clone') + set(_unused "xxxxxxxxxx") + set(HUNTER_GATE_SHA1 "${_unused}") + set(HUNTER_GATE_VERSION "${_unused}") + else() + get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) + set(_done_location "${_archive_id_location}/DONE") + set(_sha1_location "${_archive_id_location}/SHA1") + + # Check Hunter already downloaded by HunterGate + if(NOT EXISTS "${_done_location}") + hunter_gate_download("${_archive_id_location}") + endif() + + if(NOT EXISTS "${_done_location}") + hunter_gate_internal_error("hunter_gate_download failed") + endif() + + if(NOT EXISTS "${_sha1_location}") + hunter_gate_internal_error("${_sha1_location} not found") + endif() + file(READ "${_sha1_location}" _sha1_value) + string(TOLOWER "${_sha1_value}" _sha1_value_lower) + string(TOLOWER "${HUNTER_GATE_SHA1}" _HUNTER_GATE_SHA1_lower) + string(COMPARE EQUAL "${_sha1_value_lower}" "${_HUNTER_GATE_SHA1_lower}" _is_equal) + if(NOT _is_equal) + hunter_gate_internal_error( + "Short SHA1 collision:" + " ${_sha1_value} (from ${_sha1_location})" + " ${HUNTER_GATE_SHA1} (HunterGate)" + ) + endif() + if(NOT EXISTS "${_master_location}") + hunter_gate_user_error( + "Master file not found:" + " ${_master_location}" + "try to update Hunter/HunterGate" + ) + endif() + endif() + include("${_master_location}") + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() +endmacro() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..b0b80b853 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +gitpython diff --git a/utils/build/testnet_linux_cli.sh b/utils/build/testnet_linux_cli.sh index ece727b28..5adacd44f 100755 --- a/utils/build/testnet_linux_cli.sh +++ b/utils/build/testnet_linux_cli.sh @@ -11,55 +11,44 @@ # export QT_PREFIX_PATH=/home/user/Qt5.10.1/5.10.1/gcc_64 # export OPENSSL_ROOT_DIR=/home/user/openssl -ARCHIVE_NAME_PREFIX=lethean-linux-cli-x64- - -if [ -n "$build_prefix" ]; then - ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}${build_prefix}- - build_prefix_label="$build_prefix " -fi - - -testnet_def="-D TESTNET=TRUE" -testnet_label="testnet " -ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}testnet- +ARCHIVE_NAME_PREFIX=lethean-linux-cli-x64-testnet- prj_root=$(pwd) echo "---------------- BUILDING PROJECT ----------------" echo "--------------------------------------------------" -echo "Building...." +echo "Building...." + +rm -rf build; mkdir -p build/release; +cmake -H. -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release -DTESTNET=true -DSTATIC=true -rm -rf build; mkdir -p build/release; cd build/release; -cmake $testnet_def -D STATIC=true -D ARCH=x86-64 -D CMAKE_BUILD_TYPE=Release ../.. if [ $? -ne 0 ]; then echo "Failed to run cmake" exit 1 fi - -make -j2 daemon simplewallet connectivity_tool +cmake --build build/release -- -j2 if [ $? -ne 0 ]; then echo "Failed to make!" exit 1 fi - -read version_str <<< $(./src/letheand --version | awk '/^Lethean/ { print $2 }') +read version_str <<< $(./build/release/src/letheand --version | awk '/^Lethean/ { print $2 }') version_str=${version_str} echo $version_str - -rm -rf Lethean; -mkdir -p Lethean; +rm -rf build/Lethean; +mkdir -p build/Lethean; -cp -Rv src/letheand src/simplewallet src/connectivity_tool ./Lethean -chmod 0777 ./src/letheand src/simplewallet src/connectivity_tool +cp -Rv LICENCE build/release/src/letheand build/release/src/simplewallet build/release/src/connectivity_tool build/Lethean +chmod 0777 build/Lethean/letheand build/Lethean/simplewallet build/Lethean/connectivity_tool package_filename=${ARCHIVE_NAME_PREFIX}${version_str}.tar.bz2 rm -f ./$package_filename -tar -cjvf $package_filename Lethean +cd build/Lethean || exit +tar -cjvf ../../$package_filename * if [ $? -ne 0 ]; then echo "Failed to pack" exit 1 @@ -67,6 +56,4 @@ fi echo "Build success" - - exit 0 diff --git a/utils/build/testnet_linux_gui.sh b/utils/build/testnet_linux_gui.sh index 07802f6bd..3f9f9af1f 100755 --- a/utils/build/testnet_linux_gui.sh +++ b/utils/build/testnet_linux_gui.sh @@ -11,7 +11,7 @@ # export QT_PREFIX_PATH=/home/user/Qt5.10.1/5.10.1/gcc_64 # export OPENSSL_ROOT_DIR=/home/user/openssl -ARCHIVE_NAME_PREFIX=lethean-linux-x64- +ARCHIVE_NAME_PREFIX=lethean-linux-gui-x64- : "${BOOST_ROOT:?BOOST_ROOT should be set to the root of Boost, ex.: /home/user/boost_1_66_0}" : "${QT_PREFIX_PATH:?QT_PREFIX_PATH should be set to Qt libs folder, ex.: /home/user/Qt5.10.1/5.10.1/gcc_64}" @@ -22,11 +22,11 @@ if [ -n "$build_prefix" ]; then build_prefix_label="$build_prefix " fi -if [ "$testnet" == true ]; then + testnet_def="-D TESTNET=TRUE" testnet_label="testnet " ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}testnet- -fi + if [ "$testnet" == true ] || [ -n "$qt_dev_tools" ]; then copy_qt_dev_tools=true @@ -114,7 +114,7 @@ cp -Rv src/letheand src/Lethean src/simplewallet src/connectivity_tool ./Lethea package_filename=${ARCHIVE_NAME_PREFIX}${version_str}.tar.bz2 rm -f ./$package_filename -tar -cjvf $package_filename Lethean +tar -cjvf ../../$package_filename Lethean if [ $? -ne 0 ]; then echo "Failed to pack" exit 1 diff --git a/utils/build/testnet_mac_osx_cli.sh b/utils/build/testnet_mac_osx_cli.sh index 7e3d4d5ac..c05420bc6 100755 --- a/utils/build/testnet_mac_osx_cli.sh +++ b/utils/build/testnet_mac_osx_cli.sh @@ -2,70 +2,44 @@ set -x # echo on set +e # switch off exit on error curr_path=$(pwd) -# check that all the required environment vars are set -: "${ZANO_BOOST_ROOT:?variable not set, see also macosx_build_config.command}" -: "${ZANO_BOOST_LIBS_PATH:?variable not set, see also macosx_build_config.command}" -: "${CMAKE_OSX_SYSROOT:?CMAKE_OSX_SYSROOT should be set to macOS SDK path, e.g.: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk}" -: "${OPENSSL_ROOT_DIR:?variable not set, see also macosx_build_config.command}" +ARCHIVE_NAME_PREFIX=lethean-macos-cli-$(arch)-testnet- -ARCHIVE_NAME_PREFIX=lethean-macos-cli-x64- +rm -rf build; mkdir -p build/release; +cmake -H. -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release -DTESTNET=true -DSTATIC=true -if [ -n "$build_prefix" ]; then - ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}${build_prefix}- - build_prefix_label="$build_prefix " -fi - - -testnet_def="-D TESTNET=TRUE" -testnet_label="testnet " -ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}testnet- - - -rm -rf build; mkdir -p build/release; cd build/release; - -cmake $testnet_def -D OPENSSL_ROOT_DIR=$OPENSSL_ROOT_DIR -D CMAKE_OSX_SYSROOT=$CMAKE_OSX_SYSROOT -D CMAKE_BUILD_TYPE=Release -D BOOST_ROOT="$ZANO_BOOST_ROOT" -D BOOST_LIBRARYDIR="$ZANO_BOOST_LIBS_PATH" ../.. if [ $? -ne 0 ]; then echo "Failed to cmake" exit 1 fi -make -j2 connectivity_tool daemon simplewallet +cmake --build build/release -- -j2 if [ $? -ne 0 ]; then echo "Failed to make binaries!" exit 1 fi - -rm -rf Lethean; -mkdir -p Lethean; - - - -chmod 0777 ./src/letheand src/simplewallet src/connectivity_tool -cp -Rv src/letheand src/simplewallet src/connectivity_tool ./Lethean - -read version_str <<< $(./src/letheand --version | awk '/^Lethean/ { print $2 }') +read version_str <<< $(./build/release/src/letheand --version | awk '/^Lethean/ { print $2 }') version_str=${version_str} echo $version_str +rm -rf build/Lethean; +mkdir -p build/Lethean; -echo "############### Prepearing archive... ################" -mkdir package_folder -if [ $? -ne 0 ]; then - echo "Failed to zip app" - exit 1 -fi + +cp -Rv LICENCE build/release/src/letheand build/release/src/simplewallet build/release/src/connectivity_tool build/Lethean +chmod 0777 build/Lethean/letheand build/Lethean/simplewallet build/Lethean/connectivity_tool package_filename=${ARCHIVE_NAME_PREFIX}${version_str}.tar.bz2 rm -f ./$package_filename -tar -cjvf $package_filename Lethean +cd build/Lethean || exit +tar -cjvf ../../$package_filename * if [ $? -ne 0 ]; then echo "Failed to pack" exit 1 fi - echo "Build success" + exit 0 diff --git a/utils/build/testnet_windows_cli.bat b/utils/build/testnet_windows_cli.bat index 2db949ade..b647f4782 100644 --- a/utils/build/testnet_windows_cli.bat +++ b/utils/build/testnet_windows_cli.bat @@ -27,39 +27,19 @@ set BOOST_LIBRARYDIR=%LOCAL_BOOST_LIB_PATH% @echo "---------------- PREPARING BINARIES ---------------------------" @echo "---------------------------------------------------------------" - - cd %SOURCES_PATH% rmdir build /s /q mkdir build - +set HUNTER_ROOT=%HOMEPATH%\.hunter @echo "---------------- BUILDING APPLICATIONS ------------------------" @echo "---------------------------------------------------------------" -cd %SOURCES_PATH%\build -"C:\\Program Files\CMake\bin\cmake.exe" %TESTNET_DEF% -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_MSVC_PATH%" -D BOOST_ROOT="%BOOST_ROOT%" -D BOOST_LIBRARYDIR="%LOCAL_BOOST_LIB_PATH%" -D BUILD_GUI=false -D STATIC=FALSE -G "Visual Studio 17 2022" -T host=x64 .. +cmake -H. -Bbuild/release -DHUNTER_STATUS_DEBUG=OFF -D CMAKE_BUILD_TYPE=Release -D STATIC=ON -D TESTNET=ON -G "Visual Studio 17 2022" IF %ERRORLEVEL% NEQ 0 ( goto error ) -call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" x86_amd64 -@echo on -cd %SOURCES_PATH%\build - -msbuild version.vcxproj /p:SubSystem="CONSOLE,5.02" /p:Configuration=Release /t:Build -IF %ERRORLEVEL% NEQ 0 ( - goto error -) - -msbuild src/daemon.vcxproj /p:SubSystem="CONSOLE,5.02" /p:Configuration=Release /t:Build -IF %ERRORLEVEL% NEQ 0 ( - goto error -) - -msbuild src/simplewallet.vcxproj /p:SubSystem="CONSOLE,5.02" /p:Configuration=Release /t:Build -IF %ERRORLEVEL% NEQ 0 ( - goto error -) +cmake --build build/release -- IF %ERRORLEVEL% NEQ 0 ( goto error @@ -71,8 +51,9 @@ echo "sources are built successfully" :skip_build cd %SOURCES_PATH%/build -set cmd=src\Release\simplewallet.exe --version +set cmd=src\release\simplewallet.exe --version FOR /F "tokens=3" %%a IN ('%cmd%') DO set version=%%a +echo '%version%' set version=%version:~0,-2% echo '%version%' diff --git a/utils/build/testnet_windows_cli.sh b/utils/build/testnet_windows_cli.sh new file mode 100644 index 000000000..05e38b834 --- /dev/null +++ b/utils/build/testnet_windows_cli.sh @@ -0,0 +1,59 @@ +#!/bin/bash -x + +# Environment prerequisites: +# 1) QT_PREFIX_PATH should be set to Qt libs folder +# 2) BOOST_ROOT should be set to the root of Boost +# 3) OPENSSL_ROOT_DIR should be set to the root of OpenSSL +# +# for example, place these lines to the end of your ~/.bashrc : +# +# export BOOST_ROOT=/home/user/boost_1_66_0 +# export QT_PREFIX_PATH=/home/user/Qt5.10.1/5.10.1/gcc_64 +# export OPENSSL_ROOT_DIR=/home/user/openssl + +ARCHIVE_NAME_PREFIX=lethean-windows-cli-x64-testnet- + +prj_root=$(pwd) + +echo "---------------- BUILDING PROJECT ----------------" +echo "--------------------------------------------------" + +echo "Building...." + +rm -rf build; mkdir -p build/release; +cmake -H. -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release -DTESTNET=true -DSTATIC=true + +if [ $? -ne 0 ]; then + echo "Failed to run cmake" + exit 1 +fi +cmake --build build/release -- -j2 +if [ $? -ne 0 ]; then + echo "Failed to make!" + exit 1 +fi + +read version_str <<< $(./build/release/src/letheand.exe --version | awk '/^Lethean/ { print $2 }') +version_str=${version_str} +echo $version_str + +rm -rf build/Lethean; +mkdir -p build/Lethean; + + +cp -Rv LICENCE build/release/src/letheand.exe build/release/src/simplewallet.exe build/release/src/connectivity_tool build/Lethean.exe +chmod 0777 build/Lethean/letheand.exe build/Lethean/simplewallet.exe build/Lethean/connectivity_tool.exe + +package_filename=${ARCHIVE_NAME_PREFIX}${version_str}.tar.bz2 + +rm -f ./$package_filename +cd build/Lethean || exit +tar -cjvf ../../$package_filename * +if [ $? -ne 0 ]; then + echo "Failed to pack" + exit 1 +fi + +echo "Build success" + +exit 0 diff --git a/utils/docker/Dockerfile b/utils/docker/Dockerfile index 3e0adb84b..908116c10 100644 --- a/utils/docker/Dockerfile +++ b/utils/docker/Dockerfile @@ -42,15 +42,17 @@ ARG THREADS=2 COPY . /project -WORKDIR /project/build +WORKDIR /project -RUN cmake -D STATIC=true -D ARCH=x86-64 -D TESTNET=TRUE -D CMAKE_BUILD_TYPE=Release .. +RUN rm -rf build; mkdir -p build/release; -RUN make -j${THREADS} daemon simplewallet +RUN cmake -H. -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release -DTESTNET=true -DSTATIC=true + +RUN cmake --build build/release -- -j${THREADS} FROM scratch as export -COPY --chmod=0777 --from=build /project/build/src/letheand / -COPY --chmod=0777 --from=build /project/build/src/simplewallet / +COPY --chmod=0777 --from=build /project/build/release/src/letheand / +COPY --chmod=0777 --from=build /project/build/release/src/simplewallet / FROM ubuntu:20.04 as final