Enhance compilation tests

This commit is contained in:
Paweł Bylica 2019-01-18 13:49:54 +01:00
parent f27aa78a34
commit 377167f76a
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
6 changed files with 47 additions and 25 deletions

View File

@ -1,6 +1,6 @@
# EVMC: Ethereum Client-VM Connector API. # 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. # Licensed under the Apache License, Version 2.0.
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
@ -21,9 +21,9 @@ include(CMakePackageConfigHelpers)
include(GNUInstallDirs) include(GNUInstallDirs)
if(EVMC_TESTING) if(EVMC_TESTING)
include(HunterGate) include(HunterGate)
include(HunterConfig) include(HunterConfig)
include(defaults/HunterCacheServers) include(defaults/HunterCacheServers)
endif() endif()
cable_configure_toolchain(DEFAULT cxx11-pic) cable_configure_toolchain(DEFAULT cxx11-pic)

View File

@ -173,7 +173,7 @@ enum evmc_opcode
OP_REVERT = 0xfd, OP_REVERT = 0xfd,
OP_INVALID = 0xfe, OP_INVALID = 0xfe,
OP_SELFDESTRUCT = 0xff, OP_SELFDESTRUCT = 0xff
}; };
/** /**

View File

@ -40,7 +40,7 @@ enum evmc_loader_error_code
EVMC_LOADER_INSTANCE_CREATION_FAILURE = 4, EVMC_LOADER_INSTANCE_CREATION_FAILURE = 4,
/** The ABI version of the VM instance has mismatched. */ /** The ABI version of the VM instance has mismatched. */
EVMC_LOADER_ABI_VERSION_MISMATCH = 5, EVMC_LOADER_ABI_VERSION_MISMATCH = 5
}; };
/** /**

View File

@ -1,19 +1,32 @@
# EVMC: Ethereum Client-VM Connector API. # 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. # Licensed under the Apache License, Version 2.0.
add_library(test-compile-c99 STATIC compilation_test.c) # This CMake script creates multiple additional targets to test the compilation of public headers
target_link_libraries(test-compile-c99 PRIVATE evmc) # with different C and C++ standards.
set_target_properties(test-compile-c99 PROPERTIES C_STANDARD 99 C_EXTENSIONS OFF)
add_library(test-compile-c11 STATIC ${PROJECT_SOURCE_DIR}/include/evmc/evmc.h compilation_test.c) macro(create_compilation_test STANDARD)
target_link_libraries(test-compile-c11 PRIVATE evmc) if (${STANDARD} MATCHES "^(C|CXX)([0-9]+)$")
set_target_properties(test-compile-c11 PROPERTIES C_STANDARD 11 C_EXTENSIONS OFF) set(lang ${CMAKE_MATCH_1})
set(num ${CMAKE_MATCH_2})
else()
message(FATAL_ERROR "Unknown language standard: ${STANDARD}")
endif()
add_library(test-compile-cxx98 STATIC compilation_test.cpp) if (lang STREQUAL CXX)
target_link_libraries(test-compile-cxx98 PRIVATE evmc) set(ext cpp)
set_target_properties(test-compile-cxx98 PROPERTIES CXX_STANDARD 98 CXX_EXTENSIONS OFF) else()
set(ext c)
endif()
add_library(test-compile-cxx11 STATIC compilation_test.cpp) string(TOLOWER ${STANDARD} standard)
target_link_libraries(test-compile-cxx11 PRIVATE evmc) set(target test-compile-${standard})
set_target_properties(test-compile-cxx11 PROPERTIES CXX_STANDARD 11 CXX_EXTENSIONS OFF)
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)
create_compilation_test(${standard})
endforeach()

View File

@ -1,7 +1,11 @@
/* EVMC: Ethereum Client-VM Connector API. /* 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. * Licensed under the Apache License, Version 2.0.
*/ */
/* Test compilation of C public headers. */
#include <evmc/evmc.h> #include <evmc/evmc.h>
#include <evmc/instructions.h>
#include <evmc/loader.h>
#include <evmc/utils.h> #include <evmc/utils.h>

View File

@ -1,7 +1,12 @@
/* EVMC: Ethereum Client-VM Connector API. /* 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. * Licensed under the Apache License, Version 2.0.
*/ */
// Test compilation of C and C++ public headers.
#include <evmc/evmc.h> #include <evmc/evmc.h>
#include <evmc/instructions.h>
#include <evmc/loader.h>
#include <evmc/utils.h> #include <evmc/utils.h>
#include <evmc/helpers.hpp>