Skip to content

Commit

Permalink
Merge pull request EOSIO#215 from enumivo/stage112
Browse files Browse the repository at this point in the history
Stage112
  • Loading branch information
Enumivo authored Aug 2, 2018
2 parents bb44aa6 + c4d6845 commit 99777b4
Show file tree
Hide file tree
Showing 38 changed files with 996 additions and 496 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ project( Enumivo )

enable_testing()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(WARNING "CMAKE_INSTALL_PREFIX is set to default path of ${CMAKE_INSTALL_PREFIX}, resetting to ${CMAKE_INSTALL_PREFIX}/enumivo")
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/enumivo")
elseif ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
message(WARNING "CMAKE_INSTALL_PREFIX is explicitly set to /usr/local. This is not recommended.")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

Expand All @@ -20,7 +27,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION_PATCH 1)
set(VERSION_PATCH 2)

set( CLI_CLIENT_EXECUTABLE_NAME enucli )
set( GUI_CLIENT_EXECUTABLE_NAME enumivo )
Expand Down Expand Up @@ -65,6 +72,8 @@ if ("${OPENSSL_ROOT_DIR}" STREQUAL "")
endif()
endif()

find_package(Secp256k1 REQUIRED)

if(UNIX)
if(APPLE)
set(whole_archive_flag "-force_load")
Expand Down Expand Up @@ -216,6 +225,13 @@ install_directory_permissions(DIRECTORY ${CMAKE_INSTALL_FULL_SYSCONFDIR}/enumivo
install_directory_permissions(DIRECTORY ${CMAKE_INSTALL_FULL_SYSCONFDIR}/enumivo/launcher)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testnet.template ${CMAKE_CURRENT_BINARY_DIR}/etc/enumivo/launcher/testnet.template COPYONLY)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/enumivo.version.in ${CMAKE_CURRENT_BINARY_DIR}/enumivo.version.hpp)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/enumivo.version.hpp DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR})

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/EnumivoTester.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/EnumivoTester.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/EnumivoTesterBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/EnumivoTester.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EnumivoTester.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/)

include(installer)

include(doxygen)
133 changes: 133 additions & 0 deletions CMakeModules/EnumivoTester.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
cmake_minimum_required( VERSION 3.5 )

set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)

set(ENUMIVO_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@")

enable_testing()

find_package( Gperftools QUIET )
if( GPERFTOOLS_FOUND )
message( STATUS "Found gperftools; compiling tests with TCMalloc")
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

find_package(LLVM 4.0 REQUIRED CONFIG)

link_directories(${LLVM_LIBRARY_DIR})

set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_EXTENSIONS ON )
set( CXX_STANDARD_REQUIRED ON )

if ( APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" )
set( BOOST_ROOT "/usr/local/boost" )
else ( APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
set( BOOST_ROOT "~/opt/boost" )
endif ( APPLE )

set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
find_package(Boost 1.67 REQUIRED COMPONENTS
date_time
filesystem
system
chrono
iostreams
unit_test_framework)

find_library(libtester enumivo_testing @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libchain enumivo_chain @CMAKE_INSTALL_FULL_LIBDIR@)
if ( "${CMAKE_BUILD_TYPE}" EQUAL "Debug" )
find_library(libfc fc_debug @CMAKE_INSTALL_FULL_LIBDIR@)
else()
find_library(libfc fc @CMAKE_INSTALL_FULL_LIBDIR@)
endif()

find_library(libbinaryen binaryen @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwasm WASM @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libwast WAST @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libir IR @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libplatform Platform @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(liblogging Logging @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libruntime Runtime @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libsoftfloat softfloat @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
find_library(libchainbase chainbase @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libbuiltins builtins @CMAKE_INSTALL_FULL_LIBDIR@)
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib)

macro(add_enumivo_test test_name)
add_executable( ${test_name} ${ARGN} )
target_link_libraries( ${test_name}
${LLVM}
${libtester}
${libchain}
${libfc}
${libbinaryen}
${libwast}
${libwasm}
${libruntime}
${libplatform}
${libir}
${libsoftfloat}
${liboscrypto}
${libosssl}
${liblogging}
${libchainbase}
${libbuiltins}
${libsecp256k1}

LLVMX86Disassembler
LLVMX86AsmParser
LLVMX86AsmPrinter
LLVMX86CodeGen

LLVMSelectionDAG

LLVMDebugInfoDWARF
LLVMAsmPrinter
LLVMMCParser
LLVMX86Info

LLVMOrcJIT
LLVMExecutionEngine

LLVMCodeGen
LLVMScalarOpts
LLVMTransformUtils

LLVMipo
LLVMAnalysis
LLVMTarget
LLVMMC
LLVMCore
LLVMSupport
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_CHRONO_LIBRARY}
${Boost_IOSTREAMS_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${PLATFORM_SPECIFIC_LIBS}
)

#### TODO /usr/local/include is a hack for fc and some other includes
target_include_directories( ${test_name} PUBLIC
${Boost_INCLUDE_DIRS}
@OPENSSL_INCLUDE_DIR@
@CMAKE_INSTALL_PREFIX@
@CMAKE_INSTALL_FULL_INCLUDEDIR@
@CMAKE_INSTALL_FULL_INCLUDEDIR@/wasm-jit
@CMAKE_INSTALL_FULL_INCLUDEDIR@/softfloat )

#Manually run unit_test for all supported runtimes
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose
add_test(NAME ${test_name}_binaryen COMMAND ${test_name}
--report_level=detailed --color_output -- --binaryen)
add_test(NAME ${test_name}_wavm COMMAND ${test_name}
--report_level=detailed --color_output --catch_system_errors=no -- --wavm)
endmacro()
184 changes: 184 additions & 0 deletions CMakeModules/EnumivoTesterBuild.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
cmake_minimum_required( VERSION 3.5 )

set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)

set(ENUMIVO_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@")

enable_testing()

find_package( Gperftools QUIET )
if( GPERFTOOLS_FOUND )
message( STATUS "Found gperftools; compiling tests with TCMalloc")
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

find_package(LLVM 4.0 REQUIRED CONFIG)

link_directories(${LLVM_LIBRARY_DIR})

set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_EXTENSIONS ON )
set( CXX_STANDARD_REQUIRED ON )

if ( APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" )
set( BOOST_ROOT "/usr/local/boost" )
else ( APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
set( BOOST_ROOT "~/opt/boost" )
endif ( APPLE )

set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
find_package(Boost 1.67 REQUIRED COMPONENTS
date_time
filesystem
system
chrono
iostreams
unit_test_framework)

find_library(libtester enumivo_testing @CMAKE_BINARY_DIR@/libraries/testing)
find_library(libchain enumivo_chain @CMAKE_BINARY_DIR@/libraries/chain)
if ( "${CMAKE_BUILD_TYPE}" EQUAL "Debug" )
find_library(libfc fc_debug @CMAKE_BINARY_DIR@/libraries/fc)
else()
find_library(libfc fc @CMAKE_BINARY_DIR@/libraries/fc)
endif()

find_library(libbinaryen binaryen @CMAKE_BINARY_DIR@/externals/binaryen/lib)
find_library(libwasm WASM @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WASM)
find_library(libwast WAST @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WAST)
find_library(libir IR @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/IR)
find_library(libplatform Platform @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Platform)
find_library(liblogging Logging @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Logging)
find_library(libruntime Runtime @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Runtime)
find_library(libsoftfloat softfloat @CMAKE_BINARY_DIR@/libraries/softfloat)
find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
find_library(libchainbase chainbase @CMAKE_BINARY_DIR@/libraries/chainbase)
find_library(libbuiltins builtins @CMAKE_BINARY_DIR@/libraries/builtins)
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib)

macro(add_enumivo_test test_name)
add_executable( ${test_name} ${ARGN} )
target_link_libraries( ${test_name}
${LLVM}
${libtester}
${libchain}
${libfc}
${libbinaryen}
${libwast}
${libwasm}
${libruntime}
${libplatform}
${libir}
${libsoftfloat}
${liboscrypto}
${libosssl}
${liblogging}
${libchainbase}
${libbuiltins}
${libsecp256k1}

LLVMX86Disassembler
LLVMX86AsmParser
LLVMX86AsmPrinter
LLVMX86CodeGen

LLVMSelectionDAG

LLVMDebugInfoDWARF
LLVMAsmPrinter
LLVMMCParser
LLVMX86Info

LLVMOrcJIT
LLVMExecutionEngine

LLVMCodeGen
LLVMScalarOpts
LLVMTransformUtils

LLVMipo
LLVMAnalysis
LLVMTarget
LLVMMC
LLVMCore
LLVMSupport
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_CHRONO_LIBRARY}
${Boost_IOSTREAMS_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${PLATFORM_SPECIFIC_LIBS}
)

target_include_directories( ${test_name} PUBLIC
${Boost_INCLUDE_DIRS}
@OPENSSL_INCLUDE_DIR@
@CMAKE_SOURCE_DIR@/libraries/chain/include
@CMAKE_BINARY_DIR@/libraries/chain/include
@CMAKE_SOURCE_DIR@/libraries/fc/include
@CMAKE_SOURCE_DIR@/libraries/softfloat/source/include
@CMAKE_SOURCE_DIR@/libraries/appbase/include
@CMAKE_SOURCE_DIR@/libraries/chainbase/include
@CMAKE_SOURCE_DIR@/libraries/testing/include
@CMAKE_SOURCE_DIR@/libraries/wasm-jit/Include )
#
#Manually run unit_test for all supported runtimes
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose
add_test(NAME ${test_name}_binaryen COMMAND ${test_name}
--report_level=detailed --color_output -- --binaryen)
add_test(NAME ${test_name}_wavm COMMAND ${test_name}
--report_level=detailed --color_output --catch_system_errors=no -- --wavm)
endmacro()

if(ENABLE_COVERAGE_TESTING)

set(Coverage_NAME ${PROJECT_NAME}_ut_coverage)

if(NOT LCOV_PATH)
message(FATAL_ERROR "lcov not found! Aborting...")
endif() # NOT LCOV_PATH

if(NOT LLVMCOV_PATH)
message(FATAL_ERROR "llvm-cov not found! Aborting...")
endif() # NOT LCOV_PATH

if(NOT GENHTML_PATH)
message(FATAL_ERROR "genhtml not found! Aborting...")
endif() # NOT GENHTML_PATH

# no spaces allowed within tests list
set(ctest_tests 'unit_test_binaryen|unit_test_wavm')
set(ctest_exclude_tests '')

# Setup target
add_custom_target(${Coverage_NAME}

# Cleanup lcov
COMMAND ${LCOV_PATH} --directory . --zerocounters

# Run tests
COMMAND ./tools/ctestwrapper.sh -R ${ctest_tests} -E ${ctest_exclude_tests}

COMMAND ${LCOV_PATH} --directory . --capture --gcov-tool ./tools/llvm-gcov.sh --output-file ${Coverage_NAME}.info

COMMAND ${LCOV_PATH} -remove ${Coverage_NAME}.info '*/boost/*' '/usr/lib/*' '/usr/include/*' '*/externals/*' '*/fc/*' '*/wasm-jit/*' --output-file ${Coverage_NAME}_filtered.info

COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info

COMMAND if [ "$CI" != "true" ]\; then ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.info ${Coverage_NAME}_filtered.info ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned ${PROJECT_BINARY_DIR}/${Coverage_NAME}_filtered.info.cleaned\; fi

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero. Processing code coverage counters and generating report. Report published in ./${Coverage_NAME}"
)

# Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
COMMAND ;
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
)
endif()
2 changes: 1 addition & 1 deletion CMakeModules/installer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "Software for the Enumivo network")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Software for the Enumivo network")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Enumivo ${CPACK_PACKAGE_VERSION}")

if(WIN32)
Expand Down
Loading

0 comments on commit 99777b4

Please sign in to comment.