mirror of https://github.com/oxen-io/oxen-core.git
Merge remote-tracking branch 'origin/dev' into 813-release
This commit is contained in:
commit
24dd1ee800
|
@ -1,4 +1,4 @@
|
|||
local default_deps_base='libsystemd-dev libboost-filesystem-dev libboost-thread-dev libboost-date-time-dev libgtest-dev ' +
|
||||
local default_deps_base='libsystemd-dev libboost-thread-dev libgtest-dev ' +
|
||||
'libboost-serialization-dev libboost-program-options-dev libunbound-dev nettle-dev libevent-dev libminiupnpc-dev ' +
|
||||
'libunwind8-dev libsodium-dev libssl-dev libreadline-dev libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler python3 ' +
|
||||
'pkg-config libsqlite3-dev qttools5-dev libcurl4-openssl-dev';
|
||||
|
@ -6,10 +6,11 @@ local default_deps='g++ ' + default_deps_base; // g++ sometimes needs replacemen
|
|||
|
||||
local gtest_filter='-AddressFromURL.Failure:DNSResolver.DNSSEC*';
|
||||
|
||||
local submodules_commands = ['git fetch --tags', 'git submodule update --init --recursive --depth=1'];
|
||||
local submodules = {
|
||||
name: 'submodules',
|
||||
image: 'drone/git',
|
||||
commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=1']
|
||||
commands: submodules_commands
|
||||
};
|
||||
|
||||
local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';
|
||||
|
@ -45,7 +46,8 @@ local debian_pipeline(name, image,
|
|||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
|
||||
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake git ca-certificates ninja-build ccache ' + deps,
|
||||
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake git ca-certificates ninja-build ccache '
|
||||
+ deps + (if test_lokid then ' gdb' else ''),
|
||||
'mkdir build',
|
||||
'cd build',
|
||||
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE='+build_type+' ' +
|
||||
|
@ -61,7 +63,7 @@ local debian_pipeline(name, image,
|
|||
['ninja -j' + jobs + ' -v']
|
||||
) + (
|
||||
if test_lokid then [
|
||||
'(sleep 3; echo "status\ndiff\nexit") | TERM=xterm ./bin/lokid --offline --data-dir=startuptest'
|
||||
'(sleep 3; echo "status\ndiff\nexit") | TERM=xterm ../utils/build_scripts/drone-gdb.sh ./bin/lokid --offline --data-dir=startuptest'
|
||||
] else []
|
||||
) + (
|
||||
if run_tests then [
|
||||
|
@ -71,7 +73,7 @@ local debian_pipeline(name, image,
|
|||
) + extra_cmds,
|
||||
}
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
// Macos build
|
||||
local mac_builder(name,
|
||||
|
@ -89,10 +91,7 @@ local mac_builder(name,
|
|||
name: name,
|
||||
platform: { os: 'darwin', arch: 'amd64' },
|
||||
steps: [
|
||||
{
|
||||
name: 'submodules',
|
||||
commands: ['git fetch --tags', 'git submodule update --init --recursive']
|
||||
},
|
||||
{ name: 'submodules', commands: submodules_commands },
|
||||
{
|
||||
name: 'build',
|
||||
environment: { SSH_KEY: { from_secret: "SSH_KEY" }, GTEST_FILTER: gtest_filter },
|
||||
|
@ -128,20 +127,33 @@ local static_check_and_upload = [
|
|||
local static_build_deps='autoconf automake make qttools5-dev file libtool gperf pkg-config patch openssh-client';
|
||||
|
||||
|
||||
local android_build_steps(android_abi, android_platform=21, jobs=6, cmake_extra='') = [
|
||||
'mkdir build-' + android_abi,
|
||||
'cd build-' + android_abi,
|
||||
'cmake .. -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_C_FLAGS=-fdiagnostics-color=always ' +
|
||||
'-DCMAKE_BUILD_TYPE=Release ' +
|
||||
'-DCMAKE_TOOLCHAIN_FILE=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake ' +
|
||||
'-DANDROID_PLATFORM=' + android_platform + ' -DANDROID_ABI=' + android_abi + ' ' +
|
||||
'-DBUILD_STATIC_DEPS=ON -DSTATIC=ON -G Ninja ' + cmake_extra,
|
||||
'ninja -j' + jobs + ' -v wallet_merged',
|
||||
'cd ..',
|
||||
];
|
||||
|
||||
|
||||
|
||||
[
|
||||
// Various debian builds
|
||||
debian_pipeline("Debian (w/ tests) (amd64)", "debian:testing", lto=true, run_tests=true),
|
||||
debian_pipeline("Debian Debug (amd64)", "debian:testing", build_type='Debug'),
|
||||
debian_pipeline("Debian clang-10 (amd64)", "debian:testing", deps='clang-10 '+default_deps_base,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 ', lto=true),
|
||||
debian_pipeline("Debian (w/ tests) (amd64)", "debian:sid", lto=true, run_tests=true),
|
||||
debian_pipeline("Debian Debug (amd64)", "debian:sid", build_type='Debug'),
|
||||
debian_pipeline("Debian clang-11 (amd64)", "debian:sid", deps='clang-11 '+default_deps_base,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=clang-11 -DCMAKE_CXX_COMPILER=clang++-11 ', lto=true),
|
||||
debian_pipeline("Debian gcc-10 (amd64)", "debian:testing", deps='g++-10 '+default_deps_base,
|
||||
cmake_extra='-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DBUILD_DEBUG_UTILS=ON'),
|
||||
debian_pipeline("Debian buster (i386)", "i386/debian:buster", cmake_extra='-DDOWNLOAD_SODIUM=ON -DARCH_ID=i386'),
|
||||
debian_pipeline("Ubuntu focal (amd64)", "ubuntu:focal"),
|
||||
|
||||
// ARM builds (ARM64 and armhf)
|
||||
debian_pipeline("Debian (ARM64)", "debian:testing", arch="arm64", build_tests=false),
|
||||
debian_pipeline("Debian (ARM64)", "debian:sid", arch="arm64", build_tests=false),
|
||||
debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", build_tests=false, cmake_extra='-DDOWNLOAD_SODIUM=ON -DARCH_ID=armhf'),
|
||||
|
||||
// Static build (on bionic) which gets uploaded to builds.lokinet.dev:
|
||||
|
@ -159,4 +171,57 @@ local static_build_deps='autoconf automake make qttools5-dev file libtool gperf
|
|||
build_tests=false, extra_cmds=static_check_and_upload, lto=true),
|
||||
mac_builder('macOS (Release)', run_tests=true),
|
||||
mac_builder('macOS (Debug)', build_type='Debug', cmake_extra='-DBUILD_DEBUG_UTILS=ON'),
|
||||
|
||||
|
||||
// Android builds; we do them all in one image because the android NDK is huge
|
||||
{ name: 'Android wallet_api', kind: 'pipeline', type: 'docker', platform: { arch: 'amd64' },
|
||||
steps: [submodules, {
|
||||
name: 'build',
|
||||
image: 'debian:sid',
|
||||
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
|
||||
commands: [
|
||||
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
|
||||
'echo deb http://deb.debian.org/debian sid contrib >/etc/apt/sources.list.d/sid-contrib.list',
|
||||
apt_get_quiet + ' update',
|
||||
apt_get_quiet + ' install -y eatmydata',
|
||||
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
|
||||
// Keep cached copies of the android NDK around because it is huge:
|
||||
'if [ -d /cache ]; then if ! [ -d /cache/google-android-ndk-installer ]; then mkdir /cache/google-android-ndk-installer; fi; ln -s /cache/google-android-ndk-installer /var/cache/; fi',
|
||||
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake g++ git ninja-build ccache tar xz-utils google-android-ndk-installer ' + static_build_deps,
|
||||
]
|
||||
+ android_build_steps('armeabi-v7a', cmake_extra='-DARCH=armv7-a -DARCH_ID=arm32')
|
||||
+ android_build_steps('arm64-v8a', cmake_extra='-DARCH=armv8-a -DARCH_ID=arm64')
|
||||
+ android_build_steps('x86_64', cmake_extra='-DARCH="x86-64 -msse4.2 -mpopcnt" -DARCH_ID=x86-64')
|
||||
+ android_build_steps('x86', cmake_extra='-DARCH="i686 -mssse3 -mfpmath=sse" -DARCH_ID=i386')
|
||||
+ [
|
||||
'./utils/build_scripts/drone-android-static-upload.sh armeabi-v7a arm64-v8a x86_64 x86'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// iOS build
|
||||
{ name: 'iOS wallet_api', kind: 'pipeline', type: 'exec', platform: { os: 'darwin', arch: 'amd64' },
|
||||
steps: [{
|
||||
name: 'build',
|
||||
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
|
||||
commands: submodules_commands + [
|
||||
'mkdir -p build/{arm64,sim64}',
|
||||
'cd build/arm64',
|
||||
'cmake ../.. -G Ninja ' +
|
||||
'-DCMAKE_TOOLCHAIN_FILE=../../cmake/ios.toolchain.cmake -DPLATFORM=OS -DDEPLOYMENT_TARGET=11 -DENABLE_VISIBILITY=ON -DENABLE_BITCODE=OFF ' +
|
||||
'-DSTATIC=ON -DBUILD_STATIC_DEPS=ON -DUSE_LTO=OFF -DCMAKE_BUILD_TYPE=Release ' +
|
||||
'-DRANDOMX_ENABLE_JIT=OFF -DCMAKE_CXX_FLAGS=-fcolor-diagnostics',
|
||||
'ninja -j6 -v wallet_merged',
|
||||
'cd ../sim64',
|
||||
'cmake ../.. -G Ninja ' +
|
||||
'-DCMAKE_TOOLCHAIN_FILE=../../cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR64 -DDEPLOYMENT_TARGET=11 -DENABLE_VISIBILITY=ON -DENABLE_BITCODE=OFF ' +
|
||||
'-DSTATIC=ON -DBUILD_STATIC_DEPS=ON -DUSE_LTO=OFF -DCMAKE_BUILD_TYPE=Release ' +
|
||||
'-DRANDOMX_ENABLE_JIT=OFF -DCMAKE_CXX_FLAGS=-fcolor-diagnostics',
|
||||
'ninja -j6 -v wallet_merged',
|
||||
'cd ../..',
|
||||
'./utils/build_scripts/drone-ios-static-upload.sh'
|
||||
]
|
||||
}]
|
||||
},
|
||||
]
|
||||
|
|
|
@ -25,3 +25,6 @@
|
|||
[submodule "external/cpr"]
|
||||
path = external/cpr
|
||||
url = https://github.com/whoshuu/cpr.git
|
||||
[submodule "external/ghc-filesystem"]
|
||||
path = external/ghc-filesystem
|
||||
url = https://github.com/gulrak/filesystem.git
|
||||
|
|
|
@ -33,15 +33,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
|
||||
list(INSERT CMAKE_MODULE_PATH 0
|
||||
"${CMAKE_SOURCE_DIR}/cmake")
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckLinkerFlag)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if (IOS)
|
||||
INCLUDE(CmakeLists_IOS.txt)
|
||||
endif()
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
|
@ -60,7 +51,7 @@ message(STATUS "CMake version ${CMAKE_VERSION}")
|
|||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)")
|
||||
|
||||
project(loki
|
||||
VERSION 8.1.2
|
||||
VERSION 8.1.3
|
||||
LANGUAGES CXX C)
|
||||
set(LOKI_RELEASE_CODENAME "Salty Saga")
|
||||
|
||||
|
@ -85,6 +76,12 @@ set(CMAKE_C_EXTENSIONS OFF)
|
|||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CheckLinkerFlag)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
function (add_c_flag_if_supported flag var)
|
||||
string(REPLACE "-" "_" supported ${flag}_c)
|
||||
check_c_compiler_flag(${flag} ${supported})
|
||||
|
@ -147,7 +144,7 @@ endif()
|
|||
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release AND NOT MINGW)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release AND NOT MINGW AND NOT ANDROID)
|
||||
set(USE_LTO_DEFAULT ON)
|
||||
else()
|
||||
set(USE_LTO_DEFAULT OFF)
|
||||
|
@ -284,6 +281,7 @@ if(NOT MANUAL_SUBMODULES)
|
|||
check_submodule(external/googletest)
|
||||
endif()
|
||||
check_submodule(external/uWebSockets uSockets)
|
||||
check_submodule(external/ghc-filesystem)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -335,6 +333,8 @@ endif()
|
|||
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
||||
# set(BSDI TRUE)
|
||||
|
||||
include(cmake/check_for_std_filesystem.cmake)
|
||||
|
||||
include_directories(external/rapidjson/include src external)
|
||||
|
||||
if(APPLE)
|
||||
|
@ -742,7 +742,7 @@ else()
|
|||
|
||||
endif(ARM)
|
||||
|
||||
if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS)
|
||||
if(ANDROID OR IOS)
|
||||
#From Android 5: "only position independent executables (PIE) are supported"
|
||||
message(STATUS "Enabling PIE executable")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
|
||||
|
@ -792,10 +792,8 @@ set(Boost_USE_MULTITHREADED TRUE) # Needed for macOS, at least, and won't hurt e
|
|||
|
||||
if(BUILD_STATIC_DEPS)
|
||||
# StaticBuild.cmake sets Boost targets up for us
|
||||
elseif (WIN32)
|
||||
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system filesystem thread date_time serialization program_options locale)
|
||||
else()
|
||||
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system filesystem thread date_time serialization program_options)
|
||||
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system thread serialization program_options)
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
|
||||
|
@ -947,9 +945,6 @@ if(BUILD_DOCUMENTATION)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# when ON - will install libwallet_merged into "lib"
|
||||
option(BUILD_GUI_DEPS "Build GUI dependencies." OFF)
|
||||
|
||||
find_package(PythonInterp)
|
||||
find_program(iwyu_tool_path NAMES iwyu_tool.py iwyu_tool)
|
||||
if (iwyu_tool_path AND PYTHONINTERP_FOUND)
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
# Portions Copyright (c) 2017-2018, The Monero Project
|
||||
# This file is based off of the https://code.google.com/archive/p/ios-cmake/
|
||||
# It has been altered for Monero iOS development
|
||||
#
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# IOS_PLATFORM = OS (default) or SIMULATOR or SIMULATOR64
|
||||
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
|
||||
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
|
||||
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
|
||||
#
|
||||
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
|
||||
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
|
||||
# If set manually, it will override the default location and force the user of a particular Developer Platform
|
||||
#
|
||||
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
|
||||
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
|
||||
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
|
||||
# If set manually, this will force the use of a specific SDK version
|
||||
|
||||
|
||||
# Standard settings
|
||||
set (CMAKE_SYSTEM_NAME Darwin)
|
||||
set (CMAKE_SYSTEM_VERSION 1)
|
||||
set (UNIX True)
|
||||
set (APPLE True)
|
||||
set (IOS True)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D IOS")
|
||||
|
||||
# Required as of cmake 2.8.10
|
||||
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
|
||||
|
||||
# Determine the cmake host system version so we know where to find the iOS SDKs
|
||||
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
||||
if (CMAKE_UNAME)
|
||||
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
||||
endif (CMAKE_UNAME)
|
||||
|
||||
# Force the compilers to gcc for iOS
|
||||
include (CMakeForceCompiler)
|
||||
# set (MAKE_C_COMPILER "/usr/bin/gcc Apple")
|
||||
# set (CMAKE_CXX_COMPILER "/usr/bin/g++ Apple")
|
||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||
|
||||
# Skip the platform compiler checks for cross compiling
|
||||
set (CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set (CMAKE_C_COMPILER_WORKS TRUE)
|
||||
|
||||
# All iOS/Darwin specific settings - some may be redundant
|
||||
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set (CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set (CMAKE_MODULE_EXISTS 1)
|
||||
set (CMAKE_DL_LIBS "")
|
||||
|
||||
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
# Hidden visibilty is required for cxx on iOS
|
||||
set (CMAKE_C_FLAGS_INIT "-fno-stack-check")
|
||||
set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden -fno-stack-check")
|
||||
|
||||
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||
|
||||
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
||||
|
||||
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
||||
if (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM "OS")
|
||||
endif (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
||||
|
||||
# Setup building for arm64 or not
|
||||
if (NOT DEFINED BUILD_ARM64)
|
||||
set (BUILD_ARM64 true)
|
||||
endif (NOT DEFINED BUILD_ARM64)
|
||||
set (BUILD_ARM64 ${BUILD_ARM64} CACHE STRING "Build arm64 arch or not")
|
||||
|
||||
# Check the platform selection and setup for developer root
|
||||
if (${IOS_PLATFORM} STREQUAL "OS")
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
||||
set (SIMULATOR true)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
|
||||
set (SIMULATOR true)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||
else (${IOS_PLATFORM} STREQUAL "OS")
|
||||
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
|
||||
endif (${IOS_PLATFORM} STREQUAL "OS")
|
||||
|
||||
# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
|
||||
# Note Xcode 4.3 changed the installation location, choose the most recent one available
|
||||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
|
||||
set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||
set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||
if (EXISTS ${XCODE_POST_43_ROOT})
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
||||
elseif(EXISTS ${XCODE_PRE_43_ROOT})
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
||||
endif (EXISTS ${XCODE_POST_43_ROOT})
|
||||
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
|
||||
|
||||
# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
|
||||
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
|
||||
if (_CMAKE_IOS_SDKS)
|
||||
list (SORT _CMAKE_IOS_SDKS)
|
||||
list (REVERSE _CMAKE_IOS_SDKS)
|
||||
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
|
||||
else (_CMAKE_IOS_SDKS)
|
||||
message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
|
||||
endif (_CMAKE_IOS_SDKS)
|
||||
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
|
||||
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
||||
|
||||
# Set the sysroot default to the most recent SDK
|
||||
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
||||
|
||||
# set the architecture for iOS
|
||||
if (NOT DEFINED ARCH)
|
||||
set (ARCH armv7)
|
||||
endif()
|
||||
set (IOS_ARCH ${ARCH})
|
||||
|
||||
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
|
||||
message(STATUS "ios arch: ${IOS_ARCH}")
|
||||
|
||||
# Set the find root to the iOS developer roots and to user defined paths
|
||||
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
|
||||
|
||||
# default to searching for frameworks first
|
||||
set (CMAKE_FIND_FRAMEWORK FIRST)
|
||||
|
||||
# set up the default search directories for frameworks
|
||||
set (CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
|
||||
${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
|
||||
${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
|
||||
)
|
||||
|
||||
message(STATUS "IOS CMAKE conf finished")
|
|
@ -78,8 +78,7 @@ Install all dependencies at once on Debian/Ubuntu:
|
|||
|
||||
```
|
||||
sudo apt update && \
|
||||
sudo apt install g++ cmake pkg-config libboost-filesystem-dev libboost-thread-dev libboost-date-time-dev \
|
||||
libboost-serialization-dev libboost-program-options-dev \
|
||||
sudo apt install g++ cmake pkg-config libboost-thread-dev libboost-serialization-dev libboost-program-options-dev \
|
||||
libssl-dev libzmq3-dev libsqlite3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline-dev \
|
||||
libldns-dev libexpat1-dev doxygen graphviz libsqlite3-dev libcurl4-openssl-dev
|
||||
```
|
||||
|
|
|
@ -146,7 +146,7 @@ if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON AND Protobuf_COMPILE_T
|
|||
message(STATUS "Trezor compatible LibUSB found")
|
||||
endif()
|
||||
|
||||
if (BUILD_GUI_DEPS)
|
||||
if (ANDROID)
|
||||
|
||||
if (Protobuf_LIBRARY)
|
||||
list(APPEND TREZOR_DEP_LIBS ${Protobuf_LIBRARY})
|
||||
|
|
|
@ -5,24 +5,24 @@
|
|||
|
||||
set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads")
|
||||
|
||||
set(OPENSSL_VERSION 1.1.1g CACHE STRING "openssl version")
|
||||
set(OPENSSL_VERSION 1.1.1h CACHE STRING "openssl version")
|
||||
set(OPENSSL_MIRROR ${LOCAL_MIRROR} https://www.openssl.org/source CACHE STRING "openssl download mirror(s)")
|
||||
set(OPENSSL_SOURCE openssl-${OPENSSL_VERSION}.tar.gz)
|
||||
set(OPENSSL_HASH SHA256=ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
|
||||
set(OPENSSL_HASH SHA256=5c9ca8774bd7b03e5784f26ae9e9e6d749c9da2438545077e6b3d755a06595d9
|
||||
CACHE STRING "openssl source hash")
|
||||
|
||||
set(EXPAT_VERSION 2.2.9 CACHE STRING "expat version")
|
||||
set(EXPAT_VERSION 2.2.10 CACHE STRING "expat version")
|
||||
string(REPLACE "." "_" EXPAT_TAG "R_${EXPAT_VERSION}")
|
||||
set(EXPAT_MIRROR ${LOCAL_MIRROR} https://github.com/libexpat/libexpat/releases/download/${EXPAT_TAG}
|
||||
CACHE STRING "expat download mirror(s)")
|
||||
set(EXPAT_SOURCE expat-${EXPAT_VERSION}.tar.xz)
|
||||
set(EXPAT_HASH SHA512=e082874efcc4b00709e2c0192c88fb15dfc4f33fc3a2b09e619b010ea93baaf7e7572683f738463db0ce2350cab3de48a0c38af6b74d1c4f5a9e311f499edab0
|
||||
set(EXPAT_HASH SHA512=a8e0c8a9cf7e6fbacdc6e709f3c99c533ab550fba52557d24259bb8b360f9697624c7500c0e9886fa57ee2b529aadd0d1835d66fe8112e15c20df75cd3eb090f
|
||||
CACHE STRING "expat source hash")
|
||||
|
||||
set(UNBOUND_VERSION 1.11.0 CACHE STRING "unbound version")
|
||||
set(UNBOUND_VERSION 1.12.0 CACHE STRING "unbound version")
|
||||
set(UNBOUND_MIRROR ${LOCAL_MIRROR} https://nlnetlabs.nl/downloads/unbound CACHE STRING "unbound download mirror(s)")
|
||||
set(UNBOUND_SOURCE unbound-${UNBOUND_VERSION}.tar.gz)
|
||||
set(UNBOUND_HASH SHA256=9f2f0798f76eb8f30feaeda7e442ceed479bc54db0e3ac19c052d68685e51ef7
|
||||
set(UNBOUND_HASH SHA256=5b9253a97812f24419bf2e6b3ad28c69287261cf8c8fa79e3e9f6d3bf7ef5835
|
||||
CACHE STRING "unbound source hash")
|
||||
|
||||
set(BOOST_VERSION 1.74.0 CACHE STRING "boost version")
|
||||
|
@ -125,6 +125,29 @@ file(MAKE_DIRECTORY ${DEPS_DESTDIR}/include)
|
|||
|
||||
set(deps_cc "${CMAKE_C_COMPILER}")
|
||||
set(deps_cxx "${CMAKE_CXX_COMPILER}")
|
||||
if (ANDROID)
|
||||
if(NOT ANDROID_TOOLCHAIN_NAME)
|
||||
message(FATAL_ERROR "ANDROID_TOOLCHAIN_NAME not set; did you run with the proper android toolchain options?")
|
||||
endif()
|
||||
if(CMAKE_ANDROID_ARCH_ABI MATCHES x86_64)
|
||||
set(android_clang x86_64-linux-android${ANDROID_PLATFORM_LEVEL}-clang)
|
||||
set(openssl_machine x86_64)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES x86)
|
||||
set(android_clang i686-linux-android${ANDROID_PLATFORM_LEVEL}-clang)
|
||||
set(openssl_machine i686)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES armeabi-v7a)
|
||||
set(android_clang armv7a-linux-androideabi${ANDROID_PLATFORM_LEVEL}-clang)
|
||||
set(openssl_machine armv7)
|
||||
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES arm64-v8a)
|
||||
set(android_clang aarch64-linux-android${ANDROID_PLATFORM_LEVEL}-clang)
|
||||
set(openssl_machine aarch64)
|
||||
else()
|
||||
message(FATAL_ERROR "Don't know how to build for android arch abi ${CMAKE_ANDROID_ARCH_ABI}")
|
||||
endif()
|
||||
set(deps_cc "${ANDROID_TOOLCHAIN_ROOT}/bin/${android_clang}")
|
||||
set(deps_cxx "${deps_cc}++")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_LAUNCHER)
|
||||
set(deps_cc "${CMAKE_C_COMPILER_LAUNCHER} ${deps_cc}")
|
||||
endif()
|
||||
|
@ -157,20 +180,38 @@ else()
|
|||
endif()
|
||||
|
||||
set(cross_host "")
|
||||
set(cross_rc "")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(cross_host "--host=${ARCH_TRIPLET}")
|
||||
if (ARCH_TRIPLET MATCHES mingw AND CMAKE_RC_COMPILER)
|
||||
set(cross_rc "WINDRES=${CMAKE_RC_COMPILER}")
|
||||
set(cross_extra "")
|
||||
if (ANDROID)
|
||||
set(cross_host "--host=${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
set(cross_extra "LD=${ANDROID_TOOLCHAIN_ROOT}/bin/${CMAKE_LIBRARY_ARCHITECTURE}-ld" "RANLIB=${CMAKE_RANLIB}" "AR=${CMAKE_AR}")
|
||||
elseif(CMAKE_CROSSCOMPILING)
|
||||
if(APPLE)
|
||||
set(cross_host "--host=${APPLE_TARGET_TRIPLE}")
|
||||
else()
|
||||
set(cross_host "--host=${ARCH_TRIPLET}")
|
||||
if (ARCH_TRIPLET MATCHES mingw AND CMAKE_RC_COMPILER)
|
||||
set(cross_extra "WINDRES=${CMAKE_RC_COMPILER}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
set(deps_CFLAGS "-O2 ${flto}")
|
||||
set(deps_CXXFLAGS "-O2 ${flto}")
|
||||
set(deps_noarch_CFLAGS "${deps_CFLAGS}")
|
||||
set(deps_noarch_CXXFLAGS "${deps_CXXFLAGS}")
|
||||
|
||||
if(APPLE)
|
||||
set(deps_CFLAGS "${deps_CFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
set(deps_CXXFLAGS "${deps_CXXFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
foreach(lang C CXX)
|
||||
string(APPEND deps_${lang}FLAGS " ${CMAKE_${lang}_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT} ${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
|
||||
set(deps_noarch_${lang}FLAGS "${deps_${lang}FLAGS}")
|
||||
|
||||
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
string(APPEND deps_${lang}FLAGS " -arch ${arch}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Builds a target; takes the target name (e.g. "readline") and builds it in an external project with
|
||||
|
@ -180,13 +221,14 @@ endif()
|
|||
set(build_def_DEPENDS "")
|
||||
set(build_def_PATCH_COMMAND "")
|
||||
set(build_def_CONFIGURE_COMMAND ./configure ${cross_host} --disable-shared --prefix=${DEPS_DESTDIR} --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}" ${cross_rc})
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}" ${cross_extra})
|
||||
set(build_def_BUILD_COMMAND make)
|
||||
set(build_def_INSTALL_COMMAND make install)
|
||||
set(build_def_BUILD_BYPRODUCTS ${DEPS_DESTDIR}/lib/lib___TARGET___.a ${DEPS_DESTDIR}/include/___TARGET___.h)
|
||||
set(build_dep_TARGET_SUFFIX "")
|
||||
|
||||
function(build_external target)
|
||||
set(options DEPENDS PATCH_COMMAND CONFIGURE_COMMAND BUILD_COMMAND INSTALL_COMMAND BUILD_BYPRODUCTS)
|
||||
set(options TARGET_SUFFIX DEPENDS PATCH_COMMAND CONFIGURE_COMMAND BUILD_COMMAND INSTALL_COMMAND BUILD_BYPRODUCTS)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "${options}")
|
||||
foreach(o ${options})
|
||||
if(NOT DEFINED arg_${o})
|
||||
|
@ -197,7 +239,7 @@ function(build_external target)
|
|||
|
||||
string(TOUPPER "${target}" prefix)
|
||||
expand_urls(urls ${${prefix}_SOURCE} ${${prefix}_MIRROR})
|
||||
ExternalProject_Add("${target}_external"
|
||||
ExternalProject_Add("${target}${arg_TARGET_SUFFIX}_external"
|
||||
DEPENDS ${arg_DEPENDS}
|
||||
BUILD_IN_SOURCE ON
|
||||
PREFIX ${DEPS_SOURCEDIR}
|
||||
|
@ -215,7 +257,7 @@ endfunction()
|
|||
|
||||
|
||||
build_external(zlib
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" ./configure --prefix=${DEPS_DESTDIR} --static
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS} -fPIC" ${cross_extra} ./configure --prefix=${DEPS_DESTDIR} --static
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libz.a
|
||||
${DEPS_DESTDIR}/include/zlib.h
|
||||
|
@ -224,17 +266,31 @@ add_static_target(zlib zlib_external libz.a)
|
|||
|
||||
|
||||
|
||||
set(openssl_configure ./config)
|
||||
set(openssl_system_env "")
|
||||
set(openssl_cc "${deps_cc}")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32)
|
||||
set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER})
|
||||
elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32)
|
||||
set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER})
|
||||
elseif(ANDROID)
|
||||
set(openssl_system_env SYSTEM=Linux MACHINE=${openssl_machine} ${cross_extra})
|
||||
set(openssl_extra_opts no-asm)
|
||||
elseif(IOS)
|
||||
get_filename_component(apple_toolchain "${CMAKE_C_COMPILER}" DIRECTORY)
|
||||
get_filename_component(apple_sdk "${CMAKE_OSX_SYSROOT}" NAME)
|
||||
if(NOT ${apple_toolchain} MATCHES Xcode OR NOT ${apple_sdk} MATCHES "iPhone(OS|Simulator)")
|
||||
message(FATAL_ERROR "didn't find your toolchain and sdk correctly from ${CMAKE_C_COMPILER}/${CMAKE_OSX_SYSROOT}: found toolchain=${apple_toolchain}, sdk=${apple_sdk}")
|
||||
endif()
|
||||
set(openssl_system_env CROSS_COMPILE=${apple_toolchain}/ CROSS_TOP=${CMAKE_DEVELOPER_ROOT} CROSS_SDK=${apple_sdk})
|
||||
set(openssl_configure ./Configure iphoneos-cross)
|
||||
set(openssl_cc "clang")
|
||||
endif()
|
||||
endif()
|
||||
build_external(openssl
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${deps_cc} ${openssl_system_env} ./config
|
||||
--prefix=${DEPS_DESTDIR} no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${openssl_cc} ${openssl_system_env} ${openssl_configure}
|
||||
--prefix=${DEPS_DESTDIR} ${openssl_extra_opts} no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
|
||||
no-heartbeats no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl2 no-ssl3
|
||||
no-static-engine no-tests no-weak-ssl-ciphers no-zlib-dynamic "CFLAGS=${deps_CFLAGS}"
|
||||
INSTALL_COMMAND make install_sw
|
||||
|
@ -257,13 +313,19 @@ build_external(expat
|
|||
add_static_target(expat expat_external libexpat.a)
|
||||
|
||||
|
||||
set(unbound_extra)
|
||||
if(APPLE AND IOS)
|
||||
# I have no idea why this is necessary: without this it runs `clang -E` which should work, but
|
||||
# doesn't because... hurray ios is wonderful?
|
||||
set(unbound_extra CPP=cpp)
|
||||
endif()
|
||||
build_external(unbound
|
||||
DEPENDS openssl_external expat_external
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
|
||||
--enable-static --with-libunbound-only --with-pic
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_extra} --prefix=${DEPS_DESTDIR} --disable-shared
|
||||
--enable-static --with-libunbound-only --with-pic --disable-gost
|
||||
--$<IF:$<BOOL:${USE_LTO}>,enable,disable>-flto --with-ssl=${DEPS_DESTDIR}
|
||||
--with-libexpat=${DEPS_DESTDIR}
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" ${unbound_extra}
|
||||
)
|
||||
add_static_target(libunbound unbound_external libunbound.a)
|
||||
if(WIN32)
|
||||
|
@ -289,6 +351,8 @@ if(CMAKE_CROSSCOMPILING)
|
|||
else()
|
||||
list(APPEND boost_extra "address-model=32")
|
||||
endif()
|
||||
elseif(ANDROID)
|
||||
set(boost_bootstrap_cxx "CXX=c++")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
|
@ -298,15 +362,33 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
|
|||
else()
|
||||
message(FATAL_ERROR "don't know how to build boost with ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/user-config.bjam "using ${boost_toolset} : : ${deps_cxx} ;")
|
||||
|
||||
if(IOS)
|
||||
set(boost_arch_flags)
|
||||
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
string(APPEND boost_arch_flags " -arch ${arch}")
|
||||
endforeach()
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/user-config.bjam "using darwin : : ${deps_cxx} :
|
||||
<architecture>arm
|
||||
<target-os>iphone
|
||||
<compileflags>\"-fPIC ${boost_arch_flags} ${CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET} -isysroot ${CMAKE_OSX_SYSROOT}\"
|
||||
<threading>multi
|
||||
;")
|
||||
else()
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/user-config.bjam "using ${boost_toolset} : : ${deps_cxx} ;")
|
||||
endif()
|
||||
|
||||
set(boost_patch_commands "")
|
||||
if(APPLE AND BOOST_VERSION VERSION_LESS 1.74.0)
|
||||
if(IOS)
|
||||
set(boost_patch_commands PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/utils/build_scripts/boost-darwin-libtool-path.patch)
|
||||
elseif(APPLE AND BOOST_VERSION VERSION_LESS 1.74.0)
|
||||
set(boost_patch_commands PATCH_COMMAND patch -p1 -d tools/build -i ${PROJECT_SOURCE_DIR}/utils/build_scripts/boostorg-build-pr560-macos-build-fix.patch)
|
||||
endif()
|
||||
|
||||
set(boost_buildflags "cxxflags=-fPIC")
|
||||
if(APPLE)
|
||||
if(IOS)
|
||||
set(boost_buildflags)
|
||||
elseif(APPLE)
|
||||
set(boost_buildflags "cxxflags=-fPIC -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}" "cflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
|
||||
|
@ -316,7 +398,7 @@ build_external(boost
|
|||
CONFIGURE_COMMAND
|
||||
${CMAKE_COMMAND} -E env ${boost_bootstrap_cxx}
|
||||
./bootstrap.sh --without-icu --prefix=${DEPS_DESTDIR} --with-toolset=${boost_toolset}
|
||||
--with-libraries=filesystem,program_options,system,thread,date_time,serialization,locale,atomic
|
||||
--with-libraries=program_options,system,thread,serialization
|
||||
BUILD_COMMAND true
|
||||
INSTALL_COMMAND
|
||||
./b2 -d0 variant=release link=static runtime-link=static optimization=speed ${boost_extra}
|
||||
|
@ -324,10 +406,6 @@ build_external(boost
|
|||
--disable-icu --user-config=${CMAKE_CURRENT_BINARY_DIR}/user-config.bjam
|
||||
install
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libboost_atomic.a
|
||||
${DEPS_DESTDIR}/lib/libboost_date_time.a
|
||||
${DEPS_DESTDIR}/lib/libboost_filesystem.a
|
||||
${DEPS_DESTDIR}/lib/libboost_locale.a
|
||||
${DEPS_DESTDIR}/lib/libboost_program_options.a
|
||||
${DEPS_DESTDIR}/lib/libboost_serialization.a
|
||||
${DEPS_DESTDIR}/lib/libboost_system.a
|
||||
|
@ -338,22 +416,23 @@ add_library(boost_core INTERFACE)
|
|||
add_dependencies(boost_core INTERFACE boost_external)
|
||||
target_include_directories(boost_core SYSTEM INTERFACE ${DEPS_DESTDIR}/include)
|
||||
add_library(Boost::boost ALIAS boost_core)
|
||||
foreach(boostlib atomic date_time filesystem locale program_options serialization system thread)
|
||||
foreach(boostlib program_options serialization system thread)
|
||||
add_static_target(Boost::${boostlib} boost_external libboost_${boostlib}.a)
|
||||
target_link_libraries(Boost::${boostlib} INTERFACE boost_core)
|
||||
endforeach()
|
||||
target_link_libraries(Boost::locale INTERFACE Boost::thread)
|
||||
set(Boost_FOUND ON)
|
||||
set(Boost_VERSION ${BOOST_VERSION})
|
||||
|
||||
|
||||
|
||||
build_external(sqlite3)
|
||||
build_external(sqlite3
|
||||
BUILD_COMMAND true
|
||||
INSTALL_COMMAND make install-includeHEADERS install-libLTLIBRARIES)
|
||||
add_static_target(sqlite3 sqlite3_external libsqlite3.a)
|
||||
|
||||
|
||||
|
||||
if (NOT WIN32)
|
||||
if (NOT (WIN32 OR ANDROID OR IOS))
|
||||
build_external(ncurses
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --without-debug --without-ada
|
||||
--without-cxx-binding --without-cxx --without-ticlib --without-tic --without-progs
|
||||
|
@ -394,7 +473,7 @@ endif()
|
|||
|
||||
|
||||
|
||||
if(APPLE OR WIN32)
|
||||
if(APPLE OR WIN32 OR ANDROID OR IOS)
|
||||
add_library(libudev INTERFACE)
|
||||
set(maybe_eudev "")
|
||||
else()
|
||||
|
@ -411,53 +490,65 @@ endif()
|
|||
|
||||
|
||||
|
||||
build_external(libusb
|
||||
CONFIGURE_COMMAND autoreconf -ivf && ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --disable-shared --disable-udev --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}"
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libusb-1.0.a
|
||||
${DEPS_DESTDIR}/include/libusb-1.0
|
||||
${DEPS_DESTDIR}/include/libusb-1.0/libusb.h
|
||||
)
|
||||
add_static_target(libusb_vendor libusb_external libusb-1.0.a)
|
||||
set_target_properties(libusb_vendor PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${DEPS_DESTDIR}/include/libusb-1.0)
|
||||
if(NOT (ANDROID OR IOS))
|
||||
build_external(libusb
|
||||
CONFIGURE_COMMAND autoreconf -ivf && ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --disable-shared --disable-udev --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}"
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libusb-1.0.a
|
||||
${DEPS_DESTDIR}/include/libusb-1.0
|
||||
${DEPS_DESTDIR}/include/libusb-1.0/libusb.h
|
||||
)
|
||||
add_static_target(libusb_vendor libusb_external libusb-1.0.a)
|
||||
set_target_properties(libusb_vendor PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${DEPS_DESTDIR}/include/libusb-1.0)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(hidapi_libusb_lib libhidapi-libusb.a)
|
||||
set(hidapi_lib_byproducts ${DEPS_DESTDIR}/lib/libhidapi-libusb.a ${DEPS_DESTDIR}/lib/libhidapi-hidraw.a)
|
||||
if(ANDROID OR IOS)
|
||||
set(HIDAPI_FOUND FALSE)
|
||||
else()
|
||||
set(hidapi_libusb_lib libhidapi.a)
|
||||
set(hidapi_lib_byproducts ${DEPS_DESTDIR}/lib/libhidapi.a)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(hidapi_libusb_lib libhidapi-libusb.a)
|
||||
set(hidapi_lib_byproducts ${DEPS_DESTDIR}/lib/libhidapi-libusb.a ${DEPS_DESTDIR}/lib/libhidapi-hidraw.a)
|
||||
else()
|
||||
set(hidapi_libusb_lib libhidapi.a)
|
||||
set(hidapi_lib_byproducts ${DEPS_DESTDIR}/lib/libhidapi.a)
|
||||
endif()
|
||||
build_external(hidapi
|
||||
DEPENDS ${maybe_eudev} libusb_external
|
||||
CONFIGURE_COMMAND autoreconf -ivf && ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --disable-shared --enable-static --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}"
|
||||
${cross_extra}
|
||||
"libudev_CFLAGS=-I${DEPS_DESTDIR}/include" "libudev_LIBS=-L${DEPS_DESTDIR}/lib -ludev"
|
||||
"libusb_CFLAGS=-I${DEPS_DESTDIR}/include/libusb-1.0" "libusb_LIBS=-L${DEPS_DESTDIR}/lib -lusb-1.0"
|
||||
BUILD_BYPRODUCTS
|
||||
${hidapi_lib_byproducts}
|
||||
${DEPS_DESTDIR}/include/hidapi
|
||||
${DEPS_DESTDIR}/include/hidapi/hidapi.h
|
||||
)
|
||||
set(HIDAPI_FOUND TRUE)
|
||||
add_static_target(hidapi_libusb hidapi_external ${hidapi_libusb_lib})
|
||||
set(hidapi_links "libusb_vendor;libudev")
|
||||
if(WIN32)
|
||||
list(APPEND hidapi_links setupapi)
|
||||
endif()
|
||||
set_target_properties(hidapi_libusb PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${hidapi_links}"
|
||||
INTERFACE_COMPILE_DEFINITIONS HAVE_HIDAPI)
|
||||
endif()
|
||||
build_external(hidapi
|
||||
DEPENDS ${maybe_eudev} libusb_external
|
||||
CONFIGURE_COMMAND autoreconf -ivf && ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --disable-shared --enable-static --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}"
|
||||
"libudev_CFLAGS=-I${DEPS_DESTDIR}/include" "libudev_LIBS=-L${DEPS_DESTDIR}/lib -ludev"
|
||||
"libusb_CFLAGS=-I${DEPS_DESTDIR}/include/libusb-1.0" "libusb_LIBS=-L${DEPS_DESTDIR}/lib -lusb-1.0"
|
||||
BUILD_BYPRODUCTS
|
||||
${hidapi_lib_byproducts}
|
||||
${DEPS_DESTDIR}/include/hidapi
|
||||
${DEPS_DESTDIR}/include/hidapi/hidapi.h
|
||||
)
|
||||
set(HIDAPI_FOUND TRUE)
|
||||
add_static_target(hidapi_libusb hidapi_external ${hidapi_libusb_lib})
|
||||
set(hidapi_links "libusb_vendor;libudev")
|
||||
if(WIN32)
|
||||
list(APPEND hidapi_links setupapi)
|
||||
|
||||
|
||||
|
||||
set(protobuf_extra "")
|
||||
if(ANDROID)
|
||||
set(protobuf_extra "LDFLAGS=-llog")
|
||||
endif()
|
||||
set_target_properties(hidapi_libusb PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${hidapi_links}"
|
||||
INTERFACE_COMPILE_DEFINITIONS HAVE_HIDAPI)
|
||||
|
||||
|
||||
|
||||
build_external(protobuf
|
||||
CONFIGURE_COMMAND
|
||||
./configure ${cross_host} --disable-shared --prefix=${DEPS_DESTDIR} --with-pic
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}"
|
||||
${cross_extra} ${protobuf_extra}
|
||||
"CPP=${deps_cc} -E" "CXXCPP=${deps_cxx} -E"
|
||||
"CC_FOR_BUILD=${deps_cc}" "CXX_FOR_BUILD=${deps_cxx}" # Thanks Google for making people hunt for undocumented magic variables
|
||||
BUILD_BYPRODUCTS
|
||||
|
@ -478,13 +569,21 @@ add_static_target(sodium sodium_external libsodium.a)
|
|||
if(ZMQ_VERSION VERSION_LESS 4.3.4 AND CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
set(zmq_patch PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/utils/build_scripts/libzmq-mingw-closesocket.patch)
|
||||
endif()
|
||||
|
||||
set(zmq_cross_host "${cross_host}")
|
||||
if(IOS AND cross_host MATCHES "-ios$")
|
||||
# zmq doesn't like "-ios" for the host, so replace it with -darwin
|
||||
string(REGEX REPLACE "-ios$" "-darwin" zmq_cross_host ${cross_host})
|
||||
endif()
|
||||
|
||||
build_external(zmq
|
||||
DEPENDS sodium_external
|
||||
${zmq_patch}
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --enable-static --disable-shared
|
||||
CONFIGURE_COMMAND ./configure ${zmq_cross_host} --prefix=${DEPS_DESTDIR} --enable-static --disable-shared
|
||||
--disable-curve-keygen --enable-curve --disable-drafts --disable-libunwind --with-libsodium
|
||||
--without-pgm --without-norm --without-vmci --without-docs --with-pic --disable-Werror
|
||||
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=-fstack-protector ${deps_CFLAGS}" "CXXFLAGS=-fstack-protector ${deps_CXXFLAGS}"
|
||||
${cross_extra}
|
||||
"sodium_CFLAGS=-I${DEPS_DESTDIR}/include" "sodium_LIBS=-L${DEPS_DESTDIR}/lib -lsodium"
|
||||
)
|
||||
add_static_target(libzmq zmq_external libzmq.a)
|
||||
|
@ -500,33 +599,83 @@ set_target_properties(libzmq PROPERTIES
|
|||
|
||||
|
||||
|
||||
set(curl_LIBS "")
|
||||
set(curl_extra)
|
||||
if(WIN32)
|
||||
set(curl_ssl_opts --without-ssl --with-schannel)
|
||||
elseif(APPLE)
|
||||
set(curl_ssl_opts --without-ssl --with-secure-transport)
|
||||
if(IOS)
|
||||
# This CPP crap shouldn't be necessary but is because Apple's toolchain is trash
|
||||
set(curl_extra "LDFLAGS=-L${DEPS_DESTDIR}/lib -isysroot ${CMAKE_OSX_SYSROOT}" CPP=cpp)
|
||||
endif()
|
||||
else()
|
||||
set(curl_ssl_opts --with-ssl=${DEPS_DESTDIR})
|
||||
set(curl_LIBS "LIBS=-pthread")
|
||||
set(curl_extra "LIBS=-pthread")
|
||||
endif()
|
||||
|
||||
set(curl_arches default)
|
||||
set(curl_lib_outputs)
|
||||
if(IOS)
|
||||
# On iOS things get a little messy: curl won't build a multi-arch library (with `clang -arch arch1
|
||||
# -arch arch2`) so we have to build them separately then glue them together if we're building
|
||||
# multiple.
|
||||
set(curl_arches ${CMAKE_OSX_ARCHITECTURES})
|
||||
list(GET curl_arches 0 curl_arch0)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES num_arches)
|
||||
endif()
|
||||
|
||||
foreach(curl_arch ${curl_arches})
|
||||
set(curl_target_suffix "")
|
||||
set(curl_prefix "${DEPS_DESTDIR}")
|
||||
if(curl_arch STREQUAL "default")
|
||||
set(curl_cflags_extra "")
|
||||
elseif(IOS)
|
||||
set(cflags_extra " -arch ${curl_arch}")
|
||||
if(num_arches GREATER 1)
|
||||
set(curl_target_suffix "-${curl_arch}")
|
||||
set(curl_prefix "${DEPS_DESTDIR}/tmp/${curl_arch}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "unexpected curl_arch=${curl_arch}")
|
||||
endif()
|
||||
|
||||
build_external(curl
|
||||
TARGET_SUFFIX ${curl_target_suffix}
|
||||
DEPENDS openssl_external zlib_external
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_extra} --prefix=${curl_prefix} --disable-shared
|
||||
--enable-static --disable-ares --disable-ftp --disable-ldap --disable-laps --disable-rtsp
|
||||
--disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb
|
||||
--disable-smtp --disable-gopher --disable-manual --disable-libcurl-option --enable-http
|
||||
--enable-ipv6 --disable-threaded-resolver --disable-pthreads --disable-verbose --disable-sspi
|
||||
--enable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-cookies
|
||||
--enable-http-auth --enable-doh --disable-mime --enable-dateparse --disable-netrc --without-libidn2
|
||||
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
|
||||
--without-libmetalink --without-librtmp --disable-versioned-symbols --enable-hidden-symbols
|
||||
--without-zsh-functions-dir --without-fish-functions-dir
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_noarch_CFLAGS}${cflags_extra}" ${curl_extra}
|
||||
BUILD_COMMAND true
|
||||
INSTALL_COMMAND make -C lib install && make -C include install
|
||||
BUILD_BYPRODUCTS
|
||||
${curl_prefix}/lib/libcurl.a
|
||||
${curl_prefix}/include/curl/curl.h
|
||||
)
|
||||
list(APPEND curl_lib_targets curl${curl_target_suffix}_external)
|
||||
list(APPEND curl_lib_outputs ${curl_prefix}/lib/libcurl.a)
|
||||
endforeach()
|
||||
|
||||
message(STATUS "TARGETS: ${curl_lib_targets}")
|
||||
|
||||
if(IOS AND num_arches GREATER 1)
|
||||
# We are building multiple architectures for different iOS devices, so we need to glue the
|
||||
# separate libraries into one. (Normally multiple -arch values passed to clang does this for us,
|
||||
# but curl refuses to build that way).
|
||||
add_custom_target(curl_external
|
||||
COMMAND lipo ${curl_lib_outputs} -create -output ${DEPS_DESTDIR}/libcurl.a
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_DESTDIR}/tmp/${curl_arch0}/include/curl ${DEPS_DESTDIR}/include/curl
|
||||
BYPRODUCTS ${DEPS_DESTDIR}/lib/libcurl.a ${DEPS_DESTDIR}/include/curl/curl.h
|
||||
DEPENDS ${curl_lib_targets})
|
||||
endif()
|
||||
|
||||
build_external(curl
|
||||
DEPENDS openssl_external zlib_external
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
|
||||
--enable-static --disable-ares --disable-ftp --disable-ldap --disable-laps --disable-rtsp
|
||||
--disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb
|
||||
--disable-smtp --disable-gopher --disable-manual --disable-libcurl-option --enable-http
|
||||
--enable-ipv6 --disable-threaded-resolver --disable-pthreads --disable-verbose --disable-sspi
|
||||
--enable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-cookies
|
||||
--enable-http-auth --enable-doh --disable-mime --enable-dateparse --disable-netrc --without-libidn2
|
||||
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
|
||||
--without-libmetalink --without-librtmp --disable-versioned-symbols --enable-hidden-symbols
|
||||
--without-zsh-functions-dir --without-fish-functions-dir
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" ${curl_LIBS}
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libcurl.a
|
||||
${DEPS_DESTDIR}/include/curl/curl.h
|
||||
)
|
||||
add_static_target(CURL::libcurl curl_external libcurl.a)
|
||||
set(libcurl_link_libs zlib)
|
||||
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# Figure out if we need -lstdc++fs or -lc++fs and add it to the `filesystem` interface, if needed
|
||||
# (otherwise just leave it an empty interface library; linking to it will do nothing). The former
|
||||
# is needed for gcc before v9, and the latter with libc++ before llvm v9. But this gets more
|
||||
# complicated than just using the compiler, because clang on linux by default uses libstdc++, so
|
||||
# we'll just give up and see what works.
|
||||
|
||||
add_library(filesystem INTERFACE)
|
||||
|
||||
set(filesystem_code [[
|
||||
#include <filesystem>
|
||||
|
||||
int main() {
|
||||
auto cwd = std::filesystem::current_path();
|
||||
return !cwd.string().empty();
|
||||
}
|
||||
]])
|
||||
|
||||
if(CMAKE_CXX_COMPILER STREQUAL "AppleClang" AND CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
# It seems that check_cxx_source_compiles doesn't respect the CMAKE_OSX_DEPLOYMENT_TARGET, so this
|
||||
# check would pass on Catalina (10.15) and then later compilation would fail because you aren't
|
||||
# allowed to use <filesystem> when the deployment target is anything before 10.15.
|
||||
set(CMAKE_REQUIRED_FLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("${filesystem_code}" filesystem_compiled)
|
||||
if(filesystem_compiled)
|
||||
message(STATUS "No extra link flag needed for std::filesystem")
|
||||
set(filesystem_is_good ON)
|
||||
else()
|
||||
foreach(fslib stdc++fs c++fs)
|
||||
set(CMAKE_REQUIRED_LIBRARIES -l${fslib})
|
||||
check_cxx_source_compiles("${filesystem_code}" filesystem_compiled_${fslib})
|
||||
if (filesystem_compiled_${fslib})
|
||||
message(STATUS "Using -l${fslib} for std::filesystem support")
|
||||
target_link_libraries(filesystem INTERFACE ${fslib})
|
||||
set(filesystem_is_good ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
option(FORCE_GHC_FILESYSTEM "Force ghc::filesystem even when std::filesystem appears to work" OFF)
|
||||
if(filesystem_is_good AND NOT FORCE_GHC_FILESYSTEM)
|
||||
message(STATUS "we have std::filesystem")
|
||||
else()
|
||||
# Probably broken AF macos
|
||||
message(STATUS "std::filesystem is not available, apparently this compiler isn't C++17 compliant; falling back to ghc::filesystem")
|
||||
add_subdirectory(external/ghc-filesystem)
|
||||
target_link_libraries(filesystem INTERFACE ghc_filesystem)
|
||||
target_compile_definitions(filesystem INTERFACE USE_GHC_FILESYSTEM)
|
||||
endif()
|
|
@ -0,0 +1,728 @@
|
|||
# This file downloaded from https://github.com/leetal/ios-cmake; it
|
||||
# contained this header regarding the source works' licences:
|
||||
#
|
||||
# This file is part of the ios-cmake project. It was retrieved from
|
||||
# https://github.com/cristeab/ios-cmake.git, which is a fork of
|
||||
# https://code.google.com/p/ios-cmake/. Which in turn is based off of
|
||||
# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
|
||||
# are included with CMake 2.8.4
|
||||
#
|
||||
# The ios-cmake project is licensed under the new BSD license.
|
||||
#
|
||||
# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
|
||||
# Kitware, Inc., Insight Software Consortium. 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.
|
||||
#
|
||||
# This file is based off of the Platform/Darwin.cmake and
|
||||
# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
|
||||
# It has been altered for iOS development.
|
||||
#
|
||||
# Updated by Alex Stewart (alexs.mac@gmail.com)
|
||||
#
|
||||
# *****************************************************************************
|
||||
# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
|
||||
# under the BSD-3-Clause license
|
||||
# https://github.com/leetal/ios-cmake
|
||||
# *****************************************************************************
|
||||
#
|
||||
# INFORMATION / HELP
|
||||
#
|
||||
# The following arguments control the behaviour of this toolchain:
|
||||
#
|
||||
# PLATFORM: (default "OS")
|
||||
# OS = Build for iPhoneOS.
|
||||
# OS64 = Build for arm64 iphoneOS.
|
||||
# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
|
||||
# SIMULATOR = Build for x86 i386 iphoneOS Simulator.
|
||||
# SIMULATOR64 = Build for x86_64 iphoneOS Simulator.
|
||||
# TVOS = Build for arm64 tvOS.
|
||||
# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
|
||||
# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator.
|
||||
# WATCHOS = Build for armv7k arm64_32 for watchOS.
|
||||
# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
|
||||
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
|
||||
#
|
||||
# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is
|
||||
# automatically determined from PLATFORM and xcodebuild, but
|
||||
# can also be manually specified (although this should not be required).
|
||||
#
|
||||
# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform
|
||||
# being compiled for. By default this is automatically determined from
|
||||
# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
|
||||
# not be required).
|
||||
#
|
||||
# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS
|
||||
#
|
||||
# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
|
||||
#
|
||||
# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
|
||||
#
|
||||
# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
|
||||
#
|
||||
# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker
|
||||
# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY)
|
||||
#
|
||||
# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM
|
||||
# OS = armv7 armv7s arm64 (if applicable)
|
||||
# OS64 = arm64 (if applicable)
|
||||
# SIMULATOR = i386
|
||||
# SIMULATOR64 = x86_64
|
||||
# TVOS = arm64
|
||||
# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
|
||||
# WATCHOS = armv7k arm64_32 (if applicable)
|
||||
# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
|
||||
#
|
||||
# This toolchain defines the following variables for use externally:
|
||||
#
|
||||
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
|
||||
# SDK_VERSION: Version of SDK being used.
|
||||
# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM).
|
||||
# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set!
|
||||
#
|
||||
# This toolchain defines the following macros for use externally:
|
||||
#
|
||||
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
|
||||
# A convenience macro for setting xcode specific properties on targets.
|
||||
# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
|
||||
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
|
||||
#
|
||||
# find_host_package (PROGRAM ARGS)
|
||||
# A macro used to find executable programs on the host system, not within the
|
||||
# environment. Thanks to the android-cmake project for providing the
|
||||
# command.
|
||||
#
|
||||
# ******************************** DEPRECATIONS *******************************
|
||||
#
|
||||
# IOS_DEPLOYMENT_TARGET: (Deprecated) Alias to DEPLOYMENT_TARGET
|
||||
# CMAKE_IOS_DEVELOPER_ROOT: (Deprecated) Alias to CMAKE_DEVELOPER_ROOT
|
||||
# IOS_PLATFORM: (Deprecated) Alias to PLATFORM
|
||||
# IOS_ARCH: (Deprecated) Alias to ARCHS
|
||||
#
|
||||
# *****************************************************************************
|
||||
#
|
||||
|
||||
# Fix for PThread library not in path
|
||||
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||
|
||||
# Cache what generator is used
|
||||
set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
|
||||
set(MODERN_CMAKE YES)
|
||||
endif()
|
||||
|
||||
# Get the Xcode version being used.
|
||||
execute_process(COMMAND xcodebuild -version
|
||||
OUTPUT_VARIABLE XCODE_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
|
||||
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
|
||||
|
||||
######## ALIASES (DEPRECATION WARNINGS)
|
||||
|
||||
if(DEFINED IOS_PLATFORM)
|
||||
set(PLATFORM ${IOS_PLATFORM})
|
||||
message(DEPRECATION "IOS_PLATFORM argument is DEPRECATED. Consider using the new PLATFORM argument instead.")
|
||||
endif()
|
||||
|
||||
if(DEFINED IOS_DEPLOYMENT_TARGET)
|
||||
set(DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET})
|
||||
message(DEPRECATION "IOS_DEPLOYMENT_TARGET argument is DEPRECATED. Consider using the new DEPLOYMENT_TARGET argument instead.")
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||
set(CMAKE_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT})
|
||||
message(DEPRECATION "CMAKE_IOS_DEVELOPER_ROOT argument is DEPRECATED. Consider using the new CMAKE_DEVELOPER_ROOT argument instead.")
|
||||
endif()
|
||||
|
||||
if(DEFINED IOS_ARCH)
|
||||
set(ARCHS ${IOS_ARCH})
|
||||
message(DEPRECATION "IOS_ARCH argument is DEPRECATED. Consider using the new ARCHS argument instead.")
|
||||
endif()
|
||||
|
||||
######## END ALIASES
|
||||
|
||||
# Unset the FORCE on cache variables if in try_compile()
|
||||
set(FORCE_CACHE FORCE)
|
||||
get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
if(_CMAKE_IN_TRY_COMPILE)
|
||||
unset(FORCE_CACHE)
|
||||
endif()
|
||||
|
||||
# Default to building for iPhoneOS if not specified otherwise, and we cannot
|
||||
# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
|
||||
# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
|
||||
# determine the value of PLATFORM from the root project, as
|
||||
# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
|
||||
if(NOT DEFINED PLATFORM)
|
||||
if (CMAKE_OSX_ARCHITECTURES)
|
||||
if(CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*" AND CMAKE_OSX_SYSROOT MATCHES ".*iphoneos.*")
|
||||
set(PLATFORM "OS")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*")
|
||||
set(PLATFORM "SIMULATOR")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*")
|
||||
set(PLATFORM "SIMULATOR64")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvos.*")
|
||||
set(PLATFORM "TVOS")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvsimulator.*")
|
||||
set(PLATFORM "SIMULATOR_TVOS")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*armv7k.*" AND CMAKE_OSX_SYSROOT MATCHES ".*watchos.*")
|
||||
set(PLATFORM "WATCHOS")
|
||||
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*watchsimulator.*")
|
||||
set(PLATFORM "SIMULATOR_WATCHOS")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT PLATFORM)
|
||||
set(PLATFORM "OS")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(PLATFORM_INT "${PLATFORM}" CACHE STRING "Type of platform for which the build targets.")
|
||||
|
||||
# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially)
|
||||
if(PLATFORM_INT STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
|
||||
set(PLATFORM_INT "OS64")
|
||||
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
|
||||
set(PLATFORM_INT "SIMULATOR64")
|
||||
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
|
||||
endif()
|
||||
|
||||
# Determine the platform name and architectures for use in xcodebuild commands
|
||||
# from the specified PLATFORM name.
|
||||
if(PLATFORM_INT STREQUAL "OS")
|
||||
set(SDK_NAME iphoneos)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS armv7 armv7s arm64)
|
||||
set(APPLE_TARGET_TRIPLE_INT arm-apple-ios)
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "OS64")
|
||||
set(SDK_NAME iphoneos)
|
||||
if(NOT ARCHS)
|
||||
if (XCODE_VERSION VERSION_GREATER 10.0)
|
||||
set(ARCHS arm64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
|
||||
else()
|
||||
set(ARCHS arm64)
|
||||
endif()
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios)
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
|
||||
set(SDK_NAME iphoneos)
|
||||
if(MODERN_CMAKE)
|
||||
if(NOT ARCHS)
|
||||
if (XCODE_VERSION VERSION_GREATER 10.0)
|
||||
set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
|
||||
else()
|
||||
set(ARCHS arm64 x86_64)
|
||||
endif()
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work")
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR")
|
||||
set(SDK_NAME iphonesimulator)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS i386)
|
||||
set(APPLE_TARGET_TRIPLE_INT i386-apple-ios)
|
||||
endif()
|
||||
message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
|
||||
set(SDK_NAME iphonesimulator)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS x86_64)
|
||||
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios)
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "TVOS")
|
||||
set(SDK_NAME appletvos)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS arm64)
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos)
|
||||
endif()
|
||||
elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED")
|
||||
set(SDK_NAME appletvos)
|
||||
if(MODERN_CMAKE)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS arm64 x86_64)
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work")
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
|
||||
set(SDK_NAME appletvsimulator)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS x86_64)
|
||||
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos)
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "WATCHOS")
|
||||
set(SDK_NAME watchos)
|
||||
if(NOT ARCHS)
|
||||
if (XCODE_VERSION VERSION_GREATER 10.0)
|
||||
set(ARCHS armv7k arm64_32)
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos)
|
||||
else()
|
||||
set(ARCHS armv7k)
|
||||
set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos)
|
||||
endif()
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
|
||||
set(SDK_NAME watchos)
|
||||
if(MODERN_CMAKE)
|
||||
if(NOT ARCHS)
|
||||
if (XCODE_VERSION VERSION_GREATER 10.0)
|
||||
set(ARCHS armv7k arm64_32 i386)
|
||||
set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos)
|
||||
else()
|
||||
set(ARCHS armv7k i386)
|
||||
set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work")
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
|
||||
set(SDK_NAME watchsimulator)
|
||||
if(NOT ARCHS)
|
||||
set(ARCHS i386)
|
||||
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
|
||||
endif()
|
||||
|
||||
if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
|
||||
message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode")
|
||||
endif()
|
||||
|
||||
# If user did not specify the SDK root to use, then query xcodebuild for it.
|
||||
execute_process(COMMAND xcodebuild -version -sdk ${SDK_NAME} Path
|
||||
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT)
|
||||
message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
|
||||
"is pointing to the correct path. Please run:"
|
||||
"sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
|
||||
"and see if that fixes the problem for you.")
|
||||
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
|
||||
"does not exist.")
|
||||
elseif(DEFINED CMAKE_OSX_SYSROOT_INT)
|
||||
set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
# Set Xcode property for SDKROOT as well if Xcode generator is used
|
||||
if(USED_CMAKE_GENERATOR MATCHES "Xcode")
|
||||
set(CMAKE_OSX_SYSROOT "${SDK_NAME}" CACHE INTERNAL "")
|
||||
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "123456789A" CACHE INTERNAL "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Specify minimum version of deployment target.
|
||||
if(NOT DEFINED DEPLOYMENT_TARGET)
|
||||
if (PLATFORM_INT STREQUAL "WATCHOS" OR PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
|
||||
# Unless specified, SDK version 2.0 is used by default as minimum target version (watchOS).
|
||||
set(DEPLOYMENT_TARGET "2.0"
|
||||
CACHE STRING "Minimum SDK version to build for." )
|
||||
else()
|
||||
# Unless specified, SDK version 9.0 is used by default as minimum target version (iOS, tvOS).
|
||||
set(DEPLOYMENT_TARGET "9.0"
|
||||
CACHE STRING "Minimum SDK version to build for." )
|
||||
endif()
|
||||
message(STATUS "Using the default min-version since DEPLOYMENT_TARGET not provided!")
|
||||
endif()
|
||||
|
||||
# Use bitcode or not
|
||||
if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+")
|
||||
# Unless specified, enable bitcode support by default
|
||||
message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
|
||||
set(ENABLE_BITCODE TRUE)
|
||||
elseif(NOT DEFINED ENABLE_BITCODE)
|
||||
message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
|
||||
set(ENABLE_BITCODE FALSE)
|
||||
endif()
|
||||
set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable bitcode" ${FORCE_CACHE})
|
||||
# Use ARC or not
|
||||
if(NOT DEFINED ENABLE_ARC)
|
||||
# Unless specified, enable ARC support by default
|
||||
set(ENABLE_ARC TRUE)
|
||||
message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
|
||||
endif()
|
||||
set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" ${FORCE_CACHE})
|
||||
# Use hidden visibility or not
|
||||
if(NOT DEFINED ENABLE_VISIBILITY)
|
||||
# Unless specified, disable symbols visibility by default
|
||||
set(ENABLE_VISIBILITY FALSE)
|
||||
message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
|
||||
endif()
|
||||
set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)" ${FORCE_CACHE})
|
||||
# Set strict compiler checks or not
|
||||
if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE)
|
||||
# Unless specified, disable strict try_compile()
|
||||
set(ENABLE_STRICT_TRY_COMPILE FALSE)
|
||||
message(STATUS "Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!")
|
||||
endif()
|
||||
set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL "Whether or not to use strict compiler checks" ${FORCE_CACHE})
|
||||
# Get the SDK version information.
|
||||
execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
|
||||
OUTPUT_VARIABLE SDK_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Find the Developer root for the specific iOS platform being compiled for
|
||||
# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
|
||||
# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
|
||||
# this information from xcrun or xcodebuild.
|
||||
if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
|
||||
get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
|
||||
get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)
|
||||
if (NOT DEFINED CMAKE_DEVELOPER_ROOT)
|
||||
message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: "
|
||||
"${CMAKE_DEVELOPER_ROOT} does not exist.")
|
||||
endif()
|
||||
endif()
|
||||
# Find the C & C++ compilers for the specified SDK.
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
|
||||
OUTPUT_VARIABLE CMAKE_C_COMPILER
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(NOT CMAKE_CXX_COMPILER)
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
|
||||
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
# Find (Apple's) libtool.
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
|
||||
OUTPUT_VARIABLE BUILD_LIBTOOL
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using libtool: ${BUILD_LIBTOOL}")
|
||||
# Configure libtool to be used instead of ar + ranlib to build static libraries.
|
||||
# This is required on Xcode 7+, but should also work on previous versions of
|
||||
# Xcode.
|
||||
set(CMAKE_C_CREATE_STATIC_LIBRARY
|
||||
"${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
|
||||
"${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
# Find the toolchain's provided install_name_tool if none is found on the host
|
||||
if(NOT CMAKE_INSTALL_NAME_TOOL)
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find install_name_tool
|
||||
OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE STRING "" ${FORCE_CACHE})
|
||||
endif()
|
||||
# Get the version of Darwin (OS X) of the host.
|
||||
execute_process(COMMAND uname -r
|
||||
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(SDK_NAME MATCHES "iphone")
|
||||
set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
endif()
|
||||
# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box.
|
||||
if(MODERN_CMAKE)
|
||||
if(SDK_NAME MATCHES "appletv")
|
||||
set(CMAKE_SYSTEM_NAME tvOS CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
elseif(SDK_NAME MATCHES "watch")
|
||||
set(CMAKE_SYSTEM_NAME watchOS CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
endif()
|
||||
# Provide flags for a combined FAT library build on newer CMake versions
|
||||
if(PLATFORM_INT MATCHES ".*COMBINED")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO" CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
set(CMAKE_IOS_INSTALL_COMBINED YES CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
message(STATUS "Will combine built (static) artifacts into FAT lib...")
|
||||
endif()
|
||||
elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10")
|
||||
# Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified
|
||||
set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
else()
|
||||
# Legacy code path prior to CMake 3.14 or fallback if no SDK_NAME specified
|
||||
set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "" ${FORCE_CACHE})
|
||||
endif()
|
||||
# Standard settings.
|
||||
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
|
||||
set(UNIX TRUE CACHE BOOL "")
|
||||
set(APPLE TRUE CACHE BOOL "")
|
||||
set(IOS TRUE CACHE BOOL "")
|
||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE)
|
||||
# Set the architectures for which to build.
|
||||
set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS")
|
||||
# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks
|
||||
if(ENABLE_STRICT_TRY_COMPILE_INT)
|
||||
message(STATUS "Using strict compiler checks (default in CMake).")
|
||||
else()
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
endif()
|
||||
# All iOS/Darwin specific settings - some may be redundant.
|
||||
set(CMAKE_MACOSX_BUNDLE YES)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set(CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set(CMAKE_C_COMPILER_ABI ELF)
|
||||
set(CMAKE_CXX_COMPILER_ABI ELF)
|
||||
set(CMAKE_C_HAS_ISYSROOT 1)
|
||||
set(CMAKE_CXX_HAS_ISYSROOT 1)
|
||||
set(CMAKE_MODULE_EXISTS 1)
|
||||
set(CMAKE_DL_LIBS "")
|
||||
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+")
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR 8)
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
|
||||
if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
|
||||
else()
|
||||
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR 4)
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "arm")
|
||||
endif()
|
||||
|
||||
# Note that only Xcode 7+ supports the newer more specific:
|
||||
# -m${SDK_NAME}-version-min flags, older versions of Xcode use:
|
||||
# -m(ios/ios-simulator)-version-min instead.
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11")
|
||||
if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64")
|
||||
if(XCODE_VERSION VERSION_LESS 7.0)
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mios-version-min=${DEPLOYMENT_TARGET}")
|
||||
else()
|
||||
# Xcode 7.0+ uses flags we can build directly from SDK_NAME.
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
elseif(PLATFORM_INT STREQUAL "TVOS")
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mtvos-version-min=${DEPLOYMENT_TARGET}")
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||
elseif(PLATFORM_INT STREQUAL "WATCHOS")
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mwatchos-version-min=${DEPLOYMENT_TARGET}")
|
||||
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||
else()
|
||||
# SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
|
||||
set(SDK_NAME_VERSION_FLAGS
|
||||
"-mios-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
else()
|
||||
# Newer versions of CMake sets the version min flags correctly
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING
|
||||
"Set CMake deployment target" ${FORCE_CACHE})
|
||||
endif()
|
||||
|
||||
if(DEFINED APPLE_TARGET_TRIPLE_INT)
|
||||
set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE STRING
|
||||
"Autoconf target triple compatible variable" ${FORCE_CACHE})
|
||||
endif()
|
||||
|
||||
if(ENABLE_BITCODE_INT)
|
||||
set(BITCODE "-fembed-bitcode")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode" CACHE INTERNAL "")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES" CACHE INTERNAL "")
|
||||
else()
|
||||
set(BITCODE "")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(ENABLE_ARC_INT)
|
||||
set(FOBJC_ARC "-fobjc-arc")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES" CACHE INTERNAL "")
|
||||
else()
|
||||
set(FOBJC_ARC "-fno-objc-arc")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_VISIBILITY_INT)
|
||||
set(VISIBILITY "-fvisibility=hidden")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES" CACHE INTERNAL "")
|
||||
else()
|
||||
set(VISIBILITY "")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(NOT IOS_TOOLCHAIN_HAS_RUN)
|
||||
#Check if Xcode generator is used, since that will handle these flags automagically
|
||||
if(USED_CMAKE_GENERATOR MATCHES "Xcode")
|
||||
message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS
|
||||
"${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
|
||||
# Hidden visibilty is required for C++ on iOS.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||
set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
|
||||
|
||||
# In order to ensure that the updated compiler flags are used in try_compile()
|
||||
# tests, we have to forcibly set them in the CMake cache, not merely set them
|
||||
# in the local scope.
|
||||
set(VARS_TO_FORCE_IN_CACHE
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_LINK_FLAGS
|
||||
CMAKE_CXX_LINK_FLAGS)
|
||||
foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
|
||||
set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" ${FORCE_CACHE})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
## Print status messages to inform of the current state
|
||||
message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}")
|
||||
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}")
|
||||
if(DEFINED APPLE_TARGET_TRIPLE)
|
||||
message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}")
|
||||
endif()
|
||||
message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}"
|
||||
" (SDK version: ${SDK_VERSION})")
|
||||
if(MODERN_CMAKE)
|
||||
message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!")
|
||||
endif()
|
||||
if(USED_CMAKE_GENERATOR MATCHES "Xcode")
|
||||
message(STATUS "Using Xcode version: ${XCODE_VERSION}")
|
||||
endif()
|
||||
if(DEFINED SDK_NAME_VERSION_FLAGS)
|
||||
message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
||||
message(STATUS "Using install_name_tool: ${CMAKE_INSTALL_NAME_TOOL}")
|
||||
if(ENABLE_BITCODE_INT)
|
||||
message(STATUS "Enabling bitcode support.")
|
||||
else()
|
||||
message(STATUS "Disabling bitcode support.")
|
||||
endif()
|
||||
|
||||
if(ENABLE_ARC_INT)
|
||||
message(STATUS "Enabling ARC support.")
|
||||
else()
|
||||
message(STATUS "Disabling ARC support.")
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_VISIBILITY_INT)
|
||||
message(STATUS "Hiding symbols (-fvisibility=hidden).")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
|
||||
|
||||
# Set the find root to the iOS developer roots and to user defined paths.
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT_INT} ${CMAKE_PREFIX_PATH} CACHE STRING "Root path that will be prepended
|
||||
to all search paths")
|
||||
# Default to searching for frameworks first.
|
||||
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||
# Set up the default search directories for frameworks.
|
||||
set(CMAKE_FRAMEWORK_PATH
|
||||
${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
|
||||
${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
|
||||
${CMAKE_FRAMEWORK_PATH} CACHE STRING "Frameworks search paths" ${FORCE_CACHE})
|
||||
|
||||
set(IOS_TOOLCHAIN_HAS_RUN TRUE CACHE BOOL "Has the CMake toolchain run already?" ${FORCE_CACHE})
|
||||
|
||||
# By default, search both the specified iOS SDK and the remainder of the host filesystem.
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE})
|
||||
endif()
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE STRING "" ${FORCE_CACHE})
|
||||
endif()
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE STRING "" ${FORCE_CACHE})
|
||||
endif()
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE STRING "" ${FORCE_CACHE})
|
||||
endif()
|
||||
|
||||
#
|
||||
# Some helper-macros below to simplify and beautify the CMakeFile
|
||||
#
|
||||
|
||||
# This little macro lets you set any Xcode specific property.
|
||||
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
|
||||
set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
|
||||
if(XCODE_RELVERSION_I STREQUAL "All")
|
||||
set_property(TARGET ${TARGET} PROPERTY
|
||||
XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
|
||||
else()
|
||||
set_property(TARGET ${TARGET} PROPERTY
|
||||
XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
|
||||
endif()
|
||||
endmacro(set_xcode_property)
|
||||
|
||||
# This macro lets you find executable programs on the host system.
|
||||
macro(find_host_package)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
|
||||
set(IOS FALSE)
|
||||
find_package(${ARGN})
|
||||
set(IOS TRUE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
||||
endmacro(find_host_package)
|
|
@ -27,4 +27,4 @@
|
|||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
target_include_directories(epee PUBLIC include)
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include "warnings.h"
|
||||
#include "string_tools.h"
|
||||
#include "misc_language.h"
|
||||
#include "net/local_ip.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
#include "../warnings.h"
|
||||
#include "../string_tools.h"
|
||||
#include "../misc_language.h"
|
||||
#include "local_ip.h"
|
||||
#include "../pragma_comp_defs.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
|
@ -29,8 +29,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "misc_log_ex.h"
|
||||
#include "span.h"
|
||||
#include "../misc_log_ex.h"
|
||||
#include "../span.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "net.buffer"
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
#include "shared_sv.h"
|
||||
#include "../shared_sv.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "serialization/keyvalue_serialization.h"
|
||||
#include "storages/portable_storage_base.h"
|
||||
#include "../serialization/keyvalue_serialization.h"
|
||||
#include "../storages/portable_storage_base.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -34,7 +34,7 @@
|
|||
#include <string_view>
|
||||
|
||||
#include "net_utils_base.h"
|
||||
#include "span.h"
|
||||
#include "../span.h"
|
||||
|
||||
#define LEVIN_SIGNATURE 0x0101010101012101LL //Bender's nightmare
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
#include "levin_base.h"
|
||||
#include "int-util.h"
|
||||
#include "../int-util.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "net"
|
|
@ -35,9 +35,9 @@
|
|||
|
||||
#include "levin_base.h"
|
||||
#include "buffer.h"
|
||||
#include "misc_language.h"
|
||||
#include "misc_os_dependent.h"
|
||||
#include "int-util.h"
|
||||
#include "../misc_language.h"
|
||||
#include "../misc_os_dependent.h"
|
||||
#include "../int-util.h"
|
||||
|
||||
#include <random>
|
||||
#include <chrono>
|
|
@ -30,7 +30,7 @@
|
|||
#include <string>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include "int-util.h"
|
||||
#include "../int-util.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -34,11 +34,11 @@
|
|||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include "shared_sv.h"
|
||||
#include "../shared_sv.h"
|
||||
#include "enums.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include "serialization/keyvalue_serialization.h"
|
||||
#include "int-util.h"
|
||||
#include "../misc_log_ex.h"
|
||||
#include "../serialization/keyvalue_serialization.h"
|
||||
#include "../int-util.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "net"
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "misc_log_ex.h"
|
||||
#include "enableable.h"
|
||||
#include "../misc_log_ex.h"
|
||||
#include "keyvalue_serialization_overloads.h"
|
||||
#include "../storages/portable_storage.h"
|
||||
|
|
@ -33,8 +33,8 @@
|
|||
#include <vector>
|
||||
#include <deque>
|
||||
#include <array>
|
||||
#include "span.h"
|
||||
#include "storages/portable_storage_base.h"
|
||||
#include "../span.h"
|
||||
#include "../storages/portable_storage_base.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "serialization"
|
||||
|
@ -128,24 +128,6 @@ namespace epee
|
|||
return obj._load(stg, child_section);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
template<class serializible_type, class t_storage>
|
||||
static bool serialize_t_obj(enableable<serializible_type>& obj, t_storage& stg, section* parent_section, const char* pname)
|
||||
{
|
||||
if(!obj.enabled)
|
||||
return true;
|
||||
return serialize_t_obj(obj.v, stg, parent_section, pname);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
template<class serializible_type, class t_storage>
|
||||
static bool unserialize_t_obj(enableable<serializible_type>& obj, t_storage& stg, section* parent_section, const char* pname)
|
||||
{
|
||||
obj.enabled = false;
|
||||
section* child_section = stg.open_section(pname, parent_section, false);
|
||||
if(!child_section) return false;
|
||||
obj.enabled = true;
|
||||
return obj.v._load(stg, child_section);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
template<class stl_container, class t_storage>
|
||||
static bool serialize_stl_container_t_val(const stl_container& container, t_storage& stg, section* parent_section, const char* pname)
|
||||
{
|
|
@ -27,8 +27,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "portable_storage_template_helper.h"
|
||||
#include "span.h"
|
||||
#include "net/levin_base.h"
|
||||
#include "../span.h"
|
||||
#include "../net/levin_base.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "net"
|
|
@ -31,7 +31,7 @@
|
|||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include "misc_log_ex.h"
|
||||
#include "../misc_log_ex.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "serialization"
|
|
@ -28,14 +28,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "misc_language.h"
|
||||
#include "../misc_language.h"
|
||||
#include "portable_storage_base.h"
|
||||
#include "portable_storage_to_bin.h"
|
||||
#include "portable_storage_from_bin.h"
|
||||
#include "portable_storage_to_json.h"
|
||||
#include "portable_storage_from_json.h"
|
||||
#include "portable_storage_val_converters.h"
|
||||
#include "span.h"
|
||||
#include "../span.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -33,8 +33,8 @@
|
|||
#include <vector>
|
||||
#include <deque>
|
||||
#include <cstdint>
|
||||
#include "misc_log_ex.h"
|
||||
#include "int-util.h"
|
||||
#include "../misc_log_ex.h"
|
||||
#include "../int-util.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "misc_language.h"
|
||||
#include "../misc_language.h"
|
||||
#include "portable_storage_base.h"
|
||||
#include <boost/endian/conversion.hpp>
|
||||
|
|
@ -28,7 +28,6 @@
|
|||
#include <string_view>
|
||||
#include <charconv>
|
||||
#include "parserse_base_utils.h"
|
||||
#include "file_io_utils.h"
|
||||
|
||||
#define EPEE_JSON_RECURSION_LIMIT_INTERNAL 100
|
||||
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "parserse_base_utils.h"
|
||||
#include "portable_storage.h"
|
||||
#include "file_io_utils.h"
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
@ -50,16 +49,6 @@ namespace epee
|
|||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool load_t_from_json_file(t_struct& out, const std::string& json_file)
|
||||
{
|
||||
std::string f_buff;
|
||||
if(!file_io_utils::load_file_to_string(json_file, f_buff))
|
||||
return false;
|
||||
|
||||
return load_t_from_json(out, f_buff);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool store_t_to_json(t_struct& str_in, std::string& json_buff, size_t indent = 0, bool insert_newlines = true)
|
||||
{
|
||||
portable_storage ps;
|
||||
|
@ -77,14 +66,6 @@ namespace epee
|
|||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool store_t_to_json_file(t_struct& str_in, const std::string& fpath)
|
||||
{
|
||||
std::string json_buff;
|
||||
store_t_to_json(str_in, json_buff);
|
||||
return file_io_utils::save_string_to_file(fpath, json_buff);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool load_t_from_binary(t_struct& out, const epee::span<const uint8_t> binary_buff)
|
||||
{
|
||||
portable_storage ps;
|
||||
|
@ -106,16 +87,6 @@ namespace epee
|
|||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool load_t_from_binary_file(t_struct& out, const std::string& binary_file)
|
||||
{
|
||||
std::string f_buff;
|
||||
if(!file_io_utils::load_file_to_string(binary_file, f_buff))
|
||||
return false;
|
||||
|
||||
return load_t_from_binary(out, f_buff);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
template<class t_struct>
|
||||
bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, size_t indent = 0)
|
||||
{
|
||||
portable_storage ps;
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "pragma_comp_defs.h"
|
||||
#include "misc_language.h"
|
||||
#include "../pragma_comp_defs.h"
|
||||
#include "../misc_language.h"
|
||||
#include "portable_storage_base.h"
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <lokimq/variant.h>
|
|
@ -33,10 +33,10 @@
|
|||
#include <type_traits>
|
||||
#include <charconv>
|
||||
|
||||
#include "misc_language.h"
|
||||
#include "../misc_language.h"
|
||||
#include "portable_storage_base.h"
|
||||
#include "parserse_base_utils.h"
|
||||
#include "warnings.h"
|
||||
#include "../warnings.h"
|
||||
|
||||
namespace epee
|
||||
{
|
|
@ -42,6 +42,7 @@
|
|||
#include <type_traits>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <lokimq/hex.h>
|
||||
#include "storages/parserse_base_utils.h"
|
||||
#include "hex.h"
|
||||
#include "mlocker.h"
|
||||
|
@ -60,11 +61,6 @@ using namespace std::literals;
|
|||
|
||||
namespace string_tools
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string buff_to_hex_nodelimer(const std::string& src)
|
||||
{
|
||||
return to_hex::string(to_byte_span(to_span(src)));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool parse_hexstr_to_binbuff(const epee::span<const char> s, epee::span<char>& res)
|
||||
{
|
||||
|
@ -128,21 +124,6 @@ DISABLE_GCC_WARNING(maybe-uninitialized)
|
|||
return true;
|
||||
}
|
||||
POP_WARNINGS
|
||||
//----------------------------------------------------------------------------
|
||||
template<class XType>
|
||||
inline bool xtype_to_string(const XType& val, std::string& str)
|
||||
{
|
||||
try
|
||||
{
|
||||
str = boost::lexical_cast<std::string>(val);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
std::string get_ip_string_from_int32(uint32_t ip);
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -176,14 +157,6 @@ POP_WARNINGS
|
|||
return true;
|
||||
}
|
||||
|
||||
inline std::string num_to_string_fast(int64_t val)
|
||||
{
|
||||
/*
|
||||
char buff[30] = {0};
|
||||
i64toa_s(val, buff, sizeof(buff)-1, 10);
|
||||
return buff;*/
|
||||
return boost::lexical_cast<std::string>(val);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
inline std::string to_string_hex(const T &val)
|
||||
|
@ -246,37 +219,33 @@ POP_WARNINGS
|
|||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool trim_left(std::string& str)
|
||||
{
|
||||
for(std::string::iterator it = str.begin(); it!= str.end() && isspace(static_cast<unsigned char>(*it));)
|
||||
str.erase(str.begin());
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool trim_right(std::string& str)
|
||||
{
|
||||
|
||||
for(std::string::reverse_iterator it = str.rbegin(); it!= str.rend() && isspace(static_cast<unsigned char>(*it));)
|
||||
str.erase( --((it++).base()));
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string& trim(std::string& str)
|
||||
{
|
||||
|
||||
trim_left(str);
|
||||
trim_right(str);
|
||||
return str;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string& trim_left(std::string& str)
|
||||
{
|
||||
auto it = str.begin();
|
||||
while (it != str.end() && std::isspace(static_cast<unsigned char>(*it)))
|
||||
it++;
|
||||
if (it != str.begin())
|
||||
str.erase(str.begin(), it);
|
||||
return str;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string& trim_right(std::string& str)
|
||||
{
|
||||
while (!str.empty() && std::isspace(static_cast<unsigned char>(str.back())))
|
||||
str.pop_back();
|
||||
return str;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string& trim(std::string& str)
|
||||
{
|
||||
return trim_left(trim_right(str));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string trim(const std::string& str_)
|
||||
{
|
||||
std::string str = str_;
|
||||
trim_left(str);
|
||||
trim_right(str);
|
||||
trim(str);
|
||||
return str;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -291,94 +260,6 @@ POP_WARNINGS
|
|||
}
|
||||
return s;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<class t_pod_type>
|
||||
std::string pod_to_hex(const t_pod_type& s)
|
||||
{
|
||||
static_assert(std::is_standard_layout<t_pod_type>(), "expected standard layout type");
|
||||
return to_hex::string(as_byte_span(s));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<class t_pod_type>
|
||||
bool hex_to_pod(const std::string& hex_str, t_pod_type& s)
|
||||
{
|
||||
static_assert(std::is_pod<t_pod_type>::value, "expected pod type");
|
||||
if(sizeof(s)*2 != hex_str.size())
|
||||
return false;
|
||||
epee::span<char> rspan((char*)&s, sizeof(s));
|
||||
return parse_hexstr_to_binbuff(epee::to_span(hex_str), rspan);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<class t_pod_type>
|
||||
bool hex_to_pod(const std::string& hex_str, tools::scrubbed<t_pod_type>& s)
|
||||
{
|
||||
return hex_to_pod(hex_str, unwrap(s));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
template<class t_pod_type>
|
||||
bool hex_to_pod(const std::string& hex_str, epee::mlocked<t_pod_type>& s)
|
||||
{
|
||||
return hex_to_pod(hex_str, unwrap(s));
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
bool validate_hex(uint64_t length, const std::string& str);
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string get_extension(const std::string& str)
|
||||
{
|
||||
std::string res;
|
||||
std::string::size_type pos = str.rfind('.');
|
||||
if(std::string::npos == pos)
|
||||
return res;
|
||||
|
||||
res = str.substr(pos+1, str.size()-pos);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string cut_off_extension(const std::string& str)
|
||||
{
|
||||
std::string res;
|
||||
std::string::size_type pos = str.rfind('.');
|
||||
if(std::string::npos == pos)
|
||||
return str;
|
||||
|
||||
res = str.substr(0, pos);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
#ifdef _WIN32
|
||||
inline std::wstring utf8_to_utf16(const std::string& str)
|
||||
{
|
||||
if (str.empty())
|
||||
return {};
|
||||
int wstr_size = MultiByteToWideChar(CP_UTF8, 0, &str[0], str.size(), NULL, 0);
|
||||
if (wstr_size == 0)
|
||||
{
|
||||
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
|
||||
}
|
||||
std::wstring wstr(wstr_size, wchar_t{});
|
||||
if (!MultiByteToWideChar(CP_UTF8, 0, &str[0], str.size(), &wstr[0], wstr_size))
|
||||
{
|
||||
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
|
||||
}
|
||||
return wstr;
|
||||
}
|
||||
inline std::string utf16_to_utf8(const std::wstring& wstr)
|
||||
{
|
||||
if (wstr.empty())
|
||||
return {};
|
||||
int str_size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr.size(), NULL, 0, NULL, NULL);
|
||||
if (str_size == 0)
|
||||
{
|
||||
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
|
||||
}
|
||||
std::string str(str_size, char{});
|
||||
if (!WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr.size(), &str[0], str_size, NULL, NULL))
|
||||
{
|
||||
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif //_STRING_TOOLS_H_
|
|
@ -1,235 +0,0 @@
|
|||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// 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.
|
||||
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
|
||||
//
|
||||
|
||||
|
||||
#ifndef _FILE_IO_UTILS_H_
|
||||
#define _FILE_IO_UTILS_H_
|
||||
|
||||
#include <fstream>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include "string_tools.h"
|
||||
#endif
|
||||
|
||||
// On Windows there is a problem with non-ASCII characters in path and file names
|
||||
// as far as support by the standard components used is concerned:
|
||||
|
||||
// The various file stream classes, e.g. std::ifstream and std::ofstream, are
|
||||
// part of the GNU C++ Library / libstdc++. On the most basic level they use the
|
||||
// fopen() call as defined / made accessible to programs compiled within MSYS2
|
||||
// by the stdio.h header file maintained by the MinGW project.
|
||||
|
||||
// The critical point: The implementation of fopen() is part of MSVCRT, the
|
||||
// Microsoft Visual C/C++ Runtime Library, and this method does NOT offer any
|
||||
// Unicode support.
|
||||
|
||||
// Monero code that would want to continue to use the normal file stream classes
|
||||
// but WITH Unicode support could therefore not solve this problem on its own,
|
||||
// but 2 different projects from 2 different maintaining groups would need changes
|
||||
// in this particular direction - something probably difficult to achieve and
|
||||
// with a long time to wait until all new versions / releases arrive.
|
||||
|
||||
// Implemented solution approach: Circumvent the problem by stopping to use std
|
||||
// file stream classes on Windows and directly use Unicode-capable WIN32 API
|
||||
// calls. Most of the code doing so is concentrated in this header file here.
|
||||
|
||||
namespace epee
|
||||
{
|
||||
namespace file_io_utils
|
||||
{
|
||||
inline
|
||||
bool is_file_exist(const std::string& path)
|
||||
{
|
||||
boost::filesystem::path p(path);
|
||||
return boost::filesystem::exists(p);
|
||||
}
|
||||
|
||||
inline
|
||||
bool save_string_to_file(const std::string& path_to_file, const std::string& str)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring wide_path;
|
||||
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
|
||||
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file_handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
DWORD bytes_written;
|
||||
DWORD bytes_to_write = (DWORD)str.size();
|
||||
BOOL result = WriteFile(file_handle, str.data(), bytes_to_write, &bytes_written, NULL);
|
||||
CloseHandle(file_handle);
|
||||
if (bytes_written != bytes_to_write)
|
||||
result = FALSE;
|
||||
return result;
|
||||
#else
|
||||
try
|
||||
{
|
||||
std::ofstream fstream;
|
||||
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
|
||||
fstream << str;
|
||||
fstream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
bool get_file_time(const std::string& path_to_file, time_t& ft)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec);
|
||||
if(!ec)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool set_file_time(const std::string& path_to_file, const time_t& ft)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ft, ec);
|
||||
if(!ec)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring wide_path;
|
||||
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
|
||||
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file_handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
DWORD file_size = GetFileSize(file_handle, NULL);
|
||||
if ((file_size == INVALID_FILE_SIZE) || (uint64_t)file_size > (uint64_t)max_size) {
|
||||
CloseHandle(file_handle);
|
||||
return false;
|
||||
}
|
||||
target_str.resize(file_size);
|
||||
DWORD bytes_read;
|
||||
BOOL result = ReadFile(file_handle, &target_str[0], file_size, &bytes_read, NULL);
|
||||
CloseHandle(file_handle);
|
||||
if (bytes_read != file_size)
|
||||
result = FALSE;
|
||||
return result;
|
||||
#else
|
||||
try
|
||||
{
|
||||
std::ifstream fstream;
|
||||
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
|
||||
|
||||
std::ifstream::pos_type file_size = fstream.tellg();
|
||||
|
||||
if((uint64_t)file_size > (uint64_t)max_size) // ensure a large domain for comparison, and negative -> too large
|
||||
return false;//don't go crazy
|
||||
size_t file_size_t = static_cast<size_t>(file_size);
|
||||
|
||||
target_str.resize(file_size_t);
|
||||
|
||||
fstream.seekg (0, std::ios::beg);
|
||||
fstream.read((char*)target_str.data(), target_str.size());
|
||||
fstream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
bool append_string_to_file(const std::string& path_to_file, const std::string& str)
|
||||
{
|
||||
// No special Windows implementation because so far not used in Monero code
|
||||
try
|
||||
{
|
||||
std::ofstream fstream;
|
||||
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
fstream.open(path_to_file.c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::app);
|
||||
fstream << str;
|
||||
fstream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
bool get_file_size(const std::string& path_to_file, uint64_t &size)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring wide_path;
|
||||
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
|
||||
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file_handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
LARGE_INTEGER file_size;
|
||||
BOOL result = GetFileSizeEx(file_handle, &file_size);
|
||||
CloseHandle(file_handle);
|
||||
if (result) {
|
||||
size = file_size.QuadPart;
|
||||
}
|
||||
return size;
|
||||
#else
|
||||
try
|
||||
{
|
||||
std::ifstream fstream;
|
||||
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
|
||||
size = fstream.tellg();
|
||||
fstream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_FILE_IO_UTILS_H_
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// 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.
|
||||
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BOOST_FILESYSTEM_VERSION 3
|
||||
#define ENABLE_RELEASE_LOGGING
|
||||
|
||||
#include "misc_log_ex.h"
|
||||
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// 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.
|
||||
// * Neither the name of the Andrey N. Sabelnikov 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 OWNER 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.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
||||
template<class t_obj>
|
||||
struct enableable
|
||||
{
|
||||
t_obj v;
|
||||
bool enabled;
|
||||
|
||||
enableable()
|
||||
: v(t_obj()), enabled(true)
|
||||
{ // construct from defaults
|
||||
}
|
||||
|
||||
enableable(const t_obj& _v)
|
||||
: v(_v), enabled(true)
|
||||
{ // construct from specified values
|
||||
}
|
||||
|
||||
enableable(const enableable<t_obj>& _v)
|
||||
: v(_v.v), enabled(_v.enabled)
|
||||
{ // construct from specified values
|
||||
}
|
||||
};
|
||||
}
|
|
@ -64,11 +64,9 @@ endif()
|
|||
target_link_libraries(epee
|
||||
PUBLIC
|
||||
easylogging
|
||||
lokimq::lokimq
|
||||
PRIVATE
|
||||
lokimq::lokimq
|
||||
Boost::filesystem
|
||||
filesystem
|
||||
Boost::thread
|
||||
extra)
|
||||
|
||||
target_include_directories(epee PUBLIC ../include)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// 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.
|
||||
|
||||
#include "net/buffer.h"
|
||||
#include "epee/net/buffer.h"
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
|
|
|
@ -32,20 +32,20 @@
|
|||
|
||||
/* rfree: implementation for the non-template base, can be used by connection<> template class in abstract_tcp_server2 file */
|
||||
|
||||
#include "net/connection_basic.hpp"
|
||||
#include "epee/net/connection_basic.hpp"
|
||||
|
||||
#include "net/net_utils_base.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include "epee/net/net_utils_base.h"
|
||||
#include "epee/misc_log_ex.h"
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "misc_language.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
#include "epee/misc_language.h"
|
||||
#include "epee/pragma_comp_defs.h"
|
||||
#include <iomanip>
|
||||
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
|
||||
// TODO:
|
||||
#include "net/network_throttle-detail.hpp"
|
||||
#include "epee/net/network_throttle-detail.hpp"
|
||||
|
||||
#if BOOST_VERSION >= 107000
|
||||
#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// 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.
|
||||
|
||||
#include "hex.h"
|
||||
#include "epee/hex.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
// 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.
|
||||
|
||||
#include "net/levin_base.h"
|
||||
#include "epee/net/levin_base.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "int-util.h"
|
||||
#include "epee/int-util.h"
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#ifdef HAVE_EXPLICIT_BZERO
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "memwipe.h"
|
||||
#include "epee/memwipe.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define SCARECROW \
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// 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.
|
||||
|
||||
#if defined __GNUC__ && !defined _WIN32
|
||||
#if defined __GNUC__ && !defined _WIN32 && !defined __ANDROID__
|
||||
#define HAVE_MLOCK 1
|
||||
#endif
|
||||
|
||||
|
@ -34,8 +34,8 @@
|
|||
#if defined HAVE_MLOCK
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#include "misc_log_ex.h"
|
||||
#include "mlocker.h"
|
||||
#include "epee/misc_log_ex.h"
|
||||
#include "epee/mlocker.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cerrno>
|
||||
|
@ -111,25 +111,34 @@ namespace epee
|
|||
|
||||
size_t mlocker::get_page_size()
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
std::lock_guard lock{mutex()};
|
||||
if (page_size == 0)
|
||||
page_size = query_page_size();
|
||||
return page_size;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
mlocker::mlocker(void *ptr, size_t len): ptr(ptr), len(len)
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
lock(ptr, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
mlocker::~mlocker()
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
try { unlock(ptr, len); }
|
||||
catch (...) { /* ignore and do not propagate through the dtor */ }
|
||||
#endif
|
||||
}
|
||||
|
||||
void mlocker::lock(void *ptr, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
TRY_ENTRY();
|
||||
|
||||
size_t page_size = get_page_size();
|
||||
|
@ -144,10 +153,12 @@ namespace epee
|
|||
++num_locked_objects;
|
||||
|
||||
CATCH_ENTRY_L1("mlocker::lock", void());
|
||||
#endif
|
||||
}
|
||||
|
||||
void mlocker::unlock(void *ptr, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
TRY_ENTRY();
|
||||
|
||||
size_t page_size = get_page_size();
|
||||
|
@ -161,22 +172,32 @@ namespace epee
|
|||
--num_locked_objects;
|
||||
|
||||
CATCH_ENTRY_L1("mlocker::lock", void());
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t mlocker::get_num_locked_pages()
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
std::lock_guard lock{mutex()};
|
||||
return map().size();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t mlocker::get_num_locked_objects()
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
std::lock_guard lock{mutex()};
|
||||
return num_locked_objects;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mlocker::lock_page(size_t page)
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
std::pair<std::map<size_t, unsigned int>::iterator, bool> p = map().insert(std::make_pair(page, 1));
|
||||
if (p.second)
|
||||
{
|
||||
|
@ -186,10 +207,12 @@ namespace epee
|
|||
{
|
||||
++p.first->second;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void mlocker::unlock_page(size_t page)
|
||||
{
|
||||
#if defined(HAVE_MLOCK)
|
||||
std::map<size_t, unsigned int>::iterator i = map().find(page);
|
||||
if (i == map().end())
|
||||
{
|
||||
|
@ -203,5 +226,6 @@ namespace epee
|
|||
do_unlock((void*)(page * page_size), page_size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,18 @@
|
|||
|
||||
#include <ctime>
|
||||
#include <atomic>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "string_tools.h"
|
||||
#include "misc_os_dependent.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include "epee/string_tools.h"
|
||||
#include "epee/misc_os_dependent.h"
|
||||
#include "epee/misc_log_ex.h"
|
||||
|
||||
#ifndef USE_GHC_FILESYSTEM
|
||||
#include <filesystem>
|
||||
namespace fs { using namespace std::filesystem; }
|
||||
#else
|
||||
#include <ghc/filesystem.hpp>
|
||||
namespace fs = ghc::filesystem;
|
||||
#endif
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "logging"
|
||||
|
@ -82,7 +89,7 @@ std::string mlog_get_default_log_path(const char *default_filename)
|
|||
else
|
||||
default_log_file = default_filename;
|
||||
|
||||
return (boost::filesystem::path(default_log_folder) / boost::filesystem::path(default_log_file)).string();
|
||||
return (fs::u8path(default_log_folder) / fs::u8path(default_log_file)).u8string();
|
||||
}
|
||||
|
||||
static void mlog_set_common_prefix()
|
||||
|
@ -173,52 +180,27 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
|
|||
}
|
||||
if (max_log_files != 0)
|
||||
{
|
||||
std::vector<boost::filesystem::path> found_files;
|
||||
const boost::filesystem::directory_iterator end_itr;
|
||||
const boost::filesystem::path filename_base_path(filename_base);
|
||||
const boost::filesystem::path parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : ".";
|
||||
for (boost::filesystem::directory_iterator iter(parent_path); iter != end_itr; ++iter)
|
||||
std::vector<fs::path> found_files;
|
||||
const auto filename_base_path = fs::u8path(filename_base);
|
||||
const auto parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : fs::path(".");
|
||||
for (const auto& p : fs::directory_iterator{parent_path})
|
||||
{
|
||||
const std::string filename = iter->path().string();
|
||||
const std::string filename = p.path().u8string();
|
||||
if (filename.size() >= filename_base.size() && std::memcmp(filename.data(), filename_base.data(), filename_base.size()) == 0)
|
||||
{
|
||||
found_files.push_back(iter->path());
|
||||
}
|
||||
found_files.push_back(p.path());
|
||||
}
|
||||
|
||||
if (found_files.size() >= max_log_files)
|
||||
{
|
||||
std::sort(found_files.begin(), found_files.end(), [](const boost::filesystem::path &a, const boost::filesystem::path &b) {
|
||||
boost::system::error_code ec;
|
||||
std::time_t ta = boost::filesystem::last_write_time(boost::filesystem::path(a), ec);
|
||||
if (ec)
|
||||
{
|
||||
MERROR("Failed to get timestamp from " << a << ": " << ec);
|
||||
ta = std::time(nullptr);
|
||||
}
|
||||
std::time_t tb = boost::filesystem::last_write_time(boost::filesystem::path(b), ec);
|
||||
if (ec)
|
||||
{
|
||||
MERROR("Failed to get timestamp from " << b << ": " << ec);
|
||||
tb = std::time(nullptr);
|
||||
}
|
||||
static_assert(std::is_integral<time_t>(), "bad time_t");
|
||||
return ta < tb;
|
||||
std::sort(found_files.begin(), found_files.end(), [](auto& a, auto& b) {
|
||||
std::error_code ec;
|
||||
return fs::last_write_time(a, ec) < fs::last_write_time(b, ec);
|
||||
});
|
||||
for (size_t i = 0; i <= found_files.size() - max_log_files; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::remove(found_files[i], ec);
|
||||
if (ec)
|
||||
{
|
||||
MERROR("Failed to remove " << found_files[i] << ": " << ec);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
MERROR("Failed to remove " << found_files[i] << ": " << e.what());
|
||||
}
|
||||
std::error_code ec;
|
||||
if (!fs::remove(found_files[i], ec))
|
||||
MERROR("Failed to remove " << found_files[i] << ": " << ec.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
#include "net/net_utils_base.h"
|
||||
#include "epee/net/net_utils_base.h"
|
||||
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
|
||||
#include "string_tools.h"
|
||||
#include "net/local_ip.h"
|
||||
#include "epee/string_tools.h"
|
||||
#include "epee/net/local_ip.h"
|
||||
|
||||
namespace epee { namespace net_utils
|
||||
{
|
||||
|
|
|
@ -38,15 +38,15 @@
|
|||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
#include "net/net_utils_base.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include "misc_language.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
#include "epee/net/net_utils_base.h"
|
||||
#include "epee/misc_log_ex.h"
|
||||
#include "epee/misc_language.h"
|
||||
#include "epee/pragma_comp_defs.h"
|
||||
|
||||
#include "net/abstract_tcp_server2.h"
|
||||
#include "epee/net/abstract_tcp_server2.h"
|
||||
|
||||
// TODO:
|
||||
#include "net/network_throttle-detail.hpp"
|
||||
#include "epee/net/network_throttle-detail.hpp"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "net.throttle"
|
||||
|
|
|
@ -54,7 +54,7 @@ Throttling work by:
|
|||
// 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.
|
||||
|
||||
#include "net/network_throttle-detail.hpp"
|
||||
#include "epee/net/network_throttle-detail.hpp"
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "storages/portable_storage_to_json.h"
|
||||
#include "storages/portable_storage.h"
|
||||
#include "epee/storages/portable_storage_to_json.h"
|
||||
#include "epee/storages/portable_storage.h"
|
||||
#include <lokimq/variant.h>
|
||||
|
||||
namespace epee {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "readline_buffer.h"
|
||||
#include "readline_suspend.h"
|
||||
#include "epee/readline_buffer.h"
|
||||
#include "epee/readline_suspend.h"
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <algorithm>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "string_tools.h"
|
||||
#include "epee/string_tools.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "time_helper.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
#include "epee/time_helper.h"
|
||||
#include "epee/pragma_comp_defs.h"
|
||||
|
||||
namespace epee::misc_utils
|
||||
{
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include "memwipe.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include "wipeable_string.h"
|
||||
#include "epee/memwipe.h"
|
||||
#include "epee/misc_log_ex.h"
|
||||
#include "epee/wipeable_string.h"
|
||||
|
||||
static constexpr const char hex[] = u8"0123456789abcdef";
|
||||
|
||||
|
|
|
@ -33,14 +33,26 @@
|
|||
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
|
||||
# others.
|
||||
|
||||
set(DEFAULT_WITH_MINIUPNPC ON)
|
||||
if(ANDROID OR IOS)
|
||||
set(DEFAULT_WITH_MINIUPNPC OFF)
|
||||
endif()
|
||||
|
||||
option(WITH_MINIUPNPC "Enable miniupnpc support for IGD NAT hole punching" ${DEFAULT_WITH_MINIUPNPC})
|
||||
|
||||
if(NOT STATIC AND NOT BUILD_STATIC_DEPS)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(MINIUPNPC miniupnpc>=2.1)
|
||||
if(WITH_MINIUPNPC)
|
||||
pkg_check_modules(MINIUPNPC miniupnpc>=2.1)
|
||||
endif()
|
||||
pkg_check_modules(UNBOUND libunbound)
|
||||
pkg_check_modules(LOKIMQ liblokimq>=1.2)
|
||||
endif()
|
||||
|
||||
if(MINIUPNPC_FOUND)
|
||||
if(NOT WITH_MINIUPNPC)
|
||||
message(STATUS "miniupnpc support disabled")
|
||||
target_compile_definitions(miniupnpc INTERFACE WITHOUT_MINIUPNPC)
|
||||
elseif(MINIUPNPC_FOUND)
|
||||
message(STATUS "Found miniupnpc")
|
||||
link_dep_libs(miniupnpc INTERFACE "${MINIUPNPC_LIBRARY_DIRS}" ${MINIUPNPC_LIBRARIES})
|
||||
target_include_directories(miniupnpc INTERFACE ${MINIUPNPC_INCLUDE_DIRS})
|
||||
|
@ -88,7 +100,7 @@ else()
|
|||
endif()
|
||||
|
||||
add_subdirectory(db_drivers)
|
||||
add_subdirectory(easylogging++)
|
||||
add_subdirectory(easylogging++ easyloggingpp)
|
||||
add_subdirectory(randomx EXCLUDE_FROM_ALL)
|
||||
|
||||
# uSockets doesn't really have a proper build system (just a very simple Makefile) so build it
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7e37433f318488ae4bc80f80e12df12a01579874
|
|
@ -1 +1 @@
|
|||
Subproject commit 25f4b8b8a3c0f934158cd37a37b0525d75ca488e
|
||||
Subproject commit e8b989ea1f7f9d4083511a2caec7791e9abd1871
|
|
@ -1 +1 @@
|
|||
Subproject commit 81fda4ecea1921e6b6376f16a3d0cb30c7810bd4
|
||||
Subproject commit 41db8c93d8ccb3b5c85e7f8e9ac424437fb201b7
|
|
@ -74,19 +74,17 @@ add_subdirectory(net)
|
|||
add_subdirectory(mnemonics)
|
||||
add_subdirectory(wallet)
|
||||
add_subdirectory(cryptonote_protocol)
|
||||
add_subdirectory(blockchain_db)
|
||||
add_subdirectory(rpc)
|
||||
add_subdirectory(serialization)
|
||||
add_subdirectory(p2p)
|
||||
add_subdirectory(daemonizer)
|
||||
add_subdirectory(daemon)
|
||||
add_subdirectory(simplewallet)
|
||||
|
||||
if(NOT IOS)
|
||||
if (NOT BUILD_INTEGRATION)
|
||||
add_subdirectory(gen_multisig)
|
||||
add_subdirectory(blockchain_utilities)
|
||||
endif()
|
||||
add_subdirectory(blockchain_db)
|
||||
add_subdirectory(rpc)
|
||||
add_subdirectory(serialization)
|
||||
add_subdirectory(p2p)
|
||||
add_subdirectory(daemonizer)
|
||||
add_subdirectory(daemon)
|
||||
add_subdirectory(simplewallet)
|
||||
if (NOT BUILD_INTEGRATION)
|
||||
add_subdirectory(gen_multisig)
|
||||
add_subdirectory(blockchain_utilities)
|
||||
endif()
|
||||
|
||||
# We'll always add, but with EXCLUDE_FROM_ALL if you didn't ask for them (but this lets you do a
|
||||
|
|
|
@ -37,7 +37,7 @@ target_link_libraries(blockchain_db
|
|||
common
|
||||
ringct
|
||||
lmdb
|
||||
Boost::filesystem
|
||||
filesystem
|
||||
Boost::thread
|
||||
extra)
|
||||
|
||||
|
|
|
@ -29,19 +29,18 @@
|
|||
|
||||
#include "cryptonote_core/service_node_rules.h"
|
||||
#include "checkpoints/checkpoints.h"
|
||||
#include "string_tools.h"
|
||||
#include "epee/string_tools.h"
|
||||
#include "blockchain_db.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "profile_tools.h"
|
||||
#include "epee/profile_tools.h"
|
||||
#include "ringct/rctOps.h"
|
||||
#include "common/hex.h"
|
||||
|
||||
#include "lmdb/db_lmdb.h"
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "blockchain.db"
|
||||
|
||||
using epee::string_tools::pod_to_hex;
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
|
@ -307,7 +306,7 @@ transaction BlockchainDB::get_tx(const crypto::hash& h) const
|
|||
{
|
||||
transaction tx;
|
||||
if (!get_tx(h, tx))
|
||||
throw TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str());
|
||||
throw TX_DNE("tx with hash " + tools::type_to_hex(h) + " not found in db");
|
||||
return tx;
|
||||
}
|
||||
|
||||
|
@ -321,7 +320,7 @@ transaction BlockchainDB::get_pruned_tx(const crypto::hash& h) const
|
|||
{
|
||||
transaction tx;
|
||||
if (!get_pruned_tx(h, tx))
|
||||
throw TX_DNE(std::string("pruned tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str());
|
||||
throw TX_DNE("pruned tx with hash " + tools::type_to_hex(h) + " not found in db");
|
||||
return tx;
|
||||
}
|
||||
|
||||
|
@ -399,7 +398,7 @@ uint64_t BlockchainDB::get_tx_block_height(const crypto::hash &h) const
|
|||
auto result = get_tx_block_heights({{h}}).front();
|
||||
if (result == std::numeric_limits<uint64_t>::max())
|
||||
{
|
||||
std::string err = "tx_data_t with hash " + epee::string_tools::pod_to_hex(h) + " not found in db";
|
||||
std::string err = "tx_data_t with hash " + tools::type_to_hex(h) + " not found in db";
|
||||
LOG_PRINT_L1(err);
|
||||
throw TX_DNE(std::move(err));
|
||||
}
|
||||
|
@ -411,7 +410,7 @@ bool BlockchainDB::get_alt_block_header(const crypto::hash &blkid, alt_block_dat
|
|||
cryptonote::blobdata blob;
|
||||
if (!get_alt_block(blkid, data, &blob, checkpoint))
|
||||
{
|
||||
throw BLOCK_DNE("Alt-block with hash "s.append(epee::string_tools::pod_to_hex(blkid)).append(" not found in db").c_str());
|
||||
throw BLOCK_DNE("Alt-block with hash " + tools::type_to_hex(blkid) + " not found in db");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <exception>
|
||||
#include <boost/program_options.hpp>
|
||||
#include "common/command_line.h"
|
||||
#include "common/fs.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "cryptonote_basic/blobdatatype.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
|
@ -589,10 +590,6 @@ public:
|
|||
* The subclass implementing this will handle all file opening/creation,
|
||||
* and is responsible for maintaining its state.
|
||||
*
|
||||
* The parameter <filename> may not refer to a file name, necessarily, but
|
||||
* could be an IP:PORT for a database which needs it, and so on. Calling it
|
||||
* <filename> is convenient and should be descriptive enough, however.
|
||||
*
|
||||
* For now, db_flags are
|
||||
* specific to the subclass being instantiated. This is subject to change,
|
||||
* and the db_flags parameter may be deprecated.
|
||||
|
@ -600,10 +597,10 @@ public:
|
|||
* If any of this cannot be done, the subclass should throw the corresponding
|
||||
* subclass of DB_EXCEPTION
|
||||
*
|
||||
* @param filename a string referring to the BlockchainDB to open
|
||||
* @param filename a path referring to the BlockchainDB to open
|
||||
* @param db_flags flags relevant to how to open/use the BlockchainDB
|
||||
*/
|
||||
virtual void open(const std::string& filename, cryptonote::network_type nettype, const int db_flags = 0) = 0;
|
||||
virtual void open(const fs::path& filename, cryptonote::network_type nettype, const int db_flags = 0) = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the current open/ready state of the BlockchainDB
|
||||
|
@ -665,7 +662,7 @@ public:
|
|||
*
|
||||
* @return a list of filenames
|
||||
*/
|
||||
virtual std::vector<std::string> get_filenames() const = 0;
|
||||
virtual std::vector<fs::path> get_filenames() const = 0;
|
||||
|
||||
/**
|
||||
* @brief remove file(s) storing the database
|
||||
|
@ -679,7 +676,7 @@ public:
|
|||
*
|
||||
* @return true if the operation is succesfull
|
||||
*/
|
||||
virtual bool remove_data_file(const std::string& folder) const = 0;
|
||||
virtual bool remove_data_file(const fs::path& folder) const = 0;
|
||||
|
||||
// return the name of the folder the db's file(s) should reside in
|
||||
/**
|
||||
|
|
|
@ -28,21 +28,19 @@
|
|||
|
||||
#include "db_lmdb.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#include "string_tools.h"
|
||||
#include "file_io_utils.h"
|
||||
#include "epee/string_tools.h"
|
||||
#include "common/file.h"
|
||||
#include "common/pruning.h"
|
||||
#include "common/hex.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "profile_tools.h"
|
||||
#include "epee/profile_tools.h"
|
||||
#include "ringct/rctOps.h"
|
||||
|
||||
#include "checkpoints/checkpoints.h"
|
||||
|
@ -54,7 +52,6 @@
|
|||
#define LOKI_DEFAULT_LOG_CATEGORY "blockchain.db.lmdb"
|
||||
|
||||
|
||||
using epee::string_tools::pod_to_hex;
|
||||
using namespace crypto;
|
||||
using namespace boost::endian;
|
||||
|
||||
|
@ -260,10 +257,10 @@ constexpr unsigned int LMDB_DB_COUNT = 23; // Should agree with the number of db
|
|||
const char zerokey[8] = {0};
|
||||
const MDB_val zerokval = { sizeof(zerokey), (void *)zerokey };
|
||||
|
||||
const std::string lmdb_error(const std::string& error_string, int mdb_res)
|
||||
const std::string lmdb_error(std::string error_string, int mdb_res)
|
||||
{
|
||||
const std::string full_string = error_string + mdb_strerror(mdb_res);
|
||||
return full_string;
|
||||
error_string += mdb_strerror(mdb_res);
|
||||
return error_string;
|
||||
}
|
||||
|
||||
void lmdb_db_open(MDB_txn* txn, const char* name, int flags, MDB_dbi& dbi, const std::string& error_string)
|
||||
|
@ -608,8 +605,7 @@ void BlockchainLMDB::do_resize(uint64_t increase_size)
|
|||
// check disk capacity
|
||||
try
|
||||
{
|
||||
boost::filesystem::path path(m_folder);
|
||||
boost::filesystem::space_info si = boost::filesystem::space(path);
|
||||
auto si = fs::space(m_folder);
|
||||
if(si.available < add_size)
|
||||
{
|
||||
MERROR("!! WARNING: Insufficient free space to extend database !!: " <<
|
||||
|
@ -957,9 +953,9 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
|||
result = mdb_cursor_get(m_cur_tx_indices, (MDB_val *)&zerokval, &val_h, MDB_GET_BOTH);
|
||||
if (result == 0) {
|
||||
txindex *tip = (txindex *)val_h.mv_data;
|
||||
throw1(TX_EXISTS(std::string("Attempting to add transaction that's already in the db (tx id ").append(boost::lexical_cast<std::string>(tip->data.tx_id)).append(")").c_str()));
|
||||
throw1(TX_EXISTS(std::string("Attempting to add transaction that's already in the db (tx id ").append(std::to_string(tip->data.tx_id)).append(")").c_str()));
|
||||
} else if (result != MDB_NOTFOUND) {
|
||||
throw1(DB_ERROR(lmdb_error(std::string("Error checking if tx index exists for tx hash ") + epee::string_tools::pod_to_hex(tx_hash) + ": ", result).c_str()));
|
||||
throw1(DB_ERROR(lmdb_error("Error checking if tx index exists for tx hash " + tools::type_to_hex(tx_hash) + ": ", result)));
|
||||
}
|
||||
|
||||
const cryptonote::transaction &tx = txp.first;
|
||||
|
@ -1243,12 +1239,12 @@ void BlockchainLMDB::remove_output(const uint64_t amount, const uint64_t& out_in
|
|||
}
|
||||
result = mdb_cursor_del(m_cur_output_txs, 0);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error(std::string("Error deleting output index ").append(boost::lexical_cast<std::string>(out_index).append(": ")).c_str(), result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error(std::string("Error deleting output index ").append(std::to_string(out_index).append(": ")).c_str(), result).c_str()));
|
||||
|
||||
// now delete the amount
|
||||
result = mdb_cursor_del(m_cur_output_amounts, 0);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error(std::string("Error deleting amount for output index ").append(boost::lexical_cast<std::string>(out_index).append(": ")).c_str(), result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error(std::string("Error deleting amount for output index ").append(std::to_string(out_index).append(": ")).c_str(), result).c_str()));
|
||||
}
|
||||
|
||||
void BlockchainLMDB::prune_outputs(uint64_t amount)
|
||||
|
@ -1375,7 +1371,7 @@ BlockchainLMDB::BlockchainLMDB(bool batch_transactions): BlockchainDB()
|
|||
m_hardfork = nullptr;
|
||||
}
|
||||
|
||||
void BlockchainLMDB::open(const std::string& filename, cryptonote::network_type nettype, const int db_flags)
|
||||
void BlockchainLMDB::open(const fs::path& filename, cryptonote::network_type nettype, const int db_flags)
|
||||
{
|
||||
int result;
|
||||
int mdb_flags = MDB_NORDAHEAD;
|
||||
|
@ -1385,24 +1381,23 @@ void BlockchainLMDB::open(const std::string& filename, cryptonote::network_type
|
|||
if (m_open)
|
||||
throw0(DB_OPEN_FAILURE("Attempted to open db, but it's already open"));
|
||||
|
||||
boost::filesystem::path direc(filename);
|
||||
if (boost::filesystem::exists(direc))
|
||||
if (fs::exists(filename))
|
||||
{
|
||||
if (!boost::filesystem::is_directory(direc))
|
||||
if (!fs::is_directory(filename))
|
||||
throw0(DB_OPEN_FAILURE("LMDB needs a directory path, but a file was passed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!boost::filesystem::create_directories(direc))
|
||||
throw0(DB_OPEN_FAILURE(std::string("Failed to create directory ").append(filename).c_str()));
|
||||
if (std::error_code ec; !fs::create_directories(filename, ec))
|
||||
throw0(DB_OPEN_FAILURE("Failed to create directory " + filename.u8string()));
|
||||
}
|
||||
|
||||
// check for existing LMDB files in base directory
|
||||
boost::filesystem::path old_files = direc.parent_path();
|
||||
if (boost::filesystem::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_FILENAME)
|
||||
|| boost::filesystem::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME))
|
||||
auto old_files = filename.parent_path();
|
||||
if (fs::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_FILENAME)
|
||||
|| fs::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME))
|
||||
{
|
||||
LOG_PRINT_L0("Found existing LMDB files in " << old_files.string());
|
||||
LOG_PRINT_L0("Found existing LMDB files in " << old_files.u8string());
|
||||
LOG_PRINT_L0("Move " << CRYPTONOTE_BLOCKCHAINDATA_FILENAME << " and/or " << CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME << " to " << filename << ", or delete them, and then restart");
|
||||
throw DB_ERROR("Database could not be opened");
|
||||
}
|
||||
|
@ -1437,7 +1432,9 @@ void BlockchainLMDB::open(const std::string& filename, cryptonote::network_type
|
|||
if (db_flags & DBF_SALVAGE)
|
||||
mdb_flags |= MDB_PREVSNAPSHOT;
|
||||
|
||||
if (auto result = mdb_env_open(m_env, filename.c_str(), mdb_flags, 0644))
|
||||
// This .string() is probably just going to hard fail on Windows with non-ASCII unicode filenames,
|
||||
// but lmdb doesn't support anything else (and so really we're just hitting an underlying lmdb bug).
|
||||
if (auto result = mdb_env_open(m_env, filename.string().c_str(), mdb_flags, 0644))
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open lmdb environment: ", result).c_str()));
|
||||
|
||||
MDB_envinfo mei;
|
||||
|
@ -1705,28 +1702,21 @@ void BlockchainLMDB::reset()
|
|||
m_cum_count = 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> BlockchainLMDB::get_filenames() const
|
||||
std::vector<fs::path> BlockchainLMDB::get_filenames() const
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
boost::filesystem::path datafile(m_folder);
|
||||
datafile /= CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
|
||||
boost::filesystem::path lockfile(m_folder);
|
||||
lockfile /= CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME;
|
||||
|
||||
filenames.push_back(datafile.string());
|
||||
filenames.push_back(lockfile.string());
|
||||
|
||||
return filenames;
|
||||
std::vector<fs::path> paths;
|
||||
paths.push_back(m_folder / CRYPTONOTE_BLOCKCHAINDATA_FILENAME);
|
||||
paths.push_back(m_folder / CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool BlockchainLMDB::remove_data_file(const std::string& folder) const
|
||||
bool BlockchainLMDB::remove_data_file(const fs::path& folder) const
|
||||
{
|
||||
const std::string filename = folder + "/data.mdb";
|
||||
auto filename = folder / CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
|
||||
try
|
||||
{
|
||||
boost::filesystem::remove(filename);
|
||||
fs::remove(filename);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -1740,7 +1730,7 @@ std::string BlockchainLMDB::get_db_name() const
|
|||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
|
||||
return std::string("lmdb");
|
||||
return "lmdb"s;
|
||||
}
|
||||
|
||||
void BlockchainLMDB::lock()
|
||||
|
@ -2498,7 +2488,7 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h, uint64_t *height) const
|
|||
auto get_result = mdb_cursor_get(m_cur_block_heights, (MDB_val *)&zerokval, &key, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
LOG_PRINT_L3("Block with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
||||
LOG_PRINT_L3("Block with hash " << tools::type_to_hex(h) << " not found in db");
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch block index from hash", get_result).c_str()));
|
||||
|
@ -2623,7 +2613,7 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get timestamp from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- timestamp not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get timestamp from height ").append(std::to_string(height)).append(" failed -- timestamp not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR("Error attempting to retrieve a timestamp from the db"));
|
||||
|
@ -2721,7 +2711,7 @@ size_t BlockchainLMDB::get_block_weight(const uint64_t& height) const
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get block size from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- block size not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get block size from height ").append(std::to_string(height)).append(" failed -- block size not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR("Error attempting to retrieve a block size from the db"));
|
||||
|
@ -2857,7 +2847,7 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t&
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get cumulative difficulty from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- difficulty not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get cumulative difficulty from height ").append(std::to_string(height)).append(" failed -- difficulty not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR("Error attempting to retrieve a cumulative difficulty from the db"));
|
||||
|
@ -2896,7 +2886,7 @@ uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& heigh
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get generated coins from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- block size not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get generated coins from height ").append(std::to_string(height)).append(" failed -- block size not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR("Error attempting to retrieve a total generated coins from the db"));
|
||||
|
@ -2918,7 +2908,7 @@ uint64_t BlockchainLMDB::get_block_long_term_weight(const uint64_t& height) cons
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get block long term weight from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- block info not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get block long term weight from height ").append(std::to_string(height)).append(" failed -- block info not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR("Error attempting to retrieve a long term block weight from the db"));
|
||||
|
@ -2940,7 +2930,7 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height)
|
|||
auto get_result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &result, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get hash from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- hash not in db").c_str()));
|
||||
throw0(BLOCK_DNE(std::string("Attempt to get hash from height ").append(std::to_string(height)).append(" failed -- hash not in db").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a block hash from the db: ", get_result).c_str()));
|
||||
|
@ -3060,14 +3050,14 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const
|
|||
if (get_result == 0)
|
||||
tx_found = true;
|
||||
else if (get_result != MDB_NOTFOUND)
|
||||
throw0(DB_ERROR(lmdb_error(std::string("DB error attempting to fetch transaction index from hash ") + epee::string_tools::pod_to_hex(h) + ": ", get_result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error(std::string("DB error attempting to fetch transaction index from hash ") + tools::type_to_hex(h) + ": ", get_result).c_str()));
|
||||
|
||||
TIME_MEASURE_FINISH(time1);
|
||||
time_tx_exists += time1;
|
||||
|
||||
if (! tx_found)
|
||||
{
|
||||
LOG_PRINT_L1("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
||||
LOG_PRINT_L1("transaction with hash " << tools::type_to_hex(h) << " not found in db");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3096,7 +3086,7 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h, uint64_t& tx_id) const
|
|||
bool ret = false;
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
{
|
||||
LOG_PRINT_L1("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
||||
LOG_PRINT_L1("transaction with hash " << tools::type_to_hex(h) << " not found in db");
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch transaction from hash", get_result).c_str()));
|
||||
|
@ -3117,7 +3107,7 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const
|
|||
MDB_val_set(v, h);
|
||||
auto get_result = mdb_cursor_get(m_cur_tx_indices, (MDB_val *)&zerokval, &v, MDB_GET_BOTH);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
throw1(TX_DNE(lmdb_error(std::string("tx data with hash ") + epee::string_tools::pod_to_hex(h) + " not found in db: ", get_result).c_str()));
|
||||
throw1(TX_DNE(lmdb_error(std::string("tx data with hash ") + tools::type_to_hex(h) + " not found in db: ", get_result).c_str()));
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch tx data from hash: ", get_result).c_str()));
|
||||
|
||||
|
@ -4302,7 +4292,7 @@ void BlockchainLMDB::get_output_key(const epee::span<const uint64_t> &amounts, c
|
|||
MDEBUG("Partial result: " << outputs.size() << "/" << offsets.size());
|
||||
break;
|
||||
}
|
||||
throw1(OUTPUT_DNE((std::string("Attempting to get output pubkey by global index (amount ") + boost::lexical_cast<std::string>(amount) + ", index " + boost::lexical_cast<std::string>(offsets[i]) + ", count " + boost::lexical_cast<std::string>(get_num_outputs(amount)) + "), but key does not exist (current height " + boost::lexical_cast<std::string>(height()) + ")").c_str()));
|
||||
throw1(OUTPUT_DNE((std::string("Attempting to get output pubkey by global index (amount ") + std::to_string(amount) + ", index " + std::to_string(offsets[i]) + ", count " + std::to_string(get_num_outputs(amount)) + "), but key does not exist (current height " + std::to_string(height()) + ")").c_str()));
|
||||
}
|
||||
else if (get_result)
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve an output pubkey from the db", get_result).c_str()));
|
||||
|
@ -4610,7 +4600,7 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const
|
|||
MDB_val val_ret;
|
||||
auto result = mdb_cursor_get(m_cur_hf_versions, &val_key, &val_ret, MDB_SET);
|
||||
if (result == MDB_NOTFOUND || result)
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a hard fork version at height " + boost::lexical_cast<std::string>(height) + " from the db: ", result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a hard fork version at height " + std::to_string(height) + " from the db: ", result).c_str()));
|
||||
|
||||
uint8_t ret = *(const uint8_t*)val_ret.mv_data;
|
||||
return ret;
|
||||
|
@ -4674,7 +4664,7 @@ bool BlockchainLMDB::get_alt_block(const crypto::hash &blkid, alt_block_data_t *
|
|||
return false;
|
||||
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve alternate block " + epee::string_tools::pod_to_hex(blkid) + " from the db: ", result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve alternate block " + tools::type_to_hex(blkid) + " from the db: ", result).c_str()));
|
||||
if (!read_alt_block_data_from_mdb_val(v, data, block, checkpoint))
|
||||
throw0(DB_ERROR("Record size is less than expected"));
|
||||
return true;
|
||||
|
@ -4692,10 +4682,10 @@ void BlockchainLMDB::remove_alt_block(const crypto::hash &blkid)
|
|||
MDB_val v;
|
||||
int result = mdb_cursor_get(m_cur_alt_blocks, &k, &v, MDB_SET);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Error locating alternate block " + epee::string_tools::pod_to_hex(blkid) + " in the db: ", result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error("Error locating alternate block " + tools::type_to_hex(blkid) + " in the db: ", result).c_str()));
|
||||
result = mdb_cursor_del(m_cur_alt_blocks, 0);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Error deleting alternate block " + epee::string_tools::pod_to_hex(blkid) + " from the db: ", result).c_str()));
|
||||
throw0(DB_ERROR(lmdb_error("Error deleting alternate block " + tools::type_to_hex(blkid) + " from the db: ", result).c_str()));
|
||||
}
|
||||
|
||||
uint64_t BlockchainLMDB::get_alt_block_count()
|
||||
|
@ -4747,12 +4737,7 @@ bool BlockchainLMDB::is_read_only() const
|
|||
|
||||
uint64_t BlockchainLMDB::get_database_size() const
|
||||
{
|
||||
uint64_t size = 0;
|
||||
boost::filesystem::path datafile(m_folder);
|
||||
datafile /= CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
|
||||
if (!epee::file_io_utils::get_file_size(datafile.string(), size))
|
||||
size = 0;
|
||||
return size;
|
||||
return fs::file_size(m_folder / CRYPTONOTE_BLOCKCHAINDATA_FILENAME);
|
||||
}
|
||||
|
||||
void BlockchainLMDB::fixup(cryptonote::network_type nettype)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "cryptonote_basic/blobdatatype.h" // for type blobdata
|
||||
#include "ringct/rctTypes.h"
|
||||
#include "common/fs.h"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/tss.hpp>
|
||||
|
||||
|
@ -177,7 +178,7 @@ public:
|
|||
BlockchainLMDB(bool batch_transactions=true);
|
||||
~BlockchainLMDB();
|
||||
|
||||
void open(const std::string& filename, cryptonote::network_type nettype, const int mdb_flags=0) override;
|
||||
void open(const fs::path& filename, cryptonote::network_type nettype, const int mdb_flags=0) override;
|
||||
|
||||
void close() override;
|
||||
|
||||
|
@ -187,9 +188,9 @@ public:
|
|||
|
||||
void reset() override;
|
||||
|
||||
std::vector<std::string> get_filenames() const override;
|
||||
std::vector<fs::path> get_filenames() const override;
|
||||
|
||||
bool remove_data_file(const std::string& folder) const override;
|
||||
bool remove_data_file(const fs::path& folder) const override;
|
||||
|
||||
std::string get_db_name() const override;
|
||||
|
||||
|
@ -490,7 +491,7 @@ private:
|
|||
|
||||
mutable uint64_t m_cum_size; // used in batch size estimation
|
||||
mutable unsigned int m_cum_count;
|
||||
std::string m_folder;
|
||||
fs::path m_folder;
|
||||
mdb_txn_safe* m_write_txn; // may point to either a short-lived txn or a batch txn
|
||||
mdb_txn_safe* m_write_batch_txn; // persist batch txn outside of BlockchainLMDB
|
||||
boost::thread::id m_writer;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <map>
|
||||
#include "blockchain_db.h"
|
||||
#include "cryptonote_core/service_node_list.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
@ -42,13 +43,13 @@ namespace cryptonote
|
|||
class BaseTestDB: public cryptonote::BlockchainDB {
|
||||
public:
|
||||
BaseTestDB() {}
|
||||
virtual void open(const std::string& filename, network_type nettype = FAKECHAIN, const int db_flags = 0) override { }
|
||||
virtual void open(const fs::path& filename, network_type nettype = FAKECHAIN, const int db_flags = 0) override { }
|
||||
virtual void close() override {}
|
||||
virtual void sync() override {}
|
||||
virtual void safesyncmode(const bool onoff) override {}
|
||||
virtual void reset() override {}
|
||||
virtual std::vector<std::string> get_filenames() const override { return std::vector<std::string>(); }
|
||||
virtual bool remove_data_file(const std::string& folder) const override { return true; }
|
||||
virtual std::vector<fs::path> get_filenames() const override { return {}; }
|
||||
virtual bool remove_data_file(const fs::path& folder) const override { return true; }
|
||||
virtual std::string get_db_name() const override { return std::string(); }
|
||||
virtual void lock() override { }
|
||||
virtual bool try_lock() override { return true; }
|
||||
|
|
|
@ -32,7 +32,7 @@ target_link_libraries(blockchain_tools_common_libs INTERFACE
|
|||
cryptonote_core
|
||||
blockchain_db
|
||||
version
|
||||
Boost::filesystem
|
||||
filesystem
|
||||
Boost::program_options
|
||||
extra)
|
||||
|
||||
|
@ -110,7 +110,7 @@ target_link_libraries(blockchain_stats PRIVATE blockchain_tools_common_libs)
|
|||
|
||||
if (TARGET sodium_vendor OR NOT SODIUM_VERSION VERSION_LESS 1.0.17)
|
||||
loki_add_executable(sn_key_tool "loki-sn-keys" sn_key_tool.cpp)
|
||||
target_link_libraries(sn_key_tool PRIVATE sodium lokimq)
|
||||
target_link_libraries(sn_key_tool PRIVATE sodium lokimq filesystem)
|
||||
else()
|
||||
message(STATUS "Not building loki-sn-keys tool (requires libsodium >= 1.0.17)")
|
||||
endif()
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/archive/portable_binary_iarchive.hpp>
|
||||
#include <boost/archive/portable_binary_oarchive.hpp>
|
||||
#include "common/unordered_containers_boost_serialization.h"
|
||||
#include "common/command_line.h"
|
||||
#include "common/varint.h"
|
||||
#include "common/signal_handler.h"
|
||||
#include "common/fs.h"
|
||||
#include "serialization/boost_std_variant.h"
|
||||
#include "cryptonote_basic/cryptonote_boost_serialization.h"
|
||||
#include "cryptonote_core/cryptonote_core.h"
|
||||
|
@ -337,8 +337,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
tools::on_startup();
|
||||
|
||||
boost::filesystem::path output_file_path;
|
||||
|
||||
auto opt_size = command_line::boost_option_sizes();
|
||||
|
||||
po::options_description desc_cmd_only("Command line options", opt_size.first, opt_size.second);
|
||||
|
@ -421,7 +419,7 @@ int main(int argc, char* argv[])
|
|||
uint64_t output_amount = 0, output_offset = 0;
|
||||
if (!opt_txid_string.empty())
|
||||
{
|
||||
if (!epee::string_tools::hex_to_pod(opt_txid_string, opt_txid))
|
||||
if (!tools::hex_to_type(opt_txid_string, opt_txid))
|
||||
{
|
||||
std::cerr << "Invalid txid" << std::endl;
|
||||
return 1;
|
||||
|
@ -447,7 +445,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
LOG_PRINT_L0("database: LMDB");
|
||||
|
||||
const std::string filename = (boost::filesystem::path(opt_data_dir) / db->get_db_name()).string();
|
||||
fs::path filename = fs::u8path(opt_data_dir) / db->get_db_name();
|
||||
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
||||
|
||||
try
|
||||
|
@ -468,9 +466,9 @@ int main(int argc, char* argv[])
|
|||
|
||||
ancestry_state_t state;
|
||||
|
||||
const std::string state_file_path = (boost::filesystem::path(opt_data_dir) / "ancestry-state.bin").string();
|
||||
fs::path state_file_path = fs::u8path(opt_data_dir) / "ancestry-state.bin";
|
||||
LOG_PRINT_L0("Loading state data from " << state_file_path);
|
||||
std::ifstream state_data_in;
|
||||
fs::ifstream state_data_in;
|
||||
state_data_in.open(state_file_path, std::ios_base::binary | std::ios_base::in);
|
||||
if (!state_data_in.fail())
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "common/varint.h"
|
||||
#include "common/file.h"
|
||||
#include "common/signal_handler.h"
|
||||
#include "common/hex.h"
|
||||
#include "serialization/crypto.h"
|
||||
#include "cryptonote_basic/cryptonote_boost_serialization.h"
|
||||
#include "cryptonote_core/cryptonote_core.h"
|
||||
|
@ -132,20 +133,19 @@ static bool parse_db_sync_mode(std::string db_sync_mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::string get_default_db_path()
|
||||
static fs::path get_default_db_path()
|
||||
{
|
||||
boost::filesystem::path dir = tools::get_default_data_dir();
|
||||
// remove .loki, replace with .shared-ringdb
|
||||
dir = dir.remove_filename();
|
||||
dir /= ".shared-ringdb";
|
||||
return dir.string();
|
||||
fs::path p = tools::get_default_data_dir();
|
||||
p.replace_filename(".shared-ringdb");
|
||||
return p;
|
||||
}
|
||||
|
||||
static std::string get_cache_filename(boost::filesystem::path filename)
|
||||
static fs::path get_cache_filename(fs::path filename)
|
||||
{
|
||||
if (!boost::filesystem::is_directory(filename))
|
||||
if (!fs::is_directory(filename))
|
||||
filename.remove_filename();
|
||||
return filename.string();
|
||||
return filename;
|
||||
}
|
||||
|
||||
static int compare_hash32(const MDB_val *a, const MDB_val *b)
|
||||
|
@ -202,11 +202,10 @@ static int resize_env(const char *db_path)
|
|||
{
|
||||
try
|
||||
{
|
||||
boost::filesystem::path path(db_path);
|
||||
boost::filesystem::space_info si = boost::filesystem::space(path);
|
||||
auto si = fs::space(fs::u8path(db_path));
|
||||
if(si.available < needed)
|
||||
{
|
||||
MERROR("!! WARNING: Insufficient free space to extend database !!: " << (si.available >> 20L) << " MB available");
|
||||
MERROR("!! WARNING: Insufficient free space to extend database !!: " << (si.available / 1000000) << " MB available");
|
||||
return ENOSPC;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +220,7 @@ static int resize_env(const char *db_path)
|
|||
return mdb_env_set_mapsize(env, mapsize);
|
||||
}
|
||||
|
||||
static void init(std::string cache_filename)
|
||||
static void init(fs::path cache_filename)
|
||||
{
|
||||
MDB_txn *txn;
|
||||
bool tx_active = false;
|
||||
|
@ -229,7 +228,8 @@ static void init(std::string cache_filename)
|
|||
|
||||
MINFO("Creating spent output cache in " << cache_filename);
|
||||
|
||||
tools::create_directories_if_necessary(cache_filename);
|
||||
if (std::error_code ec; !fs::create_directories(cache_filename, ec))
|
||||
MWARNING("Failed to create output cache directory " << cache_filename << ": " << ec.message());
|
||||
|
||||
int flags = 0;
|
||||
if (db_flags & DBF_FAST)
|
||||
|
@ -241,10 +241,10 @@ static void init(std::string cache_filename)
|
|||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(env, 7);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = get_cache_filename(cache_filename);
|
||||
dbr = mdb_env_open(env, actual_filename.c_str(), flags, 0664);
|
||||
auto actual_filename = get_cache_filename(cache_filename);
|
||||
dbr = mdb_env_open(env, actual_filename.string().c_str(), flags, 0664);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ actual_filename.string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(env, NULL, 0, &txn);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -330,7 +330,7 @@ static std::vector<uint64_t> decompress_ring(const std::string &s)
|
|||
return ring;
|
||||
}
|
||||
|
||||
static bool for_all_transactions(const std::string &filename, uint64_t &start_idx, uint64_t &n_txes, const std::function<bool(const cryptonote::transaction_prefix&)> &f)
|
||||
static bool for_all_transactions(const fs::path& filename, uint64_t& start_idx, uint64_t& n_txes, const std::function<bool(const cryptonote::transaction_prefix&)>& f)
|
||||
{
|
||||
MDB_env *env;
|
||||
MDB_dbi dbi;
|
||||
|
@ -345,10 +345,9 @@ static bool for_all_transactions(const std::string &filename, uint64_t &start_id
|
|||
if (dbr) throw std::runtime_error("Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(env, 2);
|
||||
if (dbr) throw std::runtime_error("Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = filename;
|
||||
dbr = mdb_env_open(env, actual_filename.c_str(), 0, 0664);
|
||||
dbr = mdb_env_open(env, filename.string().c_str(), 0, 0664);
|
||||
if (dbr) throw std::runtime_error("Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ filename.u8string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn);
|
||||
if (dbr) throw std::runtime_error("Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -411,7 +410,7 @@ static bool for_all_transactions(const std::string &filename, uint64_t &start_id
|
|||
return fret;
|
||||
}
|
||||
|
||||
static bool for_all_transactions(const std::string &filename, const uint64_t &start_idx, uint64_t &n_txes, const std::function<bool(bool, uint64_t, const cryptonote::transaction_prefix&)> &f)
|
||||
static bool for_all_transactions(const fs::path& filename, const uint64_t& start_idx, uint64_t& n_txes, const std::function<bool(bool, uint64_t, const cryptonote::transaction_prefix&)>& f)
|
||||
{
|
||||
MDB_env *env;
|
||||
MDB_dbi dbi_blocks, dbi_txs;
|
||||
|
@ -426,14 +425,13 @@ static bool for_all_transactions(const std::string &filename, const uint64_t &st
|
|||
if (dbr) throw std::runtime_error("Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(env, 3);
|
||||
if (dbr) throw std::runtime_error("Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = filename;
|
||||
dbr = mdb_env_open(env, actual_filename.c_str(), 0, 0664);
|
||||
dbr = mdb_env_open(env, filename.string().c_str(), 0, 0664);
|
||||
if (dbr) throw std::runtime_error("Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ filename.u8string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn);
|
||||
if (dbr) throw std::runtime_error("Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
|
||||
LOKI_DEFER { if (tx_active) mdb_txn_abort(txn); };
|
||||
tx_active = true;
|
||||
|
||||
dbr = mdb_dbi_open(txn, "blocks", MDB_INTEGERKEY, &dbi_blocks);
|
||||
|
@ -479,7 +477,7 @@ static bool for_all_transactions(const std::string &filename, const uint64_t &st
|
|||
|
||||
ret = mdb_cursor_get(cur_txs, &k, &v, op_txs);
|
||||
if (ret)
|
||||
throw std::runtime_error("Failed to fetch transaction " + epee::string_tools::pod_to_hex(get_transaction_hash(b.miner_tx)) + ": " + std::string(mdb_strerror(ret)));
|
||||
throw std::runtime_error("Failed to fetch transaction " + tools::type_to_hex(get_transaction_hash(b.miner_tx)) + ": " + std::string(mdb_strerror(ret)));
|
||||
op_txs = MDB_NEXT;
|
||||
|
||||
bool last_block = height == n_blocks - 1;
|
||||
|
@ -493,7 +491,7 @@ static bool for_all_transactions(const std::string &filename, const uint64_t &st
|
|||
const crypto::hash& txid = b.tx_hashes[i];
|
||||
ret = mdb_cursor_get(cur_txs, &k, &v, op_txs);
|
||||
if (ret)
|
||||
throw std::runtime_error("Failed to fetch transaction " + epee::string_tools::pod_to_hex(txid) + ": " + std::string(mdb_strerror(ret)));
|
||||
throw std::runtime_error("Failed to fetch transaction " + tools::type_to_hex(txid) + ": " + std::string(mdb_strerror(ret)));
|
||||
if (start_idx <= tx_idx++)
|
||||
{
|
||||
cryptonote::transaction_prefix tx;
|
||||
|
@ -520,7 +518,7 @@ static bool for_all_transactions(const std::string &filename, const uint64_t &st
|
|||
return fret;
|
||||
}
|
||||
|
||||
static uint64_t find_first_diverging_transaction(const std::string &first_filename, const std::string &second_filename)
|
||||
static uint64_t find_first_diverging_transaction(const fs::path& first_filename, const fs::path& second_filename)
|
||||
{
|
||||
MDB_env *env[2];
|
||||
MDB_dbi dbi[2];
|
||||
|
@ -543,10 +541,10 @@ static uint64_t find_first_diverging_transaction(const std::string &first_filena
|
|||
if (dbr) throw std::runtime_error("Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(env[i], 2);
|
||||
if (dbr) throw std::runtime_error("Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = i ? second_filename : first_filename;
|
||||
dbr = mdb_env_open(env[i], actual_filename.c_str(), 0, 0664);
|
||||
const fs::path& actual_filename = i ? second_filename : first_filename;
|
||||
dbr = mdb_env_open(env[i], actual_filename.string().c_str(), 0, 0664);
|
||||
if (dbr) throw std::runtime_error("Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ actual_filename.u8string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(env[i], NULL, MDB_RDONLY, &txn[i]);
|
||||
if (dbr) throw std::runtime_error("Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -951,7 +949,7 @@ static void inc_stat(MDB_txn *txn, const char *key)
|
|||
set_stat(txn, key, data);
|
||||
}
|
||||
|
||||
static void open_db(const std::string &filename, MDB_env **env, MDB_txn **txn, MDB_cursor **cur, MDB_dbi *dbi)
|
||||
static void open_db(const fs::path& filename, MDB_env** env, MDB_txn** txn, MDB_cursor** cur, MDB_dbi* dbi)
|
||||
{
|
||||
tools::create_directories_if_necessary(filename);
|
||||
|
||||
|
@ -965,11 +963,10 @@ static void open_db(const std::string &filename, MDB_env **env, MDB_txn **txn, M
|
|||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(*env, 1);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = filename;
|
||||
MINFO("Opening monero blockchain at " << actual_filename);
|
||||
dbr = mdb_env_open(*env, actual_filename.c_str(), flags, 0664);
|
||||
MINFO("Opening loki blockchain at " << filename);
|
||||
dbr = mdb_env_open(*env, filename.string().c_str(), flags, 0664);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ filename.u8string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(*env, NULL, MDB_RDONLY, txn);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -1014,7 +1011,7 @@ static void get_num_outputs(MDB_txn *txn, MDB_cursor *cur, MDB_dbi dbi, uint64_t
|
|||
pre_rct = s.ms_entries - rct;
|
||||
}
|
||||
|
||||
static crypto::hash get_genesis_block_hash(const std::string &filename)
|
||||
static crypto::hash get_genesis_block_hash(const fs::path& filename)
|
||||
{
|
||||
MDB_env *env;
|
||||
MDB_dbi dbi;
|
||||
|
@ -1026,10 +1023,9 @@ static crypto::hash get_genesis_block_hash(const std::string &filename)
|
|||
if (dbr) throw std::runtime_error("Failed to create LDMB environment: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_env_set_maxdbs(env, 1);
|
||||
if (dbr) throw std::runtime_error("Failed to set max env dbs: " + std::string(mdb_strerror(dbr)));
|
||||
const std::string actual_filename = filename;
|
||||
dbr = mdb_env_open(env, actual_filename.c_str(), 0, 0664);
|
||||
dbr = mdb_env_open(env, filename.string().c_str(), 0, 0664);
|
||||
if (dbr) throw std::runtime_error("Failed to open rings database file '"
|
||||
+ actual_filename + "': " + std::string(mdb_strerror(dbr)));
|
||||
+ filename.u8string() + "': " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
dbr = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn);
|
||||
if (dbr) throw std::runtime_error("Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -1051,13 +1047,18 @@ static crypto::hash get_genesis_block_hash(const std::string &filename)
|
|||
return genesis_block_hash;
|
||||
}
|
||||
|
||||
static std::vector<std::pair<uint64_t, uint64_t>> load_outputs(const std::string &filename)
|
||||
static std::vector<std::pair<uint64_t, uint64_t>> load_outputs(const fs::path& filename)
|
||||
{
|
||||
std::vector<std::pair<uint64_t, uint64_t>> outputs;
|
||||
uint64_t amount = std::numeric_limits<uint64_t>::max();
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename.c_str(), "r");
|
||||
FILE* f =
|
||||
#ifdef _WIN32
|
||||
_wfopen(filename.c_str(), L"r");
|
||||
#else
|
||||
fopen(filename.c_str(), "r");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
MERROR("Failed to load outputs from " << filename << ": " << strerror(errno));
|
||||
|
@ -1108,9 +1109,15 @@ static std::vector<std::pair<uint64_t, uint64_t>> load_outputs(const std::string
|
|||
return outputs;
|
||||
}
|
||||
|
||||
static bool export_spent_outputs(MDB_cursor *cur, const std::string &filename)
|
||||
static bool export_spent_outputs(MDB_cursor* cur, const fs::path& filename)
|
||||
{
|
||||
FILE *f = fopen(filename.c_str(), "w");
|
||||
FILE* f =
|
||||
#ifdef _WIN32
|
||||
_wfopen(filename.c_str(), L"w");
|
||||
#else
|
||||
fopen(filename.c_str(), "w");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
MERROR("Failed to open " << filename << ": " << strerror(errno));
|
||||
|
@ -1172,15 +1179,13 @@ int main(int argc, char* argv[])
|
|||
|
||||
tools::on_startup();
|
||||
|
||||
boost::filesystem::path output_file_path;
|
||||
|
||||
auto opt_size = command_line::boost_option_sizes();
|
||||
|
||||
po::options_description desc_cmd_only("Command line options", opt_size.first, opt_size.second);
|
||||
po::options_description desc_cmd_sett("Command line options and settings options", opt_size.first, opt_size.second);
|
||||
const command_line::arg_descriptor<std::string> arg_blackball_db_dir = {
|
||||
"spent-output-db-dir", "Specify spent output database directory",
|
||||
get_default_db_path(),
|
||||
get_default_db_path().u8string(),
|
||||
};
|
||||
const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""};
|
||||
const command_line::arg_descriptor<bool> arg_rct_only = {"rct-only", "Only work on ringCT outputs", false};
|
||||
|
@ -1242,7 +1247,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
LOG_PRINT_L0("Starting...");
|
||||
|
||||
output_file_path = command_line::get_arg(vm, arg_blackball_db_dir);
|
||||
fs::path output_file_path = fs::u8path(command_line::get_arg(vm, arg_blackball_db_dir));
|
||||
bool opt_rct_only = command_line::get_arg(vm, arg_rct_only);
|
||||
bool opt_check_subsets = command_line::get_arg(vm, arg_check_subsets);
|
||||
bool opt_verbose = command_line::get_arg(vm, arg_verbose);
|
||||
|
@ -1260,7 +1265,9 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
const std::vector<std::string> inputs = command_line::get_arg(vm, arg_inputs);
|
||||
std::vector<fs::path> inputs;
|
||||
for (auto& in : command_line::get_arg(vm, arg_inputs))
|
||||
inputs.push_back(fs::u8path(in));
|
||||
if (inputs.empty())
|
||||
{
|
||||
LOG_PRINT_L0("No inputs given");
|
||||
|
@ -1274,7 +1281,7 @@ int main(int argc, char* argv[])
|
|||
core_storage[n] = &(blockchain_objects->m_blockchain);
|
||||
}
|
||||
|
||||
const std::string cache_dir = (output_file_path / "spent-outputs-cache").string();
|
||||
fs::path cache_dir = output_file_path / "spent-outputs-cache";
|
||||
init(cache_dir);
|
||||
|
||||
LOG_PRINT_L0("Scanning for spent outputs...");
|
||||
|
@ -1283,14 +1290,14 @@ int main(int argc, char* argv[])
|
|||
|
||||
const uint64_t start_blackballed_outputs = get_num_spent_outputs();
|
||||
|
||||
tools::ringdb ringdb(output_file_path.string(), epee::string_tools::pod_to_hex(get_genesis_block_hash(inputs[0])));
|
||||
tools::ringdb ringdb(output_file_path.string(), tools::type_to_hex(get_genesis_block_hash(inputs[0])));
|
||||
|
||||
bool stop_requested = false;
|
||||
tools::signal_handler::install([&stop_requested](int type) {
|
||||
stop_requested = true;
|
||||
});
|
||||
|
||||
int dbr = resize_env(cache_dir.c_str());
|
||||
int dbr = resize_env(cache_dir.string().c_str());
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to resize LMDB database: " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
// open first db
|
||||
|
@ -1395,7 +1402,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
for (size_t n = 0; n < inputs.size(); ++n)
|
||||
{
|
||||
const std::string canonical = boost::filesystem::canonical(inputs[n]).string();
|
||||
const std::string canonical = fs::canonical(inputs[n]).u8string();
|
||||
uint64_t start_idx = get_processed_txidx(canonical);
|
||||
if (n > 0 && start_idx == 0)
|
||||
{
|
||||
|
@ -1410,10 +1417,9 @@ int main(int argc, char* argv[])
|
|||
dbr = mdb_cursor_open(txn, dbi_spent, &cur);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to open LMDB cursor: " + std::string(mdb_strerror(dbr)));
|
||||
size_t records = 0;
|
||||
const std::string filename = inputs[n];
|
||||
std::vector<std::pair<uint64_t, uint64_t>> blackballs;
|
||||
uint64_t n_txes;
|
||||
for_all_transactions(filename, start_idx, n_txes, [&](const cryptonote::transaction_prefix &tx)->bool
|
||||
for_all_transactions(inputs[n], start_idx, n_txes, [&](const cryptonote::transaction_prefix &tx)->bool
|
||||
{
|
||||
std::cout << "\r" << start_idx << "/" << n_txes << " \r" << std::flush;
|
||||
for (const auto &in: tx.vin)
|
||||
|
@ -1573,7 +1579,7 @@ int main(int argc, char* argv[])
|
|||
mdb_cursor_close(cur);
|
||||
dbr = mdb_txn_commit(txn);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to commit txn creating/opening database: " + std::string(mdb_strerror(dbr)));
|
||||
int dbr = resize_env(cache_dir.c_str());
|
||||
int dbr = resize_env(cache_dir.string().c_str());
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to resize LMDB database: " + std::string(mdb_strerror(dbr)));
|
||||
dbr = mdb_txn_begin(env, NULL, 0, &txn);
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
|
||||
|
@ -1613,7 +1619,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
LOG_PRINT_L0("Secondary pass on " << work_spent.size() << " spent outputs");
|
||||
|
||||
int dbr = resize_env(cache_dir.c_str());
|
||||
int dbr = resize_env(cache_dir.string().c_str());
|
||||
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to resize LMDB database: " + std::string(mdb_strerror(dbr)));
|
||||
|
||||
MDB_txn *txn;
|
||||
|
|
|
@ -49,8 +49,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
tools::on_startup();
|
||||
|
||||
boost::filesystem::path output_file_path;
|
||||
|
||||
auto opt_size = command_line::boost_option_sizes();
|
||||
|
||||
po::options_description desc_cmd_only("Command line options", opt_size.first, opt_size.second);
|
||||
|
@ -98,7 +96,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
LOG_PRINT_L0("Starting...");
|
||||
|
||||
std::string opt_data_dir = command_line::get_arg(vm, cryptonote::arg_data_dir);
|
||||
bool opt_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
|
||||
bool opt_devnet = command_line::get_arg(vm, cryptonote::arg_devnet_on);
|
||||
network_type net_type = opt_testnet ? TESTNET : opt_devnet ? DEVNET : MAINNET;
|
||||
|
@ -114,7 +111,7 @@ int main(int argc, char* argv[])
|
|||
crypto::hash opt_txid = crypto::null_hash;
|
||||
if (!opt_txid_string.empty())
|
||||
{
|
||||
if (!epee::string_tools::hex_to_pod(opt_txid_string, opt_txid))
|
||||
if (!tools::hex_to_type(opt_txid_string, opt_txid))
|
||||
{
|
||||
std::cerr << "Invalid txid" << std::endl;
|
||||
return 1;
|
||||
|
@ -132,7 +129,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
LOG_PRINT_L0("database: LMDB");
|
||||
|
||||
const std::string filename = (boost::filesystem::path(opt_data_dir) / db->get_db_name()).string();
|
||||
const fs::path filename = fs::u8path(command_line::get_arg(vm, cryptonote::arg_data_dir)) / db->get_db_name();
|
||||
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
||||
|
||||
try
|
||||
|
|
|
@ -51,8 +51,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
tools::on_startup();
|
||||
|
||||
boost::filesystem::path output_file_path;
|
||||
|
||||
auto opt_size = command_line::boost_option_sizes();
|
||||
|
||||
po::options_description desc_cmd_only("Command line options", opt_size.first, opt_size.second);
|
||||
|
@ -111,14 +109,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
bool opt_blocks_dat = command_line::get_arg(vm, arg_blocks_dat);
|
||||
|
||||
std::string m_config_folder;
|
||||
|
||||
m_config_folder = command_line::get_arg(vm, cryptonote::arg_data_dir);
|
||||
auto config_folder = fs::u8path(command_line::get_arg(vm, cryptonote::arg_data_dir));
|
||||
|
||||
fs::path output_file_path;
|
||||
if (command_line::has_arg(vm, arg_output_file))
|
||||
output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file));
|
||||
output_file_path = fs::u8path(command_line::get_arg(vm, arg_output_file));
|
||||
else
|
||||
output_file_path = boost::filesystem::path(m_config_folder) / "export" / BLOCKCHAIN_RAW;
|
||||
output_file_path = config_folder / "export" / BLOCKCHAIN_RAW;
|
||||
LOG_PRINT_L0("Export output file: " << output_file_path.string());
|
||||
|
||||
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
|
||||
|
@ -132,9 +129,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
LOG_PRINT_L0("database: LMDB");
|
||||
|
||||
boost::filesystem::path folder(m_config_folder);
|
||||
folder /= db->get_db_name();
|
||||
const std::string filename = folder.string();
|
||||
auto filename = config_folder / db->get_db_name();
|
||||
|
||||
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
||||
try
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue