Merge pull request #2353 from ethereum/license_output

Include license and warranty statement with solc.
This commit is contained in:
Alex Beregszaszi 2017-06-13 16:03:24 +01:00 committed by GitHub
commit 40f5690f68
3 changed files with 31 additions and 3 deletions

View File

@ -24,6 +24,10 @@ include(EthExecutableHelper)
# Include utils # Include utils
include(EthUtils) include(EthUtils)
# Create license.h from LICENSE.txt and template
file(READ ${CMAKE_SOURCE_DIR}/LICENSE.txt LICENSE_TEXT)
configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" "license.h")
include(EthOptions) include(EthOptions)
configure_project(TESTS) configure_project(TESTS)

View File

@ -0,0 +1,3 @@
#pragma once
static char const* licenseText = R"(@LICENSE_TEXT@)";

View File

@ -23,6 +23,7 @@
#include "CommandLineInterface.h" #include "CommandLineInterface.h"
#include "solidity/BuildInfo.h" #include "solidity/BuildInfo.h"
#include "license.h"
#include <libsolidity/interface/Version.h> #include <libsolidity/interface/Version.h>
#include <libsolidity/parsing/Scanner.h> #include <libsolidity/parsing/Scanner.h>
@ -94,6 +95,7 @@ static string const g_strHelp = "help";
static string const g_strInputFile = "input-file"; static string const g_strInputFile = "input-file";
static string const g_strInterface = "interface"; static string const g_strInterface = "interface";
static string const g_strJulia = "julia"; static string const g_strJulia = "julia";
static string const g_strLicense = "license";
static string const g_strLibraries = "libraries"; static string const g_strLibraries = "libraries";
static string const g_strLink = "link"; static string const g_strLink = "link";
static string const g_strMetadata = "metadata"; static string const g_strMetadata = "metadata";
@ -186,6 +188,13 @@ static void version()
exit(0); exit(0);
} }
static void license()
{
// This is a static variable generated by cmake from LICENSE.txt
cout << licenseText << endl;
exit(0);
}
static bool needsHumanTargetedStdout(po::variables_map const& _args) static bool needsHumanTargetedStdout(po::variables_map const& _args)
{ {
if (_args.count(g_argGas)) if (_args.count(g_argGas))
@ -510,8 +519,12 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da
bool CommandLineInterface::parseArguments(int _argc, char** _argv) bool CommandLineInterface::parseArguments(int _argc, char** _argv)
{ {
// Declare the supported options. // Declare the supported options.
po::options_description desc( po::options_description desc(R"(solc, the Solidity commandline compiler.
R"(solc, the Solidity commandline compiler.
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See 'solc --license'
for details.
Usage: solc [options] [input_file...] Usage: solc [options] [input_file...]
Compiles the given Solidity input files (or the standard input if none given or Compiles the given Solidity input files (or the standard input if none given or
"-" is used as a file name) and outputs the components specified in the options "-" is used as a file name) and outputs the components specified in the options
@ -523,10 +536,12 @@ Example:
Allowed options)", Allowed options)",
po::options_description::m_default_line_length, po::options_description::m_default_line_length,
po::options_description::m_default_line_length - 23); po::options_description::m_default_line_length - 23
);
desc.add_options() desc.add_options()
(g_argHelp.c_str(), "Show help message and exit.") (g_argHelp.c_str(), "Show help message and exit.")
(g_argVersion.c_str(), "Show version and exit.") (g_argVersion.c_str(), "Show version and exit.")
(g_strLicense.c_str(), "Show licensing information and exit.")
(g_argOptimize.c_str(), "Enable bytecode optimizer.") (g_argOptimize.c_str(), "Enable bytecode optimizer.")
( (
g_argOptimizeRuns.c_str(), g_argOptimizeRuns.c_str(),
@ -633,6 +648,12 @@ Allowed options)",
return false; return false;
} }
if (m_args.count(g_strLicense))
{
license();
return false;
}
if (m_args.count(g_argCombinedJson)) if (m_args.count(g_argCombinedJson))
{ {
vector<string> requests; vector<string> requests;