diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ab9ad3..be0fa47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ include(CMakePackageConfigHelpers) include(GNUInstallDirs) if(EVMC_TESTING) + set(HUNTER_CONFIGURATION_TYPES Release CACHE STRING "Build type of Hunter packages") include(HunterGate) include(HunterConfig) include(defaults/HunterCacheServers) diff --git a/README.md b/README.md index ef82051..88d23dc 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ Please visit the [documentation]. ### Languages support -| Language | Supported Versions | -| ----------------------- | ------------------- | -| **C** | C90, C99, C11 | -| **C++** _(helpers)_[^1] | C++11, C++14, C++17 | +| Language | Supported Versions | Supported Compilers +| ----------------------- | ------------------- | ------------------- +| **C** | C90, C99, C11 | GCC 6+, clang 3.8+ +| **C++** _(helpers)_[^1] | C++11, C++14, C++17 | GCC 6+, clang 3.8+ | **Go** _(bindings)_ | 1.9, 1.10, 1.11 | [^1]: C++ support is provided by C headers and some optional C++ helpers. diff --git a/circle.yml b/circle.yml index 6851c07..39e5a94 100644 --- a/circle.yml +++ b/circle.yml @@ -3,12 +3,13 @@ jobs: lint: docker: - - image: ethereum/cpp-build-env:7 + - image: ethereum/cpp-build-env:10 steps: - checkout - run: name: "Check code format" command: | + clang-format --version find examples include lib test -name '*.hpp' -o -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format -i git diff --color --exit-code - run: @@ -18,11 +19,21 @@ jobs: sudo pip3 install codespell codespell --quiet-level=4 --ignore-words=./.codespell-whitelist - build-cxx11: &build + build: &build docker: - - image: ethereum/cpp-build-env:7 + - image: ethereum/cpp-build-env:10 steps: - checkout + - run: + name: "Environment" + command: | + CC=${CC:-cc} + CXX=${CXX:-cpp} + echo CC: $CC + echo CXX: $CXX + $CC --version + $CXX --version + cmake --version - run: name: "Configure" working_directory: ~/build @@ -63,23 +74,35 @@ jobs: name: "Run evmc-vmtester libevmc-example-vm.so" command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so + build-cxx17: + <<: *build + environment: + CC: gcc-8 + CXX: g++-8 + CMAKE_OPTIONS: -DTOOLCHAIN=cxx17-pic + build-cxx14: <<: *build environment: - CC: clang-3.8 - CXX: clang++-3.8 + CC: clang-8 + CXX: clang++-8 CMAKE_OPTIONS: -DTOOLCHAIN=cxx14-pic - build-cxx17: + build-gcc6: <<: *build environment: CC: gcc-6 CXX: g++-6 - CMAKE_OPTIONS: -DTOOLCHAIN=cxx17-pic + + build-clang3.8: + <<: *build + environment: + CC: clang-3.8 + CXX: clang++-3.8 test-docs: docker: - - image: ethereum/cpp-build-env + - image: ethereum/cpp-build-env:10 steps: - checkout - run: @@ -98,7 +121,7 @@ jobs: upload-docs: docker: - - image: ethereum/cpp-build-env + - image: ethereum/cpp-build-env:10 steps: - checkout - run: @@ -141,9 +164,10 @@ workflows: evmc: jobs: - lint - - build-cxx11 - - build-cxx14 - build-cxx17 + - build-cxx14 + - build-gcc6 + - build-clang3.8 - bindings-go-1.11 - bindings-go-1.10 - bindings-go-1.9 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa2347f..9d162db 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # EVMC: Ethereum Client-VM Connector API. -# Copyright 2018 The EVMC Authors. +# Copyright 2019 The EVMC Authors. # Licensed under the Apache License, Version 2.0. See the LICENSE file. hunter_add_package(GTest) @@ -8,6 +8,7 @@ find_package(GTest CONFIG REQUIRED) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_C_EXTENSIONS OFF) endif() add_subdirectory(integration) diff --git a/test/integration/compilation/CMakeLists.txt b/test/integration/compilation/CMakeLists.txt index 46095f6..b7e55d6 100644 --- a/test/integration/compilation/CMakeLists.txt +++ b/test/integration/compilation/CMakeLists.txt @@ -5,28 +5,32 @@ # This CMake script creates multiple additional targets to test the compilation of public headers # with different C and C++ standards. +set(standards c_std_90;c_std_99;c_std_11;cxx_std_11;cxx_std_14) +if(NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8.1) + list(APPEND standards cxx_std_17) +endif() + +list(APPEND all_features ${CMAKE_CXX_COMPILE_FEATURES}) +list(APPEND all_features ${CMAKE_C_COMPILE_FEATURES}) + macro(create_compilation_test STANDARD) - if (${STANDARD} MATCHES "^(C|CXX)([0-9]+)$") + if (${STANDARD} MATCHES "^(c|cxx)_std_([0-9]+)$") set(lang ${CMAKE_MATCH_1}) set(num ${CMAKE_MATCH_2}) else() - message(FATAL_ERROR "Unknown language standard: ${STANDARD}") + message(FATAL_ERROR "Unknown standard: ${STANDARD}") endif() - if (lang STREQUAL CXX) - set(ext cpp) + if(${STANDARD} IN_LIST all_features) + set(target test-compile-${STANDARD}) + add_library(${target} OBJECT compilation_test.${lang}) + target_compile_features(${target} PRIVATE ${STANDARD}) + target_include_directories(${target} PRIVATE ${include_dir}) else() - set(ext c) + message(STATUS "Compilation test SKIPPED: ${STANDARD}") endif() - - string(TOLOWER ${STANDARD} standard) - set(target test-compile-${standard}) - - add_library(${target} OBJECT compilation_test.${ext}) - target_include_directories(${target} PRIVATE ${include_dir}) - set_target_properties(${target} PROPERTIES ${lang}_STANDARD ${num} ${lang}_EXTENSIONS OFF) endmacro() -foreach(standard C90;C99;C11;CXX11;CXX14;CXX17) +foreach(standard ${standards}) create_compilation_test(${standard}) endforeach() diff --git a/test/integration/compilation/compilation_test.cpp b/test/integration/compilation/compilation_test.cxx similarity index 100% rename from test/integration/compilation/compilation_test.cpp rename to test/integration/compilation/compilation_test.cxx diff --git a/test/vmtester/tests.cpp b/test/vmtester/tests.cpp index 0c9384e..8796b19 100644 --- a/test/vmtester/tests.cpp +++ b/test/vmtester/tests.cpp @@ -111,9 +111,9 @@ TEST_F(evmc_vm_test, version) TEST_F(evmc_vm_test, set_tracer) { - static const auto tracer_callback = [](evmc_tracer_context*, size_t, evmc_status_code, int64_t, - size_t, const evmc_uint256be*, size_t, size_t, size_t, - const uint8_t*) noexcept {}; + static const auto tracer_callback = + [](evmc_tracer_context*, size_t, evmc_status_code, int64_t, size_t, const evmc_uint256be*, + size_t, size_t, size_t, const uint8_t*) noexcept {}; if (vm->set_tracer) vm->set_tracer(vm, tracer_callback, nullptr); }