2018-10-26 13:26:47 +03:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
project(eevm)
|
2018-10-26 13:26:47 +03:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
# Set Windows compiler options.
|
|
|
|
add_compile_options(/W3 /std:c++latest)
|
|
|
|
else()
|
|
|
|
# Set Linux compiler options
|
|
|
|
add_compile_options(-Wall -Werror)
|
|
|
|
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
separate_arguments(COVERAGE_FLAGS UNIX_COMMAND "--coverage -fprofile-arcs -ftest-coverage")
|
|
|
|
set(PLATFORM_SPECIFIC_TEST_LIBS "gcov")
|
|
|
|
else()
|
|
|
|
separate_arguments(COVERAGE_FLAGS UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping")
|
|
|
|
set(PLATFORM_SPECIFIC_TEST_LIBS "-fprofile-instr-generate")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(GLOB KECCAK_SOURCES
|
|
|
|
3rdparty/keccak/*.c
|
|
|
|
)
|
|
|
|
|
2019-10-10 19:05:08 +03:00
|
|
|
add_subdirectory(3rdparty)
|
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Options
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
2018-10-26 13:26:47 +03:00
|
|
|
option(RECORD_TRACE "Record a detailed trace of EVM execution during test runs" OFF)
|
|
|
|
if(RECORD_TRACE)
|
|
|
|
add_definitions(-DRECORD_TRACE)
|
|
|
|
endif(RECORD_TRACE)
|
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Common variables
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
set(EEVM_INCLUDE_DIRS
|
2018-10-26 13:26:47 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty
|
2019-08-16 18:15:07 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2018-10-26 13:26:47 +03:00
|
|
|
)
|
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
set(EEVM_CORE_SRCS
|
|
|
|
src/disassembler.cpp
|
|
|
|
src/processor.cpp
|
|
|
|
src/stack.cpp
|
|
|
|
src/transaction.cpp
|
|
|
|
src/util.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(EEVM_SIMPLE_SRCS
|
2019-08-23 15:18:25 +03:00
|
|
|
src/simple/simpleaccount.cpp
|
2019-08-16 18:15:07 +03:00
|
|
|
src/simple/simpleglobalstate.cpp
|
|
|
|
src/simple/simplestorage.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Libraries
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
add_library(eevm STATIC
|
|
|
|
${EEVM_CORE_SRCS}
|
|
|
|
${KECCAK_SOURCES}
|
|
|
|
)
|
|
|
|
target_include_directories(eevm PRIVATE
|
|
|
|
${EEVM_INCLUDE_DIRS}
|
|
|
|
)
|
2019-10-10 19:05:08 +03:00
|
|
|
target_link_libraries(eevm
|
|
|
|
intx::intx
|
|
|
|
)
|
2019-08-16 18:15:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Executables
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
add_executable(eevm_tests
|
2018-10-26 13:26:47 +03:00
|
|
|
tests/main.cpp
|
|
|
|
tests/harness.cpp
|
2019-04-04 15:36:07 +03:00
|
|
|
tests/rlp.cpp
|
2019-08-16 18:15:07 +03:00
|
|
|
${EEVM_SIMPLE_SRCS}
|
2018-10-26 13:26:47 +03:00
|
|
|
)
|
2019-08-16 18:15:07 +03:00
|
|
|
target_include_directories(eevm_tests PRIVATE
|
|
|
|
${EEVM_INCLUDE_DIRS}
|
2018-10-26 13:26:47 +03:00
|
|
|
)
|
2019-08-16 18:15:07 +03:00
|
|
|
target_compile_options(eevm_tests PRIVATE ${COVERAGE_FLAGS})
|
|
|
|
target_link_libraries(eevm_tests eevm ${PLATFORM_SPECIFIC_TEST_LIBS})
|
2018-10-26 13:26:47 +03:00
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Tests
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
2018-10-26 13:26:47 +03:00
|
|
|
enable_testing()
|
2019-08-16 18:15:07 +03:00
|
|
|
|
2018-10-26 13:26:47 +03:00
|
|
|
add_test(
|
2019-08-16 18:15:07 +03:00
|
|
|
NAME eevm_tests
|
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_test_wrapper.sh eevm_tests
|
2018-10-26 13:26:47 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT ENV{TEST_DIR})
|
2019-08-16 18:15:07 +03:00
|
|
|
set_tests_properties(eevm_tests
|
|
|
|
PROPERTIES
|
|
|
|
ENVIRONMENT TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/test_cases
|
|
|
|
)
|
2018-10-26 13:26:47 +03:00
|
|
|
endif()
|
2018-12-03 13:41:25 +03:00
|
|
|
|
2019-08-16 18:15:07 +03:00
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# Samples
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
2018-12-03 13:41:25 +03:00
|
|
|
function(add_sample name)
|
|
|
|
add_executable(${name}
|
|
|
|
samples/${name}/main.cpp
|
2019-08-16 18:15:07 +03:00
|
|
|
${EEVM_SIMPLE_SRCS}
|
2018-12-03 13:41:25 +03:00
|
|
|
)
|
|
|
|
target_include_directories(${name} PRIVATE
|
2019-08-16 18:15:07 +03:00
|
|
|
${EEVM_INCLUDE_DIRS}
|
2018-12-03 13:41:25 +03:00
|
|
|
)
|
2019-08-16 18:15:07 +03:00
|
|
|
target_link_libraries(${name} eevm)
|
2018-12-03 13:41:25 +03:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_sample(hello_world)
|
|
|
|
add_sample(sum)
|
|
|
|
add_sample(erc20)
|
2019-08-30 20:01:32 +03:00
|
|
|
add_sample(disassembler)
|