Skip to content

Commit

Permalink
Adding boost as a submodule rather than requiring it to be provided e…
Browse files Browse the repository at this point in the history
…xternally.

The boost libs are now statically linked to the nano targets so dynamic linking related functionality has been removed.
Adding several target link references that were missing but not apparent when using the unified boost install directories
Linking to boost stacktrace basic as this is the main functionality we use.
Windows Event Log support has been disabled as there is a compatibility issue with GitHub builders
Added boost_checkout_lite.sh script which can be used to do a minimal clone of the boost submodule after it's been added but not yet initialized.
  • Loading branch information
clemahieu committed Jan 13, 2023
1 parent 9bb3cbe commit cd05c50
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 204 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
[submodule "diskhash"]
path = diskhash
url = https://github.com/nanocurrency/diskhash.git
[submodule "boost"]
path = boost
url = https://github.com/boostorg/boost.git
182 changes: 102 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ if(CMAKE_VERSION VERSION_GREATER 3.13 OR CMAKE_VERSION VERSION_EQUAL 3.13)
cmake_policy(SET CMP0077 NEW)
endif()

if(CMAKE_VERSION VERSION_LESS 3.13)
# compatibility for boost import targets use bundled 3.13 FindBoost.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/legacyModules")
endif()

# compatibility for osx sierra and on needs to be set before project
set(CMAKE_OSX_DEPLOYMENT_TARGET
10.14
Expand Down Expand Up @@ -65,8 +60,7 @@ else()
endif()

if(APPLE)
set(CMAKE_INSTALL_RPATH
"@executable_path/../Frameworks;@executable_path/../boost/lib")
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()
Expand Down Expand Up @@ -129,16 +123,6 @@ set(NANO_ROCKSDB_TOOLS
OFF
CACHE BOOL "")

option(NANO_STACKTRACE_BACKTRACE
"Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)
if(NANO_STACKTRACE_BACKTRACE)
add_definitions(-DNANO_STACKTRACE_BACKTRACE=1)
if(BACKTRACE_INCLUDE)
add_definitions(
-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${BACKTRACE_INCLUDE})
endif()
endif()

if(${NANO_TIMED_LOCKS} GREATER 0)
add_definitions(-DNANO_TIMED_LOCKS=${NANO_TIMED_LOCKS})
add_definitions(-DNANO_TIMED_LOCKS_FILTER=${NANO_TIMED_LOCKS_FILTER})
Expand Down Expand Up @@ -360,35 +344,109 @@ else()
endif()

include_directories(${CMAKE_SOURCE_DIR})

if(WIN32
AND NANO_TEST
AND NANO_SHARED_BOOST)
message(
SEND_ERROR
" Linking errors occur if NANO_SHARED_BOOST is used with tests on Windows"
" Disable NANO_SHARED_BOOST or NANO_TEST on Windows")
set(NANO_SHARED_BOOST)
endif()

set(NANO_SHARED_BOOST
OFF
CACHE BOOL "Build Nano with shared boost")

if(NANO_SHARED_BOOST)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_BOOST_CMAKE ON)
add_definitions(-DBOOST_ALL_DYN_LINK)
else()
set(Boost_USE_STATIC_LIBS ON)
endif()
set(Boost_USE_MULTITHREADED ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

find_package(Boost 1.81.0 REQUIRED COMPONENTS filesystem log log_setup thread
program_options system)
set(BOOST_MODULE_LIBS
algorithm
align
any
array
asio
assert
atomic
beast
bind
chrono
circular_buffer
concept_check
config
container
container_hash
context
conversion
core
coroutine
date_time
describe
detail
dll
dynamic_bitset
endian
exception
filesystem
foreach
format
function
function_types
functional
fusion
integer
interprocess
intrusive
io
iostreams
iterator
lexical_cast
property_tree
log
logic
math
move
mp11
mpl
multi_index
multiprecision
numeric/conversion
optional
parameter
phoenix
pool
predef
preprocessor
process
program_options
proto
random
range
ratio
rational
regex
serialization
smart_ptr
spirit
stacktrace
static_assert
static_string
system
thread
throw_exception
tokenizer
tuple
type_index
type_traits
typeof
unordered
utility
variant
variant2
winapi)

add_definitions(-DBOOST_ALL_NO_LIB) # Disable automatic boost linking
foreach(lib IN LISTS BOOST_MODULE_LIBS)
add_subdirectory(boost/libs/${lib} EXCLUDE_FROM_ALL)
endforeach()
include_directories(${BOOST_LIBRARY_INCLUDES})
add_library(Boost::stacktrace ALIAS boost_stacktrace_basic)
add_definitions(-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED)

# Workaround for GitHub builders which do not appear to have the Windows Message
# Compiler mc.exe
add_definitions(-DBOOST_LOG_WITHOUT_EVENT_LOG)

# Workaround for missing reference errata in the boost property_tree module
target_link_libraries(boost_property_tree INTERFACE Boost::any)
target_link_libraries(boost_property_tree INTERFACE Boost::format)
target_link_libraries(boost_property_tree INTERFACE Boost::multi_index)

# diskhash
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down Expand Up @@ -585,7 +643,6 @@ if(NANO_FUZZER_TEST)
endif()

if(NANO_TEST OR RAIBLOCKS_TEST)
find_package(Boost 1.81.0 REQUIRED COMPONENTS coroutine context)
if(WIN32)
if(MSVC_VERSION)
if(MSVC_VERSION GREATER_EQUAL 1910)
Expand Down Expand Up @@ -756,15 +813,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install(FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib"
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/PlugIns/platforms)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
string(REGEX MATCH "(.+/.*boost_[^-]+)" boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll}
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/boost/lib)
endif()
endforeach(boost_lib)
endif()
install(FILES Nano.icns
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Resources)
Expand Down Expand Up @@ -794,24 +842,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
get_filename_component(Qt5_bin_DIR ${Qt5_DIR}/../../../bin ABSOLUTE)
install(TARGETS nano_wallet DESTINATION .)
install(TARGETS nano_wallet_com DESTINATION .)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
if(${CMAKE_BUILD_TYPE} MATCHES "Rel")
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-x64.+\)(.lib|a)"
boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.dll")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION .)
endif()
else()
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-.+-x64.+\)(.lib|a)"
boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.dll")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION .)
endif()
endif()
endforeach(boost_lib)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${WIN_REDIST} DESTINATION .)
install(FILES ${Qt5_bin_DIR}/libGLESv2.dll DESTINATION .)
Expand All @@ -826,14 +856,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
"qt5-default | qtbase5-dev, qtchooser, qt5-qmake, qtbase5-dev-tools")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "russel@nano.org")
install(TARGETS nano_wallet RUNTIME DESTINATION ./bin)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
string(REGEX MATCH "(.+/.*boost_[^-]+)" boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.${Boost_VERSION_STRING}")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION ./lib)
endif()
endforeach(boost_lib)
endif()
set(DEBIAN_POSTINST postinst.in)
set(DEBIAN_POSTRM postrm.in)
Expand Down
1 change: 1 addition & 0 deletions boost
Submodule boost added at da0411
19 changes: 19 additions & 0 deletions boost_checkout_lite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#set -x
#Check out boost submodule with minimum set of modules to reduce size

# flattened boost libs dependency list
dependencies=("algorithm" "align" "any" "array" "asio" "assert" "atomic" "beast" "bind" "chrono" "circular_buffer" "concept_check" "config" "container" "container_hash" "context" "conversion" "core" "coroutine" "date_time" "describe" "detail" "dll" "dynamic_bitset" "endian" "exception" "filesystem" "foreach" "format" "function" "function_types" "functional" "fusion" "integer" "interprocess" "intrusive" "io" "iostreams" "iterator" "lexical_cast" "log" "logic" "math" "move" "mp11" "mpl" "multi_index" "multiprecision" "numeric_conversion" "optional" "parameter" "phoenix" "pool" "predef" "preprocessor" "process" "program_options" "property_tree" "proto" "random" "range" "ratio" "rational" "regex" "serialization" "smart_ptr" "spirit" "stacktrace" "static_assert" "static_string" "system" "thread" "throw_exception" "tokenizer" "tuple" "type_index" "type_traits" "typeof" "unordered" "utility" "variant" "variant2" "winapi")

git submodule init boost
cd boost
# deactivate all boost submodules
git submodule foreach 'git config submodule.$sm_path.active false'
# selectivly activate required dependencies
for i in ${dependencies[@]}
do
git config submodule.$i.active true
done
cd ..
# Update all submodules recursivly. Deactivated modules will be skipped by --recursive
git submodule update --jobs 16 --recursive --recommend-shallow --single-branch
2 changes: 1 addition & 1 deletion ci/actions/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ set exit_code=%errorlevel%
goto exit

:exit
exit /B %exit_code%
exit /B %exit_code%
9 changes: 2 additions & 7 deletions ci/actions/windows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if (${env:artifact} -eq 1) {
else {
$env:NETWORK_CFG = "live"
}
$env:NANO_SHARED_BOOST = "ON"
$env:NANO_TEST = "-DNANO_TEST=OFF"
$env:CI_TAG = ${env:TAG}
if ([string]::IsNullOrEmpty(${env:VERSION_PRE_RELEASE})) {
Expand All @@ -27,10 +26,9 @@ else {
if ( ${env:RELEASE} -eq "true" -or ${env:TEST_USE_ROCKSDB} -eq 1 ) {
$env:BUILD_TYPE = "RelWithDebInfo"
}
else {
else {
$env:BUILD_TYPE = "Debug"
}
$env:NANO_SHARED_BOOST = "OFF"
$env:NETWORK_CFG = "dev"
$env:NANO_TEST = "-DNANO_TEST=ON"
$env:CI = '-DCI_TEST="1"'
Expand All @@ -40,9 +38,6 @@ else {
mkdir build
Push-Location build

#accessibility of Boost dlls for generating config samples
$ENV:PATH = "$ENV:PATH;$ENV:BOOST_ROOT\lib64-msvc-14.2"

& ..\ci\actions\windows\configure.bat
if (${LastExitCode} -ne 0) {
throw "Failed to configure"
Expand All @@ -65,4 +60,4 @@ if (${LastExitCode} -ne 0) {
throw "Failed to Pass Test ${env:RUN}"
}

Pop-Location
Pop-Location
7 changes: 2 additions & 5 deletions ci/actions/windows/configure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ cmake .. ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DACTIVE_NETWORK=nano_%NETWORK_CFG%_network ^
-DNANO_SIMD_OPTIMIZATIONS=TRUE ^
-Dgtest_force_shared_crt=on ^
-DBoost_NO_SYSTEM_PATHS=TRUE ^
-DBoost_NO_BOOST_CMAKE=TRUE ^
-DNANO_SHARED_BOOST=%NANO_SHARED_BOOST%
-Dgtest_force_shared_crt=on

set exit_code=%errorlevel%
if %exit_code% neq 0 goto exit

:exit
exit /B %exit_code%
exit /B %exit_code%
15 changes: 3 additions & 12 deletions ci/actions/windows/install_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Get-RedirectedUri {
.NOTES
Code from: Redone per issue #2896 in core https://github.com/PowerShell/PowerShell/issues/2896
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
Expand All @@ -31,7 +31,7 @@ function Get-RedirectedUri {
# This is for Powershell core
$redirectUri = $request.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
}

$retry = $false
}
catch {
Expand All @@ -44,12 +44,10 @@ function Get-RedirectedUri {
}
}
} while ($retry)

$redirectUri
}
}
$boost_url = Get-RedirectedUri "https://repo.nano.org/artifacts/boost-msvc14.2-1.70-full.zip"
$BOOST_ROOT = "c:\local\boost_1_70_0"
$qt5_root = "c:\qt"
$qt5base_url = Get-RedirectedUri "https://repo.nano.org/artifacts/5.13.1-0-201909031231qtbase-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z"
$qt5winextra_url = Get-RedirectedUri "https://repo.nano.org/artifacts/5.13.1-0-201909031231qtwinextras-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z"
Expand All @@ -62,10 +60,3 @@ mkdir $qt5_root
Push-Location $qt5_root
7z x "${env:TMP}\qt5*.7z" -aoa
Pop-Location


mkdir $BOOST_ROOT
Write-Output "BOOST_ROOT=$BOOST_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
(New-Object System.Net.WebClient).DownloadFile($boost_url, "${env:TMP}\boost-msvc.zip")
Push-Location $BOOST_ROOT
7z x "${env:TMP}\boost-msvc.zip" -aoa
13 changes: 8 additions & 5 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ target_link_libraries(
ipc_flatbuffers_lib
${CRYPTOPP_LIBRARY}
${CMAKE_DL_LIBS}
Boost::program_options)

if(NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_lib backtrace)
endif()
Boost::asio
Boost::circular_buffer
Boost::dll
Boost::log_setup
Boost::log
Boost::multiprecision
Boost::program_options
Boost::stacktrace)

target_compile_definitions(
nano_lib
Expand Down
Loading

0 comments on commit cd05c50

Please sign in to comment.