tools: Add evmc tool main file

The evmc tool can just print help and version information.
This commit is contained in:
Paweł Bylica 2019-12-04 10:42:41 +01:00
parent fd0077e420
commit 3eb43b55df
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
4 changed files with 49 additions and 0 deletions

View File

@ -3,6 +3,7 @@
# Licensed under the Apache License, Version 2.0.
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0074 NEW)
if(TARGET evmc)
# The evmc library has been already created (probably by other submodule).

View File

@ -2,4 +2,5 @@
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
add_subdirectory(evmc)
add_subdirectory(vmtester)

14
tools/evmc/CMakeLists.txt Normal file
View File

@ -0,0 +1,14 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
hunter_add_package(CLI11)
find_package(CLI11 REQUIRED)
add_executable(evmc-tool main.cpp)
set_target_properties(evmc-tool PROPERTIES
OUTPUT_NAME evmc
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set_source_files_properties(main.cpp PROPERTIES
COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")
target_link_libraries(evmc-tool PRIVATE CLI11::CLI11)

33
tools/evmc/main.cpp Normal file
View File

@ -0,0 +1,33 @@
// EVMC: Ethereum Client-VM Connector API.
// Copyright 2019 The EVMC Authors.
// Licensed under the Apache License, Version 2.0.
#include <CLI/CLI.hpp>
int main(int argc, const char** argv)
{
CLI::App app{"EVMC tool"};
const auto& version_flag = *app.add_flag("--version", "Print version information");
try
{
app.parse(argc, argv);
// Handle the --version flag first and exit when present.
if (version_flag)
{
std::cout << "EVMC tool " PROJECT_VERSION "\n";
return 0;
}
return 0;
}
catch (const CLI::ParseError& e)
{
return app.exit(e);
}
catch (...)
{
return -1;
}
}