Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
4egod committed Apr 6, 2018
1 parent 754e5a8 commit 29adade
Show file tree
Hide file tree
Showing 177 changed files with 2,682 additions and 1,641 deletions.
108 changes: 68 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers, The Bitsum Foundation.
# Licensed under the GNU Lesser General Public License. See LICENSING.md for details.
# Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers.
# Licensed under the GNU Lesser General Public License. See LICENSE for details.

cmake_minimum_required(VERSION 3.5)
project(bitsum_core)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 14)
message(STATUS "Bitsumd profile: According to cmake, sizeof(void *) == " ${CMAKE_SIZEOF_VOID_P})
set(CMAKE_C_STANDARD 11)
# message(STATUS "Bitsumd profile: According to cmake, sizeof(void *) == " ${CMAKE_SIZEOF_VOID_P})
option(USE_INSTRUMENTATION "For testing - builds with address sanitizer instrument" OFF)
option(THREAD_SANITIZER "For testing - builds with thread sanitizer instrument, USE_INSTRUMENTATION must be also set" OFF)
option(WITH_THREAD_SANITIZER "For testing - builds with thread sanitizer instrument, USE_INSTRUMENTATION must be also set" OFF)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
option(BYTECOIN_SQLITE "Builds with sqlite instead of lmdb. 4x slower, but works on 32-bit and mobile platforms" OFF)
option(USE_SQLITE "Builds with SQLite instead of LMDB. 4x slower, but works on 32-bit and mobile platforms" OFF)
option(USE_SSL "Builds with support of https between wallet-rpc and bitsumd" OFF)
else()
option(BYTECOIN_SQLITE "Builds with sqlite instead of lmdb. 4x slower, but works on 32-bit and mobile platforms" ON)
option(USE_SQLITE "Builds with sqlite instead of LMDB. 4x slower, but works on 32-bit and mobile platforms" ON)
option(USE_SSL "Builds with support of https between wallet-rpc and bitsumd" OFF)
endif()
option(BYTECOIN_SSL "Builds bitsumd capable of serving json requests via https" OFF)
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
add_definitions(-D_SCL_SECURE_NO_WARNINGS=1 -D_CRT_SECURE_NO_WARNINGS=1 -D_WIN32_WINNT=0x0501)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -g -O2 -Wall -Wextra -Wno-strict-aliasing -Werror=return-type -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -g -O2 -Wall -Wextra -Wno-strict-aliasing -Werror=return-type -Wno-unused-parameter")
message(STATUS "Using instrumentation: " ${USE_INSTRUMENTATION})
message(STATUS "Using thread sanitizer: " ${THREAD_SANITIZER})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -g -O2 -Wall -Wextra -Werror=return-type -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -g -O2 -Wall -Wextra -Werror=return-type -Wno-unused-parameter")
message(STATUS "Instrumentation usage: " ${USE_INSTRUMENTATION})
message(STATUS "Thread sanitizer usage: " ${WITH_THREAD_SANITIZER})
if(USE_INSTRUMENTATION)
if(THREAD_SANITIZER)
if(WITH_THREAD_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
else()
Expand All @@ -32,34 +35,56 @@ else()
endif()
endif()
endif()
if(BYTECOIN_SQLITE)
# requires dl on Linux, we add it unconditionally for simplicity
message(STATUS "Bitsumd profile: database selected - SQLite 3 (make sure it is put into ../sqlite/)")
if(USE_SQLITE)
# Requires dl on Linux, we add it unconditionally for simplicity.
message(STATUS "Database selected: SQLite 3. Make sure it is put into ../sqlite/")
include_directories(../sqlite)
set(SRC_DB ../sqlite/sqlite3.c src/platform/DBsqlite3.cpp src/platform/DBsqlite3.hpp)
add_definitions(-DBYTECOIN_SQLITE=1)
add_definitions(-Dplatform_USE_SQLITE=1)
else()
message(STATUS "Bitsumd profile: database selected - LMDB (make sure it is put into ../lmdb/)")
message(STATUS "Database selected: LMDB. Make sure it is put into ../lmdb/")
include_directories(../lmdb/libraries/liblmdb)
set(SRC_DB ../lmdb/libraries/liblmdb/mdb.c ../lmdb/libraries/liblmdb/midl.c src/platform/DBlmdb.cpp src/platform/DBlmdb.hpp)
endif()
if(BYTECOIN_SSL)
message(STATUS "Bitsumd profile: SSL enabled, make sure openssl headers are in ../openssl/include and static libs are in ../openssl/")
if(USE_SSL)
message(STATUS "SSL usage: ON. Make sure openssl headers are in ../openssl/include and static libs are in ../openssl/")
include_directories(../openssl/include)
link_directories(../openssl) # must be placed before add_executable, add_library
link_directories(../openssl) # Must be placed before add_executable, add_library.
set(LINK_OPENSSL ssl crypto)
add_definitions(-DBYTECOIN_SSL=1)
add_definitions(-Dplatform_USE_SSL=1)
else()
message(STATUS "SSL usage: OFF")
endif()
file(GLOB SRC_BITSUM src/bitsum/*.cpp src/bitsum/*.hpp)
file(GLOB SRC_CRYPTO src/crypto/*.cpp src/crypto/*.c src/crypto/*.h src/crypto/*.hpp)
file(GLOB SRC_CRYPTO
src/crypto/*.cpp src/crypto/*.hpp src/crypto/*.h
src/crypto/blake256.c
src/crypto/chacha8.c
src/crypto/crypto-ops-data.c
src/crypto/crypto-ops.c
src/crypto/crypto-util.c
src/crypto/groestl.c
src/crypto/hash-extra-blake.c
src/crypto/hash-extra-groestl.c
src/crypto/hash-extra-jh.c
src/crypto/hash-extra-skein.c
src/crypto/hash.c
src/crypto/jh.c
src/crypto/keccak.c
src/crypto/oaes_lib.c
src/crypto/random.c
src/crypto/skein.c
src/crypto/slow-hash_x86.c
src/crypto/tree-hash.c
)
file(GLOB SRC_COMMON src/common/*.cpp src/common/*.hpp)
file(GLOB SRC_SERIALIZATION src/Serialization/*.cpp src/Serialization/*.hpp)
file(GLOB SRC_SERIA src/seria/*.cpp src/seria/*.hpp)
file(GLOB SRC_LOGGING src/logging/*.cpp src/logging/*.hpp)
file(GLOB SRC_P2P src/p2p/*.cpp src/p2p/*.hpp)
file(GLOB SRC_CORE src/Core/*.cpp src/Core/*.hpp src/Core/*.h)
file(GLOB SRC_HTTP src/http/*.cpp src/http/*.hpp)
file(GLOB SRC_PLATFORM
file(GLOB SRC_PLATFORM
src/platform/ExclusiveLock.cpp src/platform/ExclusiveLock.hpp
src/platform/Files.cpp src/platform/Files.hpp
src/platform/Network.cpp src/platform/Network.hpp
Expand Down Expand Up @@ -99,44 +124,47 @@ set(SOURCE_FILES
src/version.hpp
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs")
if(WIN32)
include_directories(SYSTEM $ENV{BOOST_INCLUDEDIR})
link_directories(SYSTEM $ENV{BOOST_LIBRARYDIR}) # must be before add_executable, add_library
include_directories(SYSTEM ../boost)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
link_directories(SYSTEM ../boost/stage/lib) # must be before add_executable, add_library
else()
link_directories(SYSTEM ../boost/stage32/lib) # must be before add_executable, add_library
endif()
endif()
add_library(bitsum SHARED ${SRC_BITSUM})
add_library(bitsum-crypto ${SRC_CRYPTO})
add_library(bitsum-core ${SOURCE_FILES})
target_link_libraries(bitsum-core bitsum-crypto)
if(WIN32)
add_executable(walletd src/main_walletd.cpp src/bitsum.rc) # .rc works only if referenced directly in add_executable
add_executable(bitsumd src/main_bytecoind.cpp src/bitsum.rc) # .rc works only if referenced directly in add_executable
add_executable(wallet-rpc src/main_wallet_rpc.cpp src/bitsum.rc) # .rc works only if referenced directly in add_executable
add_executable(bitsumd src/main_bitsumd.cpp src/bitsum.rc) # .rc works only if referenced directly in add_executable
else()
add_executable(walletd src/main_walletd.cpp)
add_executable(bitsumd src/main_bytecoind.cpp)
add_executable(wallet-rpc src/main_wallet_rpc.cpp)
add_executable(bitsumd src/main_bitsumd.cpp)
endif()
#add_executable(tests src/main_tests.cpp tests/crypto/test_crypto.cpp tests/hash/test_hash.cpp tests/json/test_json.cpp)
set(Boost_USE_STATIC_LIBS OFF)
#add_executable(tests src/main_tests.cpp tests/io.hpp tests/crypto/test_crypto.cpp tests/hash/test_hash.cpp tests/json/test_json.cpp)
set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS=1 -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE=1) # boost::_1 conflicts with std::_1
target_link_libraries(bitsum bitsum-crypto bitsum-core)
target_link_libraries(walletd bitsum-crypto bitsum-core)
target_link_libraries(wallet-rpc bitsum-crypto bitsum-core)
target_link_libraries(bitsumd bitsum-crypto bitsum-core)
#target_link_libraries(tests bytecoin-crypto bytecoin-core)
#target_link_libraries(tests bitsum-crypto bitsum-core)
if(WIN32)
else()
#set(BOOST_ROOT ../boost)
set(BOOST_ROOT ../boost)
set(Boost_USE_MULTITHREADED OFF) # all boost libraries are multithreaded since some version
find_package(Boost 1.56 REQUIRED COMPONENTS system)

find_package(Boost 1.62 REQUIRED COMPONENTS system)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11")
target_link_libraries(walletd "-framework Foundation" "-framework IOKit")
target_link_libraries(wallet-rpc "-framework Foundation" "-framework IOKit")
target_link_libraries(bitsumd "-framework Foundation" "-framework IOKit")
endif()
target_link_libraries(bitsum ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
target_link_libraries(walletd ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
target_link_libraries(wallet-rpc ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
target_link_libraries(bitsumd ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
# target_link_libraries(tests ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
#target_link_libraries(tests ${Boost_LIBRARIES} ${LINK_OPENSSL} dl pthread)
endif()
89 changes: 53 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ All commands below are adapted for Ubuntu, other distributions may need an other

### Building with standard options

Create directory `bitsum` somewhere and go there:
```
$> mkdir bitsum
$> cd bitsum
```

To go futher you have to have a number of packages and utilities.

* `build-essential` package:
Expand All @@ -30,18 +36,19 @@ To go futher you have to have a number of packages and utilities.
```
If version is too old, follow instructions on [the official site](https://cmake.org/download/).
* Boost (1.58 or newer):
* Boost (1.62 or newer):
```
$> sudo apt-get install libboost-all-dev
$> cat /usr/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
```
If version is too old, follow instructions on [the official site](http://www.boost.org/users/download/).
Then create directory `bitsum` somewhere and go there:
```
$> mkdir bitsum
$> cd bitsum
```
If version is too old, download boost from [boost.org](https://boost.org), unpack it into a folder inside `bitsum` and rename it from `boost_1_66_0` or similar to just `boost`
Build boost
```
$> cd boost
$bitsum/boost> ./bootstrap.sh
$bitsum/boost> ./b2 link=static -j 8 --build-dir=build64 --stagedir=stage
cd ..
```
Git-clone (or git-pull) Bitsum Core source code in that folder:
```
Expand All @@ -53,17 +60,17 @@ Put LMDB source code in `bitsum` folder (source files are referenced via relativ
$bitsum> git clone https://github.com/LMDB/lmdb.git
```
Create build directory inside bitsum_core, go there and run CMake and Make:
Create build directory inside bytecoin, go there and run CMake and Make:
```
$bitsum> mkdir bitsum_core/build
$bitsum> cd bitsum_core/build
$bitsum/bitsum_core/build> cmake ..
$bitsum/bitsum_core/build> cmake -DUSE_SSL=0 ..
$bitsum/bitsum_core/build> time make -j4
```
Check built binaries by running them from `../bin` folder
```
$bitsum/bitsum_core/build> ../bin/bitsumd -v
$bitsum/bitsum_core/build> ../bin/bytecoind -v
```
### Building with specific options
Expand All @@ -72,7 +79,7 @@ Install OpenSSL to `bitsum/openssl` folder. (Use switch `linux-x86_64-clang` ins
```
$bitsum> git clone https://github.com/openssl/openssl.git
$bitsum> cd openssl
$bitsum/openssl> ./Configure linux-x86_64
$bitsum/openssl> ./Configure linux-x86_64 no-shared
$bitsum/openssl> time make -j4
$bitsum/openssl> cd ..
```
Expand All @@ -84,7 +91,7 @@ Below are the commands which add OpenSSL support and switch from LMDB to SQLite
```
$bitsum> mkdir bitsum_core/build
$bitsum> cd bitsum_core/build
$bitsum/bitsum_core/build> cmake -DBYTECOIN_SSL=1 -DBYTECOIN_SQLITE=1 ..
$bitsum/bitsum_core/build> cmake -DUSE_SSL=1 -DUSE_SQLITE=1 ..
$bitsum/bitsum_core/build> time make -j4
```
Expand Down Expand Up @@ -119,7 +126,7 @@ Create build directory inside bitsum_core, go there and run CMake and Make:
```
$bitsum> mkdir bitsum_core/build
$bitsum> cd bitsum_core/build
$bitsum/bitsum_core/build> cmake ..
$bitsum/bitsum_core/build> cmake -DUSE_SSL=0 ..
$bitsum/bitsum_core/build> time make -j4
```
Expand Down Expand Up @@ -172,54 +179,64 @@ You add OpenSSL support or switch from LMDB to SQLite by providing options to CM
```
$bitsum> mkdir bitsum_core/build
$bitsum> cd bitsum_core/build
$bitsum/bitsum_core/build> cmake -DBYTECOIN_SSL=1 -DBYTECOIN_SQLITE=1 ..
$bitsum/bitsum_core/build> cmake -DUSE_SSL=1 -DUSE_SQLITE=1 ..
$bitsum/bitsum_core/build> time make -j4
```
## Building on Windows
You need Microsoft Visual Studio Community 2017. [Download](https://microsoft.com) and install it selecting `C++`, `git`, `cmake integration` packages.
Get [Boost](https://boost.org) and unpack it into a folder of your choice. We will use `C:\boost_1_58_0` in the further examples.
Run `Visual Studio x64 command prompt` from start menu.
Build boost
Create directory `bitsum` somewhere:
```
$> cd C:\boost_1_58_0
$C:\boost_1_58_0> bootstrap.bat
$C:\boost_1_58_0> b2.exe address-model=64 link=static
$C:\> mkdir bitsum
$C:\> cd bitsum
```
Set boost environment variables, right-click Computer in start menu, select `Properties`, then click `advanced system settings`, `environment variables`.
Get [Boost](https://boost.org) and unpack it into a folder inside `bitsum` and rename it from `boost_1_66_0` or similar to just `boost`.
Set `BOOST_ROOT` to `C:\boost_1_58_0`
Set `BOOST_INCLUDEDIR` to `C:\boost_1_58_0`
Set `BOOST_LIBRARYDIR` to `C:\boost_1_58_0\stage\lib`
Now create directory `bitsum` somewhere
Build boost (build 32-bit boost version only if you need 32-bit Bitsum Core binaries).
```
$C:\> mkdir bitsum
$C:\> cd bitsum
$> cd boost
$C:\bitsum\boost> bootstrap.bat
$C:\bitsum\boost> b2.exe address-model=64 link=static -j 8 --build-dir=build64 --stagedir=stage
$C:\bitsum\boost> b2.exe address-model=32 link=static -j 8 --build-dir=build32 --stagedir=stage32
cd ..
```
You need Bitsum Core source code
Git-clone (or git-pull) Bitsum Core source code in that folder:
```
$C:\bitsum> git clone https://github.com/BitsumFoundation/bitsum_core.git
```
You need lmdb in the same folder (source files are referenced via relative paths, so you do not need to separately build it)
Put LMDB in the same folder (source files are referenced via relative paths, so you do not need to separately build it):
```
$C:\bitsum> git clone https://github.com/LMDB/lmdb.git
```
You need to build openssl, first install ActivePerl (select "add to PATH" option, then restart console):
```
$C:\bitsum> git clone https://github.com/openssl/openssl.git
$C:\bitsum> cd openssl
$C:\bitsum\openssl> perl Configure VC-WIN64A no-shared no-asm
$C:\bitsum\openssl> nmake
$C:\bitsum\openssl> cd ..
```
If you want to build 32-bit binaries, you will also need 32-bit build of openssl in separate folder (configuring openssl changes header files, so there is no way to have both 32-bit and 64-bit versions in the same folder):
```
$C:\bitsum> git clone https://github.com/openssl/openssl.git openssl32
$C:\bitsum> cd openssl32
$C:\bitsum\openssl> perl Configure VC-WIN32 no-shared no-asm
$C:\bitsum\openssl> nmake
$C:\bitsum\openssl> cd ..
```
Now launch Visual Studio, in File menu select `Open Folder`, select `C:\bitsum\bitsum_core` folder.
Wait until CMake finishes running and `Build` appears in main menu.
Select `x64-Debug` or `x64-Release` from standard toolbar, and then `Build/Build Solution` from the main menu.
You cannot add options to CMake running inside Visual Studio so just edit `CMakeLists.txt` and set `BYTECOIN_SSL` or `BYTECOIN_SQLITE` to `ON` if you wish to build with them.
You cannot add options to CMake running inside Visual Studio so just edit `CMakeLists.txt` and set `USE_SSL` or `USE_SQLITE` to `ON` if you wish to build with them.
## Building on 32-bit x86 platforms, iOS, Android and other ARM platforms
Expand All @@ -229,7 +246,7 @@ Therefore SQLite option is automatically selected by CMake on 32-bit platforms a
We build official x86 32-bit version for Windows only, because there is zero demand for 32-bit version for Linux or Mac.
Building source code for iOS, Android, Raspberry PI, etc is possible but requires major skills on your part. __TBD__
Building source code for iOS, Android, Raspberry PI, etc is possible (we have experimental `bytecoind` and `walletd` running on ARM64 iPhone) but requires major skills on your part. __TBD__
## Building on Big-Endian platforms
Expand Down
4 changes: 3 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Release Notes

### v0.18.3.18 (BETA)
### v1.18.4.5
- Merge code with bytecoin v3.0.0

### v0.18.3.18 (BETA)
- Project is moved to the new public GitHub repository.
Loading

0 comments on commit 29adade

Please sign in to comment.