Skip to content

Commit fd408f0

Browse files
committed
Merge 'hardfork' branch, apply minor fixes
Resolved conflicts: - libraries/chain/db_market.cpp - tests/tests/settle_tests.cpp
2 parents 4cb30cd + a2fc464 commit fd408f0

File tree

247 files changed

+21664
-7493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+21664
-7493
lines changed

.travis.yml

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
language: c++
22

3-
cache: ccache
3+
cache:
4+
ccache: true
5+
directories:
6+
- sonar_cache
47

58
git:
69
depth: 1
@@ -24,19 +27,11 @@ env:
2427
- CCACHE_MAXSIZE=1Gi
2528
- CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros
2629

27-
script:
28-
- programs/build_helpers/buildstep -s 3500
29-
- ccache -s
30-
- programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
31-
- programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
32-
- programs/build_helpers/buildstep make.cli_wallet 2200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet witness_node js_operation_serializer get_dev_key network_mapper"
33-
- programs/build_helpers/buildstep make.chain_test 1000 "make -j 2 chain_test"
34-
- programs/build_helpers/buildstep make.cli_test 200 "make -j 2 cli_test"
35-
- programs/build_helpers/buildstep make.perf_test 120 "make -j 2 performance_test"
36-
- set -o pipefail
37-
- programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test"
38-
- programs/build_helpers/buildstep run.cli_test 60 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test"
39-
- 'programs/build_helpers/buildstep prepare.sonar 20 "find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o \"\$d\" \"\${d/CMakeFiles*.dir//}\"/*.cpp; done >/dev/null; programs/build_helpers/set_sonar_branch sonar-project.properties" || true'
40-
- 'programs/build_helpers/buildstep run.sonar 1200 "which sonar-scanner && sonar-scanner" || true'
41-
- programs/build_helpers/buildstep end 0
42-
- ccache -s
30+
jobs:
31+
include:
32+
- stage: build for cache
33+
script: ./programs/build_helpers/build_protocol
34+
- stage: build, test and scan partly with sonar
35+
script: ./programs/build_helpers/build_and_test
36+
- stage: scan fully with sonar
37+
script: ./programs/build_helpers/scan_with_sonar

CMakeLists.txt

+180-48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Defines BitShares library target.
2-
project( BitShares )
3-
cmake_minimum_required( VERSION 3.1 )
2+
cmake_minimum_required( VERSION 3.2 FATAL_ERROR )
3+
project( BitShares LANGUAGES CXX C)
44

55
set( BLOCKCHAIN_NAME "BitShares" )
66

@@ -11,7 +11,13 @@ set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" )
1111

1212
set( CMAKE_CXX_STANDARD 14 )
1313
set( CMAKE_CXX_STANDARD_REQUIRED ON )
14-
set( CMAKE_CXX_EXTENSIONS OFF )
14+
15+
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
16+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
17+
set( CMAKE_CXX_EXTENSIONS ON ) # for __int128 support
18+
else()
19+
set( CMAKE_CXX_EXTENSIONS OFF )
20+
endif()
1521

1622
# http://stackoverflow.com/a/18369825
1723
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@@ -22,25 +28,137 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2228
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
2329
message(FATAL_ERROR "Clang version must be at least 3.3!")
2430
endif()
31+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
32+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "19.0")
33+
message(FATAL_ERROR "MSVC version must be at least 19.0 (Visual Studio 2015 Update 1)!")
34+
endif()
35+
36+
# allow MSVC VS2015 with Update 1, other 2015 versions are not supported
37+
if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_EQUAL "19.0")
38+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "19.0.23506.0")
39+
message(FATAL_ERROR "Your version ${CMAKE_CXX_COMPILER_VERSION} of MSVC is not supported, use version 19.0.23506.0 (Visual Studio 2015 Update 1)!")
40+
endif()
41+
endif()
2542
endif()
2643

2744
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
2845

29-
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
30-
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/libraries/egenesis/genesis.json" )
46+
include(CheckCCompilerFlag)
47+
include(Utils)
48+
49+
# function to help with cUrl
50+
macro(FIND_CURL)
51+
if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
52+
find_package(OpenSSL REQUIRED)
53+
set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
54+
set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
55+
find_package(CURL REQUIRED)
56+
list(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES} ${BOOST_THREAD_LIBRARY} ${CMAKE_DL_LIBS})
57+
set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
58+
else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
59+
find_package(CURL REQUIRED)
60+
endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
61+
62+
if( WIN32 )
63+
if ( MSVC )
64+
list( APPEND CURL_LIBRARIES Wldap32 )
65+
endif( MSVC )
66+
67+
if( MINGW )
68+
# MinGW requires a specific order of included libraries ( CURL before ZLib )
69+
find_package( ZLIB REQUIRED )
70+
list( APPEND CURL_LIBRARIES ${ZLIB_LIBRARY} pthread )
71+
endif( MINGW )
72+
73+
list( APPEND CURL_LIBRARIES ${PLATFORM_SPECIFIC_LIBS} )
74+
endif( WIN32 )
75+
endmacro()
76+
77+
# Save the old value of CMAKE_REQUIRED_FLAGS
78+
set( TEMP_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
79+
80+
# Fortify source
81+
if (CMAKE_COMPILER_IS_GNUCXX)
82+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
83+
message (STATUS "Setting optimizations for clang++")
84+
set(CMAKE_CXX_FLAGS_RELEASE "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1")
85+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1 -g")
86+
87+
# check and add data execution prevention
88+
message (STATUS "Enabling data execution prevention")
89+
add_linker_flag("-fsanitize=safe-stack")
90+
91+
# check and add Stack-based buffer overrun detection
92+
set(CMAKE_REQUIRED_FLAGS "-fstack-protector")
93+
check_c_compiler_flag("" HAVE_STACKPROTECTOR)
94+
if(HAVE_STACKPROTECTOR)
95+
message (STATUS "Enabling stack-based buffer overrun detection")
96+
add_flag_append(CMAKE_C_FLAGS "-fstack-protector")
97+
add_flag_append(CMAKE_CXX_FLAGS "-fstack-protector")
98+
endif()
99+
else ()
100+
message (STATUS "Setting optimizations for g++")
101+
set(CMAKE_CXX_FLAGS_RELEASE "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1")
102+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-D_FORTIFY_SOURCE=2 -O3 -DNDEBUG=1 -g")
103+
104+
# check and add data execution prevention
105+
set(CMAKE_REQUIRED_FLAGS "-Wl,-znoexecstack")
106+
check_c_compiler_flag("" HAVE_NOEXECSTACK)
107+
if(HAVE_NOEXECSTACK)
108+
message (STATUS "Enabling data execution prevention")
109+
add_linker_flag("-znoexecstack")
110+
endif()
111+
112+
# check and add Stack-based buffer overrun detection
113+
set(CMAKE_REQUIRED_FLAGS "-fstack-protector-strong")
114+
check_c_compiler_flag("" HAVE_STACKPROTECTOR)
115+
if(HAVE_STACKPROTECTOR)
116+
message (STATUS "Enabling stack-based buffer overrun detection")
117+
add_flag_append(CMAKE_C_FLAGS "-fstack-protector-strong")
118+
add_flag_append(CMAKE_CXX_FLAGS "-fstack-protector-strong")
119+
endif()
120+
121+
endif ()
122+
endif ()
123+
124+
# check for Data relocation and Protection (RELRO)
125+
set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro,-znow")
126+
check_c_compiler_flag("" HAVE_RELROFULL)
127+
if(HAVE_RELROFULL)
128+
message (STATUS "Enabling full data relocation and protection")
129+
add_linker_flag("-zrelro")
130+
add_linker_flag("-znow")
131+
else()
132+
#if full relro is not available, try partial relro
133+
set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro")
134+
check_c_compiler_flag("" HAVE_RELROPARTIAL)
135+
if(HAVE_RELROPARTIAL)
136+
message (STATUS "Enabling partial data relocation and protection")
137+
add_linker_flag("-zrelro")
138+
endif()
139+
endif()
140+
141+
set(CMAKE_REQUIRED_FLAGS ${TEMP_REQUIRED_FLAGS} )
142+
143+
# position independent executetable (PIE)
144+
# position independent code (PIC)
145+
if (NOT MSVC)
146+
add_definitions (-fPIC)
147+
endif(NOT MSVC)
31148

32-
#set (ENABLE_INSTALLER 1)
33-
#set (USE_PCH 1)
149+
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
150+
set( GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/libraries/egenesis/genesis.json"
151+
CACHE STRING "Path to embedded genesis file" )
34152

35153
if (USE_PCH)
36154
include (cotire)
37155
endif(USE_PCH)
38156

39157
option(USE_PROFILER "Build with GPROF support(Linux)." OFF)
40158

41-
IF( NOT WIN32 )
42-
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules" )
43-
ENDIF( NOT WIN32 )
159+
# Use Boost config file from fc
160+
set(Boost_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules/Boost")
161+
44162
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/GitVersionGen" )
45163
include( GetGitRevisionDescription )
46164
get_git_head_revision( GIT_REFSPEC GIT_SHA2 )
@@ -54,38 +172,60 @@ LIST(APPEND BOOST_COMPONENTS thread
54172
program_options
55173
chrono
56174
unit_test_framework
57-
context)
175+
context
176+
coroutine
177+
regex)
58178
# boost::endian is also required, but FindBoost can't handle header-only libs
59179
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
60180

61-
IF( WIN32 )
62-
SET(BOOST_ROOT $ENV{BOOST_ROOT})
181+
IF(WIN32)
182+
if($ENV{BOOST_ROOT})
183+
SET(BOOST_ROOT $ENV{BOOST_ROOT})
184+
endif($ENV{BOOST_ROOT})
63185
set(Boost_USE_MULTITHREADED ON)
64186
set(BOOST_ALL_DYN_LINK OFF) # force dynamic linking for all libraries
187+
add_definitions("-DCURL_STATICLIB")
188+
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 crypt32 mswsock userenv )
189+
ELSE( WIN32 )
190+
IF( APPLE )
191+
set( CMAKE_THREAD_LIBS_INIT "-lpthread" )
192+
set( CMAKE_HAVE_THREADS_LIBRARY 1 )
193+
set( CMAKE_USE_WIN32_THREADS_INIT 0 )
194+
set( CMAKE_USE_PTHREADS_INIT 1 )
195+
set( THREADS_PREFER_PTHREAD_FLAG ON )
196+
ENDIF( APPLE )
65197
ENDIF(WIN32)
66198

67-
FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
68-
# For Boost 1.53 on windows, coroutine was not in BOOST_LIBRARYDIR and do not need it to build, but if boost versin >= 1.54, find coroutine otherwise will cause link errors
69-
IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)")
70-
SET(BOOST_LIBRARIES_TEMP ${Boost_LIBRARIES})
71-
FIND_PACKAGE(Boost 1.54 REQUIRED COMPONENTS coroutine)
72-
LIST(APPEND BOOST_COMPONENTS coroutine)
73-
SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES})
74-
ENDIF()
199+
FIND_PACKAGE(Boost CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS})
200+
201+
# enforce more strict compiler warnings and errors
202+
add_compiler_flag_if_available("-Wall")
203+
add_compiler_flag_if_available("-Wclobbered")
204+
add_compiler_flag_if_available("-Wempty-body")
205+
add_compiler_flag_if_available("-Wformat-security")
206+
add_compiler_flag_if_available("-Wignored-qualifiers")
207+
add_compiler_flag_if_available("-Wimplicit-fallthrough=5")
208+
add_compiler_flag_if_available("-Wmissing-field-initializers")
209+
add_compiler_flag_if_available("-Wpointer-arith")
210+
add_compiler_flag_if_available("-Wshift-negative-value")
211+
add_compiler_flag_if_available("-Wtype-limits")
212+
add_compiler_flag_if_available("-Wunused-but-set-parameter")
75213

76214
if( WIN32 )
77215

78216
message( STATUS "Configuring BitShares on WIN32")
79-
set( DB_VERSION 60 )
80-
set( BDB_STATIC_LIBS 1 )
81217

82-
set( ZLIB_LIBRARIES "" )
83-
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
218+
if ( MINGW )
219+
message( STATUS "Windows build using MinGW" )
220+
set( FULL_STATIC_BUILD TRUE )
221+
else( MINGW )
222+
set( ZLIB_LIBRARIES "" )
223+
endif( MINGW )
84224

85-
set(CRYPTO_LIB)
225+
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
86226

87227
if( MSVC )
88-
add_definitions(-DWIN32_LEAN_AND_MEAN)
228+
add_definitions(-DWIN32_LEAN_AND_MEAN)
89229
#looks like this flag can have different default on some machines.
90230
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
91231
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
@@ -94,44 +234,32 @@ if( WIN32 )
94234
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG")
95235
endif ( MSVC )
96236

