Browse Source

jsonrpcstub integreted into cmake build process

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
46b629a579
  1. 2
      cmake/EthDependencies.cmake
  2. 11
      libweb3jsonrpc/CMakeLists.txt
  3. 16
      test/webthreestubclient.h

2
cmake/EthDependencies.cmake

@ -122,6 +122,8 @@ if (NOT HEADLESS)
string(REGEX REPLACE "npm" "" ETH_NPM_DIRECTORY ${ETH_NPM})
message(" - npm location : ${ETH_NPM}")
find_program(ETH_JSON_RPC_STUB jsonrpcstub)
endif() #HEADLESS
# use multithreaded boost libraries, with -mt suffix

11
libweb3jsonrpc/CMakeLists.txt

@ -32,6 +32,17 @@ target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} solidity)
target_link_libraries(${EXECUTABLE} serpent)
if (ETH_JSON_RPC_STUB)
add_custom_target(jsonrpcstub)
add_custom_command(TARGET jsonrpcstub
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${ETH_JSON_RPC_STUB} spec.json --cpp-server=AbstractWebThreeStubServer --cpp-client=WebThreeStubClient
COMMAND cmake -E rename webthreestubclient.h ../test/webthreestubclient.h
)
add_dependencies(${EXECUTABLE} jsonrpcstub)
endif()
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

16
test/webthreestubclient.h

@ -213,6 +213,16 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_flush() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_flush",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_blockByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
@ -347,13 +357,13 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_changed(const int& param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_changed(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_changed",p);
if (result.isBool())
return result.asBool();
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}

Loading…
Cancel
Save