mirror of https://github.com/status-im/evmc.git
tools: Add evmc tool main file
The evmc tool can just print help and version information.
This commit is contained in:
parent
fd0077e420
commit
3eb43b55df
|
@ -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).
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
# Copyright 2019 The EVMC Authors.
|
||||
# Licensed under the Apache License, Version 2.0.
|
||||
|
||||
add_subdirectory(evmc)
|
||||
add_subdirectory(vmtester)
|
||||
|
|
|
@ -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)
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue