提交 c6cff96d 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #361 from EOSIO/nathan-misc

Updates for SDK
Subproject commit d48ebabf56b4115753fcabb7648a0ffcf3b0f5e9
Subproject commit b7e07526feec60f887b7579ad9cae78999940fd7
......@@ -2,7 +2,7 @@
#INCLUDE(GetPrerequisites)
#INCLUDE(VersionMacros)
SET( DEFAULT_HEADER_INSTALL_DIR include/\${target} )
SET( DEFAULT_HEADER_INSTALL_DIR include/${target} )
SET( DEFAULT_LIBRARY_INSTALL_DIR lib/ )
SET( DEFAULT_EXECUTABLE_INSTALL_DIR bin/ )
SET( CMAKE_DEBUG_POSTFIX _debug )
......@@ -112,7 +112,14 @@ set( sources
#list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp")
list(APPEND sources ${fc_headers})
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY )
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
INSTALL( TARGETS fc
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION . )
IF(APPLE)
# As of 10.10 yosemite, the OpenSSL static libraries shipped with os x have a dependency
......
......@@ -20,4 +20,11 @@ target_link_libraries( type_generator eos_utilities fc ${CMAKE_DL_LIBS} ${PLATFO
add_custom_command( OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/include/eos/types/generated.hpp"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/type_generator ${CMAKE_CURRENT_SOURCE_DIR}/types.eos ${CMAKE_CURRENT_SOURCE_DIR}/include/eos/types/generated.hpp
DEPENDS types.eos type_generator )
INSTALL( TARGETS
eos_types
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
INSTALL( FILES ${HEADERS} DESTINATION "include/eos/types" )
......@@ -14,6 +14,7 @@ set(sources
string_escape.cpp
tempdir.cpp
words.cpp
wasm.cpp
${HEADERS})
#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY)
......@@ -22,9 +23,10 @@ set(sources
add_library( eos_utilities
${sources}
${HEADERS} )
target_link_libraries( eos_utilities fc )
target_link_libraries( eos_utilities fc WAST WASM )
target_include_directories( eos_utilities
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../wasm-jit/Include" )
if (USE_PCH)
set_target_properties(eos_utilities PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(eos_utilities)
......
#pragma once
#include <string>
#include <vector>
namespace eos { namespace utilities {
std::vector<uint8_t> assemble_wast(const std::string& wast);
} } // namespace eos::utilities
#include <eos/utilities/wasm.hpp>
#include <fc/exception/exception.hpp>
#include <Inline/BasicTypes.h>
#include <IR/Module.h>
#include <IR/Validate.h>
#include <WAST/WAST.h>
#include <WASM/WASM.h>
#include <iostream>
#include <iomanip>
namespace eos { namespace utilities {
std::vector<uint8_t> assemble_wast( const std::string& wast ) {
IR::Module module;
std::vector<WAST::Error> parseErrors;
WAST::parseModule(wast.c_str(),wast.size(),module,parseErrors);
if(parseErrors.size())
{
// Print any parse errors;
std::cerr << "Error parsing WebAssembly text file:" << std::endl;
for(auto& error : parseErrors)
{
std::cerr << ":" << error.locus.describe() << ": " << error.message.c_str() << std::endl;
std::cerr << error.locus.sourceLine << std::endl;
std::cerr << std::setw(error.locus.column(8)) << "^" << std::endl;
}
FC_ASSERT( !"error parsing wast" );
}
try
{
// Serialize the WebAssembly module.
Serialization::ArrayOutputStream stream;
WASM::serialize(stream,module);
return stream.getBytes();
}
catch(Serialization::FatalSerializationException exception)
{
std::cerr << "Error serializing WebAssembly binary file:" << std::endl;
std::cerr << exception.message << std::endl;
throw;
}
}
} } // namespace eos::utilities
......@@ -145,6 +145,13 @@ public:
testing_blockchain(chainbase::database& db, fork_database& fork_db, block_log& blocklog,
chain_initializer_interface& initializer, testing_fixture& fixture);
/**
* @brief Publish the provided contract to the blockchain, owned by owner
* @param owner The account to publish the contract under
* @param contract_wast The WAST of the contract
*/
void set_contract(AccountName owner, const char* contract_wast);
/**
* @brief Produce new blocks, adding them to the blockchain, optionally following a gap of missed blocks
* @param count Number of blocks to produce
......
......@@ -74,6 +74,18 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
#define MKACCT7(chain, name, creator, deposit, owner, active, recovery) \
MKACCT_IMPL(chain, name, creator, owner, active, recovery, deposit)
#define SETCODE3(chain, acct, wast) \
{ \
auto wasm = eos::utilities::assemble_wast(wast); \
types::setcode handler; \
handler.account = #acct; \
handler.code.assign(wasm.begin(), wasm.end()); \
eos::chain::SignedTransaction trx; \
trx.scope = sort_names({config::EosContractName, #acct}); \
transaction_emplace_message(trx, config::EosContractName, vector<types::AccountPermission>{{#acct,"active"}}, \
"setcode", handler); \
}
#define SETAUTH5(chain, account, authname, parentname, auth) \
{ \
eos::chain::SignedTransaction trx; \
......
#pragma once
#include <eos/utilities/wasm.hpp>
#include "macro_support.hpp"
/// Some helpful macros to reduce boilerplate when making testcases
......@@ -170,6 +172,16 @@
*/
#define Make_Account(...) BOOST_PP_OVERLOAD(MKACCT, __VA_ARGS__)(__VA_ARGS__)
/**
* @brief Shorthand way to set the code for an account
*
* @code{.cpp}
* char* wast = //...
* Set_Code(chain, codeacct, wast);
* @endcode
*/
#define Set_Code(...) BOOST_PP_OVERLOAD(SETCODE, __VA_ARGS__)(__VA_ARGS__)
/**
* @brief Shorthand way to create or update named authority on an account
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册