File 00_disable_wasm.patch of Package ethereum-cpp

From: Adam Mizerski <adam@mizerski.pl>
Date: 2019-02-12 20:48:31
Upstream: no
Subject: disable wasm

1) It's not needed to build and run tests.
2) It uses private headers of binaryen, which are not packaged.

Index: ethereum-cpp-1.8.0/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/CMakeLists.txt
+++ ethereum-cpp-1.8.0/CMakeLists.txt
@@ -98,12 +98,6 @@ set(UTILS_INCLUDE_DIR "${CMAKE_SOURCE_DI
 
 configure_project()
 
-if(TESTS)
-    # Import binaryen library for testeth.
-    # TODO: remove this once testeth uses binaryen as a CLI tool.
-    include(ProjectBinaryen)
-endif()
-
 add_subdirectory(evmc)
 
 #Global include path for all libs.
Index: ethereum-cpp-1.8.0/test/CMakeLists.txt
===================================================================
--- ethereum-cpp-1.8.0.orig/test/CMakeLists.txt
+++ ethereum-cpp-1.8.0/test/CMakeLists.txt
@@ -118,7 +118,7 @@ find_package(yaml-cpp CONFIG REQUIRED)
 
 add_executable(testeth ${sources})
 target_include_directories(testeth PRIVATE ${UTILS_INCLUDE_DIR})
-target_link_libraries(testeth PRIVATE ethereum ethashseal web3jsonrpc devcrypto devcore aleth-buildinfo cryptopp-static yaml-cpp::yaml-cpp binaryen::binaryen libjson-rpc-cpp::client)
+target_link_libraries(testeth PRIVATE ethereum ethashseal web3jsonrpc devcrypto devcore aleth-buildinfo cryptopp-static yaml-cpp::yaml-cpp libjson-rpc-cpp::client)
 install(TARGETS testeth DESTINATION ${CMAKE_INSTALL_BINDIR})
 
 set_property(SOURCE tools/libtesteth/TestHelper.cpp PROPERTY COMPILE_DEFINITIONS BINARYEN_VERSION=${BINARYEN_VERSION})
Index: ethereum-cpp-1.8.0/test/tools/libtesteth/TestHelper.cpp
===================================================================
--- ethereum-cpp-1.8.0.orig/test/tools/libtesteth/TestHelper.cpp
+++ ethereum-cpp-1.8.0/test/tools/libtesteth/TestHelper.cpp
@@ -7,7 +7,6 @@
 #include "TestHelper.h"
 #include "Options.h"
 #include "TestOutputHelper.h"
-#include "wast2wasm.h"
 
 #include <libdevcore/JsonUtils.h>
 #include <libethashseal/EthashCPUMiner.h>
@@ -342,8 +341,6 @@ string replaceCode(string const& _code)
         checkHexHasEvenLength(_code);
         return _code;
     }
-    if (_code.find("(module") == 0)
-        return wast2wasm(_code);
 
     string compiledCode = compileLLL(_code);
     if (_code.size() > 0)
Index: ethereum-cpp-1.8.0/test/tools/libtesteth/wast2wasm.cpp
===================================================================
--- ethereum-cpp-1.8.0.orig/test/tools/libtesteth/wast2wasm.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "wast2wasm.h"
-
-#include <libdevcore/CommonData.h>
-
-#include <boost/test/unit_test.hpp>
-
-// Disable MSVC warning "unary minus operator applied to unsigned type".
-#pragma warning(push)
-#pragma warning(disable: 4146)
-#include <wasm-binary.h>
-#include <wasm-s-parser.h>
-#include <wasm-validator.h>
-#pragma warning(pop)
-
-using namespace std;
-
-namespace dev
-{
-
-namespace test
-{
-
-/* from https://github.com/ewasm/evm2wasm */
-string wast2wasm(string const& input, bool debug)
-{
-    wasm::Module module;
-
-    try {
-        // FIXME: binaryen 1.37.28 actually modifies the input...
-        //        as a workaround make a copy here
-        string tmp = input;
-        wasm::SExpressionParser parser(const_cast<char*>(tmp.c_str()));
-        wasm::Element& root = *parser.root;
-        wasm::SExpressionWasmBuilder builder(module, *root[0]);
-    } catch (wasm::ParseException& p) {
-        ostringstream err;
-        p.dump(err);
-        BOOST_ERROR("Error parsing wasm: " + err.str());
-    }
-
-    BOOST_REQUIRE_MESSAGE(wasm::WasmValidator().validate(module), "Compiled WASM module is not valid.");
-
-    wasm::BufferWithRandomAccess buffer(debug);
-    wasm::WasmBinaryWriter writer(&module, buffer, debug);
-    writer.setNamesSection(false);
-    writer.write();
-
-    ostringstream output;
-    buffer.writeTo(output);
-
-    return toHexPrefixed(output.str());
-}
-
-}
-
-}
Index: ethereum-cpp-1.8.0/test/tools/libtesteth/wast2wasm.h
===================================================================
--- ethereum-cpp-1.8.0.orig/test/tools/libtesteth/wast2wasm.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include <string>
-
-namespace dev
-{
-
-namespace test
-{
-
-std::string wast2wasm(std::string const& input, bool debug = false);
-
-}
-
-}
openSUSE Build Service is sponsored by