97-
# On windows tcl should be installed to the directory pointed by setenv.bat script
98-
SET(TCL_INCLUDE_PATH $ENV{TCL_ROOT}/include)
99-
MESSAGE(STATUS "tcl INCLUDE PATH: ${TCL_INCLUDE_PATH}")
100-
101-
FIND_PACKAGE(TCL)
102-
MESSAGE(STATUS "tcl_library: ${TCL_LIBRARY}")
103-
104-
SET(TCL_LIBS "optimized;${TCL_LIBRARY};debug;")
105-
get_filename_component(TCL_LIB_PATH "${TCL_LIBRARY}" PATH)
106-
get_filename_component(TCL_LIB_NAME "${TCL_LIBRARY}" NAME_WE)
107-
get_filename_component(TCL_LIB_EXT "${TCL_LIBRARY}" EXT)
108-
109-
SET(TCL_LIBS "${TCL_LIBS}${TCL_LIB_PATH}/${TCL_LIB_NAME}g${TCL_LIB_EXT}")
110-
SET(TCL_LIBRARY ${TCL_LIBS})
111-
112237
else( WIN32 ) # Apple AND Linux
113238

114239
if( APPLE )
115240
# Apple Specific Options Here
116241
message( STATUS "Configuring BitShares on OS X" )
117242
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" )
118243
else( APPLE )
119-
# Linux Specific Options Here
120-
message( STATUS "Configuring BitShares on Linux" )
244+
if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" )
245+
# OpenBSD Specific Options
246+
message( STATUS "Configuring BitShares on OpenBSD" )
247+
else()
248+
# Linux Specific Options Here
249+
message( STATUS "Configuring BitShares on Linux" )
250+
set( rt_library rt )
251+
endif()
252+
# Common Linux & OpenBSD Options
121253
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
122254
if(USE_PROFILER)
123255
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
124256
endif( USE_PROFILER )
125-
set( rt_library rt )
126257
set( pthread_library pthread)
127258
if ( NOT DEFINED crypto_library )
128259
# I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()?
129260
# if you have a normal install, you can define crypto_library to the empty string to avoid a build error
130261
set( crypto_library crypto)
131262
endif ()
132-
if ( FULL_STATIC_BUILD )
133-
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
134-
endif ( FULL_STATIC_BUILD )
135263
endif( APPLE )
136264

137265
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
@@ -154,6 +282,10 @@ else( WIN32 ) # Apple AND Linux
154282

155283
endif( WIN32 )
156284

285+
if ( NOT MSVC AND FULL_STATIC_BUILD )
286+
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libstdc++ -static-libgcc" )
287+
endif ( NOT MSVC AND FULL_STATIC_BUILD )
288+
157289
set(ENABLE_COVERAGE_TESTING FALSE CACHE BOOL "Build BitShares for code coverage analysis")
158290

159291
if(ENABLE_COVERAGE_TESTING)

CMakeModules/Utils.cmake

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
macro(add_flag_append _VAR_NAME _FLAG)
2+
set(${_VAR_NAME} "${${_VAR_NAME}} ${_FLAG}")
3+
endmacro(add_flag_append _VAR_NAME _FLAG)
4+
5+
macro(add_linker_flag _FLAG)
6+
#executables
7+
add_flag_append(CMAKE_C_LINK_FLAGS "-Wl,${_FLAG}")
8+
add_flag_append(CMAKE_CXX_LINK_FLAGS "-Wl,${_FLAG}")
9+
#libraries
10+
add_flag_append(CMAKE_SHARED_LIBRARY_C_FLAGS "-Wl,${_FLAG}")
11+
add_flag_append(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Wl,${_FLAG}")
12+
endmacro(add_linker_flag _FLAG)
13+
14+
include(CheckCXXCompilerFlag)
15+
16+
macro(add_compiler_flag_if_available _FLAG)
17+
string(TOUPPER "${_FLAG}" _TEMPVAR1)
18+
string(REPLACE "-" "_" _TEMPVAR2 "${_TEMPVAR1}")
19+
string(CONCAT _TEMPVAR3 "HAVE" "${_TEMPVAR2}")
20+
set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
21+
check_cxx_compiler_flag("${_FLAG}" ${_TEMPVAR3})
22+
if(${_TEMPVAR3})
23+
add_flag_append(CMAKE_CXX_FLAGS ${_FLAG})
24+
endif()
25+
endmacro(add_compiler_flag_if_available _VAR_NAME _FLAG)

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM phusion/baseimage:0.10.1
1+
FROM phusion/baseimage:0.11
22
MAINTAINER The bitshares decentralized organisation
33

44
ENV LANG=en_US.UTF-8
@@ -74,6 +74,7 @@ EXPOSE 1776
7474

7575
# default exec/config files
7676
ADD docker/default_config.ini /etc/bitshares/config.ini
77+
ADD docker/default_logging.ini /etc/bitshares/logging.ini
7778
ADD docker/bitsharesentry.sh /usr/local/bin/bitsharesentry.sh
7879
RUN chmod a+x /usr/local/bin/bitsharesentry.sh
7980

0 commit comments

Comments
 (0)