From 8c7cfd00c9a42d21f118ce0dc5e0f9373742ecc7 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Mon, 11 Jul 2022 17:04:13 -0400 Subject: [PATCH 1/4] modify Tester.cmake some more for clean usage in -dev package --- CMakeLists.txt | 4 ++-- CMakeModules/EosioTester.cmake.in | 30 +++++++++++++++--------------- CMakeModules/eosio-config.cmake.in | 10 ++++++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c79f89da10..968e98d9e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,12 +191,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testnet.template ${CMAKE_CURRENT_BINA configure_file(${CMAKE_CURRENT_SOURCE_DIR}/eosio.version.in ${CMAKE_CURRENT_BINARY_DIR}/eosio.version.hpp) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eosio.version.hpp DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} COMPONENT dev EXCLUDE_FROM_ALL) -set(EOS_ROOT_DIR ${CMAKE_BINARY_DIR}) +set(EOS_ROOT_DIR "${CMAKE_BINARY_DIR}/lib") configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/eosio-config.cmake @ONLY) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/mandel-config.cmake @ONLY) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/EosioTesterBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/EosioTester.cmake @ONLY) -set(EOS_ROOT_DIR ${CMAKE_INSTALL_PREFIX}) +set(EOS_ROOT_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/modules/eosio-config.cmake @ONLY) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/modules/mandel-config.cmake @ONLY) install(FILES ${CMAKE_BINARY_DIR}/modules/eosio-config.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/eosio COMPONENT dev EXCLUDE_FROM_ALL) diff --git a/CMakeModules/EosioTester.cmake.in b/CMakeModules/EosioTester.cmake.in index 0d9d224ab9..297f0f0b72 100644 --- a/CMakeModules/EosioTester.cmake.in +++ b/CMakeModules/EosioTester.cmake.in @@ -52,29 +52,29 @@ find_package(Boost @Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@ EXACT REQUIRED CO iostreams unit_test_framework) -find_library(libtester eosio_testing @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libchain eosio_chain @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) +find_library(libtester eosio_testing @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libchain eosio_chain @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - find_library(libfc fc_debug @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) - find_library(libsecp256k1 secp256k1_debug @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) + find_library(libfc fc_debug @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) + find_library(libsecp256k1 secp256k1_debug @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) else() - find_library(libfc fc @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) - find_library(libsecp256k1 secp256k1 @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) + find_library(libfc fc @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) + find_library(libsecp256k1 secp256k1 @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) endif() -find_library(libff ff @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libwasm WASM @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libwast WAST @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libir IR @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(liblogging Logging @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libruntime Runtime @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libsoftfloat softfloat @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) +find_library(libff ff @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libwasm WASM @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libwast WAST @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libir IR @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(liblogging Logging @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libruntime Runtime @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libsoftfloat softfloat @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) get_filename_component(cryptodir @OPENSSL_CRYPTO_LIBRARY@ DIRECTORY) find_library(liboscrypto crypto "${cryptodir}" NO_DEFAULT_PATH) get_filename_component(ssldir @OPENSSL_SSL_LIBRARY@ DIRECTORY) find_library(libosssl ssl "${ssldir}" NO_DEFAULT_PATH) -find_library(libchainbase chainbase @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) -find_library(libbuiltins builtins @CMAKE_INSTALL_PREFIX@/lib64 @CMAKE_INSTALL_PREFIX@/lib NO_DEFAULT_PATH) +find_library(libchainbase chainbase @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) +find_library(libbuiltins builtins @CMAKE_INSTALL_FULL_LIBDIR@ NO_DEFAULT_PATH) #Ubuntu build requires rt library to be specified explicitly if(UNIX AND NOT APPLE) diff --git a/CMakeModules/eosio-config.cmake.in b/CMakeModules/eosio-config.cmake.in index e30a3fa4ab..345dd5c648 100644 --- a/CMakeModules/eosio-config.cmake.in +++ b/CMakeModules/eosio-config.cmake.in @@ -1,8 +1,10 @@ -if(EOSIO_ROOT STREQUAL "" OR NOT EOSIO_ROOT) - set(EOSIO_ROOT "@EOS_ROOT_DIR@") +if(NOT EOSIO_ROOT) + list(APPEND CMAKE_MODULE_PATH @EOS_ROOT_DIR@/cmake/eosio) +else() + # legacy behavior for anyone configuring with -DEOSIO_ROOT=/foo or such + list(APPEND CMAKE_MODULE_PATH ${EOSIO_ROOT}/lib/cmake/eosio) + list(APPEND CMAKE_MODULE_PATH ${EOSIO_ROOT}/lib64/cmake/eosio) endif() -list(APPEND CMAKE_MODULE_PATH ${EOSIO_ROOT}/lib/cmake/eosio) -list(APPEND CMAKE_MODULE_PATH ${EOSIO_ROOT}/lib64/cmake/eosio) include(EosioTester) function(EXTRACT_MAJOR_MINOR_FROM_VERSION version success major minor) From d668e0124233bb31fd61f1562456547569eada0f Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Mon, 11 Jul 2022 19:20:31 -0400 Subject: [PATCH 2/4] modfiy libbuiltins for GNUInstallDirs usage & bump fc/ff --- libraries/builtins/CMakeLists.txt | 6 +++--- libraries/fc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/builtins/CMakeLists.txt b/libraries/builtins/CMakeLists.txt index f2db436305..ba465fc043 100644 --- a/libraries/builtins/CMakeLists.txt +++ b/libraries/builtins/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories( builtins PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" install ( TARGETS builtins - RUNTIME DESTINATION bin COMPONENT dev EXCLUDE_FROM_ALL - LIBRARY DESTINATION lib COMPONENT dev EXCLUDE_FROM_ALL - ARCHIVE DESTINATION lib COMPONENT dev EXCLUDE_FROM_ALL + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT dev EXCLUDE_FROM_ALL + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} COMPONENT dev EXCLUDE_FROM_ALL + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} COMPONENT dev EXCLUDE_FROM_ALL ) diff --git a/libraries/fc b/libraries/fc index 26cffa0ae4..866aa19f64 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 26cffa0ae4118bd6cd01458d1d98efa702ed92b1 +Subproject commit 866aa19f64ac06520ff6e866fe3f9d0964564198 From 57fcf4956586044ab8a69aeaf74674f922fc8996 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 14 Jul 2022 14:55:28 -0400 Subject: [PATCH 3/4] embed contracts required for unittesting in to libtester --- libraries/fc | 2 +- libraries/testing/CMakeLists.txt | 3 + libraries/testing/contracts.cpp.in | 24 ++ libraries/testing/contracts.hpp.in | 12 +- unittests/incbin.h | 352 ----------------------------- unittests/wasm_tests.cpp | 2 +- 6 files changed, 38 insertions(+), 357 deletions(-) create mode 100644 libraries/testing/contracts.cpp.in delete mode 100644 unittests/incbin.h diff --git a/libraries/fc b/libraries/fc index 866aa19f64..16e6355889 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 866aa19f64ac06520ff6e866fe3f9d0964564198 +Subproject commit 16e63558890ce74bfca76797f928cb8f3936ff3d diff --git a/libraries/testing/CMakeLists.txt b/libraries/testing/CMakeLists.txt index d77cfa6a2a..0144e269ec 100644 --- a/libraries/testing/CMakeLists.txt +++ b/libraries/testing/CMakeLists.txt @@ -4,10 +4,13 @@ configure_file(contracts.hpp.in include/testing_contracts/contracts.hpp ESCAPE_Q add_library(eosio_testing_contracts INTERFACE) target_include_directories(eosio_testing_contracts INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/include/testing_contracts) +configure_file(contracts.cpp.in contracts.cpp ESCAPE_QUOTES) + ## SORT .cpp by most likely to change / break compile add_library( eosio_testing tester.cpp tester_network.cpp + ${CMAKE_CURRENT_BINARY_DIR}/contracts.cpp ${HEADERS} ) diff --git a/libraries/testing/contracts.cpp.in b/libraries/testing/contracts.cpp.in new file mode 100644 index 0000000000..a4649da5a1 --- /dev/null +++ b/libraries/testing/contracts.cpp.in @@ -0,0 +1,24 @@ +#include + +#include +#include + +#define INCBIN_STYLE INCBIN_STYLE_SNAKE +#include + +#define MAKE_EMBEDDED_WASM_ABI(CN,C, D) \ +INCBIN(eosio_testing_contract_ ## CN ## _wasm, "${CMAKE_BINARY_DIR}/unittests/" #D "/" #C "/" #C ".wasm"); \ +INCBIN(eosio_testing_contract_ ## CN ## _abi, "${CMAKE_BINARY_DIR}/unittests/" #D "/" #C "/" #C ".abi"); \ + \ +namespace eosio::testing { \ + std::vector contracts:: CN ## _wasm() { \ + return std::vector(geosio_testing_contract_ ## CN ## _wasm_data, geosio_testing_contract_ ## CN ## _wasm_data + geosio_testing_contract_ ## CN ## _wasm_size); \ + } \ + std::vector contracts:: CN ## _abi() { \ + return std::vector(geosio_testing_contract_ ## CN ## _abi_data, geosio_testing_contract_ ## CN ## _abi_data + geosio_testing_contract_ ## CN ## _abi_size); \ + } \ +} + +MAKE_EMBEDDED_WASM_ABI(eosio_bios, eosio.bios, contracts) +MAKE_EMBEDDED_WASM_ABI(before_producer_authority_eosio_bios, eosio.bios, contracts/old_versions/v1.7.0-develop-preactivate_feature) +MAKE_EMBEDDED_WASM_ABI(before_preactivate_eosio_bios, eosio.bios, contracts/old_versions/v1.6.0-rc3) diff --git a/libraries/testing/contracts.hpp.in b/libraries/testing/contracts.hpp.in index f67c6066a3..e3eed08228 100644 --- a/libraries/testing/contracts.hpp.in +++ b/libraries/testing/contracts.hpp.in @@ -33,18 +33,24 @@ struct core_sym { return std::vector(s.begin(), s.end()); \ } +//contracts that need to be available by native contract unit testing's libtester need to be embedded +// in to the library as the build directory may not exist after being 'make install'ed. +#define MAKE_EMBD_WASM_ABI(CN) \ + static std::vector CN ## _wasm(); \ + static std::vector CN ## _abi(); + namespace eosio { namespace testing { struct contracts { // Contracts in `eos/unittests/contracts' directory - MAKE_READ_WASM_ABI(eosio_bios, eosio.bios, contracts) + MAKE_EMBD_WASM_ABI(eosio_bios) MAKE_READ_WASM_ABI(eosio_msig, eosio.msig, contracts) MAKE_READ_WASM_ABI(eosio_system, eosio.system, contracts) MAKE_READ_WASM_ABI(eosio_token, eosio.token, contracts) MAKE_READ_WASM_ABI(eosio_wrap, eosio.wrap, contracts) - MAKE_READ_WASM_ABI(before_producer_authority_eosio_bios, eosio.bios, contracts/old_versions/v1.7.0-develop-preactivate_feature) - MAKE_READ_WASM_ABI(before_preactivate_eosio_bios, eosio.bios, contracts/old_versions/v1.6.0-rc3) + MAKE_EMBD_WASM_ABI(before_producer_authority_eosio_bios) + MAKE_EMBD_WASM_ABI(before_preactivate_eosio_bios) // Contracts in `eos/unittests/unittests/test-contracts' directory MAKE_READ_WASM_ABI(asserter, asserter, test-contracts) diff --git a/unittests/incbin.h b/unittests/incbin.h deleted file mode 100644 index c891d8662b..0000000000 --- a/unittests/incbin.h +++ /dev/null @@ -1,352 +0,0 @@ -/** - * From https://github.com/graphitemaster/incbin licenced in public domain - */ -#ifndef INCBIN_HDR -#define INCBIN_HDR -#include -#if defined(__AVX512BW__) || \ - defined(__AVX512CD__) || \ - defined(__AVX512DQ__) || \ - defined(__AVX512ER__) || \ - defined(__AVX512PF__) || \ - defined(__AVX512VL__) || \ - defined(__AVX512F__) -# define INCBIN_ALIGNMENT_INDEX 6 -#elif defined(__AVX__) || \ - defined(__AVX2__) -# define INCBIN_ALIGNMENT_INDEX 5 -#elif defined(__SSE__) || \ - defined(__SSE2__) || \ - defined(__SSE3__) || \ - defined(__SSSE3__) || \ - defined(__SSE4_1__) || \ - defined(__SSE4_2__) || \ - defined(__neon__) -# define INCBIN_ALIGNMENT_INDEX 4 -#elif ULONG_MAX != 0xffffffffu -# define INCBIN_ALIGNMENT_INDEX 3 -# else -# define INCBIN_ALIGNMENT_INDEX 2 -#endif - -/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */ -#define INCBIN_ALIGN_SHIFT_0 1 -#define INCBIN_ALIGN_SHIFT_1 2 -#define INCBIN_ALIGN_SHIFT_2 4 -#define INCBIN_ALIGN_SHIFT_3 8 -#define INCBIN_ALIGN_SHIFT_4 16 -#define INCBIN_ALIGN_SHIFT_5 32 -#define INCBIN_ALIGN_SHIFT_6 64 - -/* Actual alignment value */ -#define INCBIN_ALIGNMENT \ - INCBIN_CONCATENATE( \ - INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \ - INCBIN_ALIGNMENT_INDEX) - -/* Stringize */ -#define INCBIN_STR(X) \ - #X -#define INCBIN_STRINGIZE(X) \ - INCBIN_STR(X) -/* Concatenate */ -#define INCBIN_CAT(X, Y) \ - X ## Y -#define INCBIN_CONCATENATE(X, Y) \ - INCBIN_CAT(X, Y) -/* Deferred macro expansion */ -#define INCBIN_EVAL(X) \ - X -#define INCBIN_INVOKE(N, ...) \ - INCBIN_EVAL(N(__VA_ARGS__)) - -/* Green Hills uses a different directive for including binary data */ -#if defined(__ghs__) -# define INCBIN_MACRO "\tINCBIN" -#else -# define INCBIN_MACRO ".incbin" -#endif - -#ifndef _MSC_VER -# define INCBIN_ALIGN \ - __attribute__((aligned(INCBIN_ALIGNMENT))) -#else -# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT)) -#endif - -#if defined(__arm__) || /* GNU C and RealView */ \ - defined(__arm) || /* Diab */ \ - defined(_ARM) /* ImageCraft */ -# define INCBIN_ARM -#endif - -#ifdef __GNUC__ -/* Utilize .balign where supported */ -# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n" -# define INCBIN_ALIGN_BYTE ".balign 1\n" -#elif defined(INCBIN_ARM) -/* - * On arm assemblers, the alignment value is calculated as (1 << n) where `n' is - * the shift count. This is the value passed to `.align' - */ -# define INCBIN_ALIGN_HOST ".align" INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n" -# define INCBIN_ALIGN_BYTE ".align 0\n" -#else -/* We assume other inline assembler's treat `.align' as `.balign' */ -# define INCBIN_ALIGN_HOST ".align" INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n" -# define INCBIN_ALIGN_BYTE ".align 1\n" -#endif - -/* INCBIN_CONST is used by incbin.c generated files */ -#if defined(__cplusplus) -# define INCBIN_EXTERNAL extern "C" -# define INCBIN_CONST extern const -#else -# define INCBIN_EXTERNAL extern -# define INCBIN_CONST const -#endif - -/** - * @brief Optionally override the linker section into which data is emitted. - * - * @warning If you use this facility, you'll have to deal with platform-specific linker output - * section naming on your own - * - * Overriding the default linker output section, e.g for esp8266/Arduino: - * @code - * #define INCBIN_OUTPUT_SECTION ".irom.text" - * #include "incbin.h" - * INCBIN(Foo, "foo.txt"); - * // Data is emitted into program memory that never gets copied to RAM - * @endcode - */ -#if !defined(INCBIN_OUTPUT_SECTION) -# if defined(__APPLE__) -# define INCBIN_OUTPUT_SECTION ".const_data" -# else -# define INCBIN_OUTPUT_SECTION ".rodata" -# endif -#endif - -#if defined(__APPLE__) -/* The directives are different for Apple branded compilers */ -# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n" -# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" -# define INCBIN_INT ".long " -# define INCBIN_MANGLE "_" -# define INCBIN_BYTE ".byte " -# define INCBIN_TYPE(...) -#else -# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n" -# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" -# define INCBIN_INT ".int " -# if defined(__USER_LABEL_PREFIX__) -# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__) -# else -# define INCBIN_MANGLE "" -# endif -# if defined(INCBIN_ARM) -/* On arm assemblers, `@' is used as a line comment token */ -# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n" -# elif defined(__MINGW32__) || defined(__MINGW64__) -/* Mingw doesn't support this directive either */ -# define INCBIN_TYPE(NAME) -# else -/* It's safe to use `@' on other architectures */ -# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n" -# endif -# define INCBIN_BYTE ".byte " -#endif - -/* List of style types used for symbol names */ -#define INCBIN_STYLE_CAMEL 0 -#define INCBIN_STYLE_SNAKE 1 - -/** - * @brief Specify the prefix to use for symbol names. - * - * By default this is `g', producing symbols of the form: - * @code - * #include "incbin.h" - * INCBIN(Foo, "foo.txt"); - * - * // Now you have the following symbols: - * // const unsigned char gFooData[]; - * // const unsigned char *const gFooEnd; - * // const unsigned int gFooSize; - * @endcode - * - * If however you specify a prefix before including: e.g: - * @code - * #define INCBIN_PREFIX incbin - * #include "incbin.h" - * INCBIN(Foo, "foo.txt"); - * - * // Now you have the following symbols instead: - * // const unsigned char incbinFooData[]; - * // const unsigned char *const incbinFooEnd; - * // const unsigned int incbinFooSize; - * @endcode - */ -#if !defined(INCBIN_PREFIX) -# define INCBIN_PREFIX g -#endif - -/** - * @brief Specify the style used for symbol names. - * - * Possible options are - * - INCBIN_STYLE_CAMEL "CamelCase" - * - INCBIN_STYLE_SNAKE "snake_case" - * - * Default option is *INCBIN_STYLE_CAMEL* producing symbols of the form: - * @code - * #include "incbin.h" - * INCBIN(Foo, "foo.txt"); - * - * // Now you have the following symbols: - * // const unsigned char FooData[]; - * // const unsigned char *const FooEnd; - * // const unsigned int FooSize; - * @endcode - * - * If however you specify a style before including: e.g: - * @code - * #define INCBIN_STYLE INCBIN_STYLE_SNAKE - * #include "incbin.h" - * INCBIN(foo, "foo.txt"); - * - * // Now you have the following symbols: - * // const unsigned char foo_data[]; - * // const unsigned char *const foo_end; - * // const unsigned int foo_size; - * @endcode - */ -#if !defined(INCBIN_STYLE) -# define INCBIN_STYLE INCBIN_STYLE_CAMEL -#endif - -/* Style lookup tables */ -#define INCBIN_STYLE_0_DATA Data -#define INCBIN_STYLE_0_END End -#define INCBIN_STYLE_0_SIZE Size -#define INCBIN_STYLE_1_DATA _data -#define INCBIN_STYLE_1_END _end -#define INCBIN_STYLE_1_SIZE _size - -/* Style lookup: returning identifier */ -#define INCBIN_STYLE_IDENT(TYPE) \ - INCBIN_CONCATENATE( \ - INCBIN_STYLE_, \ - INCBIN_CONCATENATE( \ - INCBIN_EVAL(INCBIN_STYLE), \ - INCBIN_CONCATENATE(_, TYPE))) - -/* Style lookup: returning string literal */ -#define INCBIN_STYLE_STRING(TYPE) \ - INCBIN_STRINGIZE( \ - INCBIN_STYLE_IDENT(TYPE)) \ - -/* Generate the global labels by indirectly invoking the macro with our style - * type and concatenating the name against them. */ -#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \ - INCBIN_INVOKE( \ - INCBIN_GLOBAL, \ - INCBIN_CONCATENATE( \ - NAME, \ - INCBIN_INVOKE( \ - INCBIN_STYLE_IDENT, \ - TYPE))) \ - INCBIN_INVOKE( \ - INCBIN_TYPE, \ - INCBIN_CONCATENATE( \ - NAME, \ - INCBIN_INVOKE( \ - INCBIN_STYLE_IDENT, \ - TYPE))) - -/** - * @brief Externally reference binary data included in another translation unit. - * - * Produces three external symbols that reference the binary data included in - * another translation unit. - * - * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with - * "Data", as well as "End" and "Size" after. An example is provided below. - * - * @param NAME The name given for the binary data - * - * @code - * INCBIN_EXTERN(Foo); - * - * // Now you have the following symbols: - * // extern const unsigned char FooData[]; - * // extern const unsigned char *const FooEnd; - * // extern const unsigned int FooSize; - * @endcode - */ -#define INCBIN_EXTERN(NAME) \ - INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char \ - INCBIN_CONCATENATE( \ - INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ - INCBIN_STYLE_IDENT(DATA))[]; \ - INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char *const \ - INCBIN_CONCATENATE( \ - INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ - INCBIN_STYLE_IDENT(END)); \ - INCBIN_EXTERNAL const unsigned int \ - INCBIN_CONCATENATE( \ - INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ - INCBIN_STYLE_IDENT(SIZE)) - -/** - * @brief Include a binary file into the current translation unit. - * - * Includes a binary file into the current translation unit, producing three symbols - * for objects that encode the data and size respectively. - * - * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with - * "Data", as well as "End" and "Size" after. An example is provided below. - * - * @param NAME The name to associate with this binary data (as an identifier.) - * @param FILENAME The file to include (as a string literal.) - * - * @code - * INCBIN(Icon, "icon.png"); - * - * // Now you have the following symbols: - * // const unsigned char IconData[]; - * // const unsigned char *const IconEnd; - * // const unsigned int IconSize; - * @endcode - * - * @warning This must be used in global scope - * @warning The identifiers may be different if INCBIN_STYLE is not default - * - * To externally reference the data included by this in another translation unit - * please @see INCBIN_EXTERN. - */ -#ifdef _MSC_VER -#define INCBIN(NAME, FILENAME) \ - INCBIN_EXTERN(NAME) -#else -#define INCBIN(NAME, FILENAME) \ - __asm__(INCBIN_SECTION \ - INCBIN_GLOBAL_LABELS(NAME, DATA) \ - INCBIN_ALIGN_HOST \ - INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \ - INCBIN_MACRO " \"" FILENAME "\"\n" \ - INCBIN_GLOBAL_LABELS(NAME, END) \ - INCBIN_ALIGN_BYTE \ - INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \ - INCBIN_BYTE "1\n" \ - INCBIN_GLOBAL_LABELS(NAME, SIZE) \ - INCBIN_ALIGN_HOST \ - INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \ - INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \ - INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \ - ); \ - INCBIN_EXTERN(NAME) - -#endif -#endif diff --git a/unittests/wasm_tests.cpp b/unittests/wasm_tests.cpp index 41373269c7..d1078baaea 100644 --- a/unittests/wasm_tests.cpp +++ b/unittests/wasm_tests.cpp @@ -20,10 +20,10 @@ #include #include +#include #include #include -#include "incbin.h" #include "test_wasts.hpp" #include "test_softfloat_wasts.hpp" From 161097d22814689f6dabbd866e5c25b0536f711f Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 20 Jul 2022 17:49:56 -0400 Subject: [PATCH 4/4] remove broad 'using namespace boost' --- libraries/chain/abi_serializer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/chain/abi_serializer.cpp b/libraries/chain/abi_serializer.cpp index 69ccde8626..186f79474e 100644 --- a/libraries/chain/abi_serializer.cpp +++ b/libraries/chain/abi_serializer.cpp @@ -5,13 +5,11 @@ #include #include -using namespace boost; - - namespace eosio { namespace chain { const size_t abi_serializer::max_recursion_depth; + using boost::algorithm::starts_with; using boost::algorithm::ends_with; using std::string; using std::string_view;