Skip to content

Commit

Permalink
Embed git version in eosc/eosd/launcher. Log in eosd. Resolves EOSIO#664
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiszczak committed Nov 14, 2017
1 parent ad6c8b9 commit d1ab9c3
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 7 deletions.
17 changes: 16 additions & 1 deletion programs/eosc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@ endif()

find_package( Gperftools QUIET )
if( GPERFTOOLS_FOUND )
message( STATUS "Found gperftools; compiling steemd with TCMalloc")
message( STATUS "Found gperftools; compiling with TCMalloc")
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../.git)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.."
OUTPUT_VARIABLE "eosc_BUILD_VERSION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git commit revision: ${eosc_BUILD_VERSION}")
else()
set(eosc_BUILD_VERSION 0)
endif()
endif()

find_package(Intl REQUIRED)

set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
Expand Down
3 changes: 2 additions & 1 deletion programs/eosc/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/

namespace eosio { namespace client { namespace config {
constexpr char version_str[] = "${eosc_BUILD_VERSION}";
constexpr char locale_path[] = "${LOCALEDIR}";
constexpr char locale_domain[] = "${LOCALEDOMAIN}";
}}};
}}}
11 changes: 9 additions & 2 deletions programs/eosc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Usage: ./eosc create account [OPTIONS] creator name OwnerKey ActiveKey
#include "CLI11.hpp"
#include "help_text.hpp"
#include "localize.hpp"
#include <config.hpp>
#include "config.hpp"

using namespace std;
using namespace eosio;
Expand Down Expand Up @@ -455,7 +455,7 @@ int main( int argc, char** argv ) {
bindtextdomain(locale_domain, locale_path);
textdomain(locale_domain);

CLI::App app{"Command Line Interface to Eos Daemon"};
CLI::App app{"Command Line Interface to Eos Client"};
app.require_subcommand();
app.add_option( "-H,--host", host, localized("the host where eosd is running"), true );
app.add_option( "-p,--port", port, localized("the port where eosd is running"), true );
Expand All @@ -465,6 +465,13 @@ int main( int argc, char** argv ) {
bool verbose_errors = false;
app.add_flag( "-v,--verbose", verbose_errors, localized("output verbose messages on error"));

auto version = app.add_subcommand("version", localized("Retrieve version information"), false);
version->require_subcommand();

version->add_subcommand("client", localized("Retrieve version information of the client"))->set_callback([] {
std::cout << localized("Build version: ${ver}", ("ver", eosio::client::config::version_str)) << std::endl;
});

// Create subcommand
auto create = app.add_subcommand("create", localized("Create various items, on and off the blockchain"), false);
create->require_subcommand();
Expand Down
19 changes: 19 additions & 0 deletions programs/eosd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ if( GPERFTOOLS_FOUND )
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../.git)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.."
OUTPUT_VARIABLE "eosd_BUILD_VERSION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git commit revision: ${eosd_BUILD_VERSION}")
else()
set(eosd_BUILD_VERSION 0)
endif()
endif()

configure_file(config.hpp.in config.hpp ESCAPE_QUOTES)

target_include_directories(eosd PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries( eosd
PRIVATE appbase
PRIVATE account_history_api_plugin account_history_plugin db_plugin
Expand Down
4 changes: 4 additions & 0 deletions programs/eosd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@

#include <boost/exception/diagnostic_information.hpp>

#include "config.hpp"

using namespace appbase;
using namespace eosio;

int main(int argc, char** argv)
{
try {
app().set_version(eosio::eosd::config::version_str);
ilog("eosd version ${ver}", ("ver", app().version()));
app().register_plugin<net_plugin>();
app().register_plugin<chain_api_plugin>();
app().register_plugin<producer_plugin>();
Expand Down
25 changes: 22 additions & 3 deletions programs/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ endif()

find_package( Gperftools QUIET )
if( GPERFTOOLS_FOUND )
message( STATUS "Found gperftools; compiling steemd with TCMalloc")
message( STATUS "Found gperftools; compiling with TCMalloc")
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

target_link_libraries( launcher
PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../.git)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.."
OUTPUT_VARIABLE "launcher_BUILD_VERSION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git commit revision: ${launcher_BUILD_VERSION}")
else()
set(launcher_BUILD_VERSION 0)
endif()
endif()

configure_file(config.hpp.in config.hpp ESCAPE_QUOTES)

target_include_directories(launcher PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries(launcher
PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )

install( TARGETS
launcher
Expand Down
7 changes: 7 additions & 0 deletions programs/launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <netinet/in.h>
#include <net/if.h>

#include "config.hpp"

using namespace std;
namespace bf = boost::filesystem;
namespace bp = boost::process;
Expand Down Expand Up @@ -751,6 +753,7 @@ int main (int argc, char *argv[]) {
("timestamp,i",bpo::value<string>(),"set the timestamp for the first block. Use \"now\" to indicate the current time")
("launch,l",bpo::value<string>(), "select a subset of nodes to launch. Currently may be \"all\", \"none\", or \"local\". If not set, the default is to launch all unless an output file is named, in which case it starts none.")
("kill,k", bpo::value<string>(),"The launcher retrieves the previously started process ids and issue a kill signal to each.")
("version,v", "print version information")
("help,h","print this list");


Expand All @@ -768,6 +771,10 @@ int main (int argc, char *argv[]) {
opts.print(cerr);
return 0;
}
if (vmap.count("version") > 0) {
cout << eosio::launcher::config::version_str << endl;
return 0;
}

if (vmap.count("launch")) {
string l = vmap["launch"].as<string>();
Expand Down

0 comments on commit d1ab9c3

Please sign in to comment.