From 2fd8a15fc4e458aee13dd3be7fcba96bb5019c38 Mon Sep 17 00:00:00 2001 From: Jake Farrell Date: Sat, 29 Sep 2012 00:26:36 +0000 Subject: [PATCH] Thrift-1680:Make install requires GNU make Client: build patch: Jake Farrell Updates boost and libevent configure messages, updates thrift help to display error and smaller message, moves help to --help or -help and takes care of // TODO(dreiss): Delete these when everyone is using the new hotness. Welcome to the new hotness everyone. git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1391705 13f79535-47bb-0310-9956-ffa450edef68 --- aclocal/ax_boost_base.m4 | 2 +- aclocal/ax_lib_event.m4 | 2 +- compiler/cpp/src/main.cc | 113 +++++++++------------------------------ 3 files changed, 26 insertions(+), 91 deletions(-) diff --git a/aclocal/ax_boost_base.m4 b/aclocal/ax_boost_base.m4 index 5894d0ca..806f98b9 100644 --- a/aclocal/ax_boost_base.m4 +++ b/aclocal/ax_boost_base.m4 @@ -37,7 +37,7 @@ AC_DEFUN([AX_BOOST_BASE], [ AC_ARG_WITH([boost], - AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]), + AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost [default=yes]. Optionally specify the root prefix dir where boost is installed]), [ if test "$withval" = "no"; then want_boost="no" diff --git a/aclocal/ax_lib_event.m4 b/aclocal/ax_lib_event.m4 index 91de8289..7d2f98a8 100644 --- a/aclocal/ax_lib_event.m4 +++ b/aclocal/ax_lib_event.m4 @@ -141,7 +141,7 @@ AC_DEFUN([AX_LIB_EVENT], dnl Allow search path to be overridden on the command line. AC_ARG_WITH([libevent], - AS_HELP_STRING([--with-libevent@<:@=DIR@:>@], [use libevent (default is yes) - it is possible to specify an alternate root directory for libevent]), + AS_HELP_STRING([--with-libevent@<:@=DIR@:>@], [use libevent [default=yes]. Optionally specify the root prefix dir where libevent is installed]), [ if test "x$withval" = "xno"; then want_libevent="no" diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc index c12b31ab..406c094d 100644 --- a/compiler/cpp/src/main.cc +++ b/compiler/cpp/src/main.cc @@ -633,9 +633,18 @@ void version() { } /** - * Diplays the usage message and then exits with an error code. + * Display the usage message and then exit with an error code. */ void usage() { + fprintf(stderr, "Usage: thrift [options] file\n\n"); + fprintf(stderr, "Use thrift -help for a list of options\n"); + exit(1); +} + +/** + * Diplays the help message and then exits with an error code. + */ +void help() { fprintf(stderr, "Usage: thrift [options] file\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, " -version Print the compiler version\n"); @@ -971,7 +980,9 @@ int main(int argc, char** argv) { ++arg; } - if (strcmp(arg, "-version") == 0) { + if (strcmp(arg, "-help") == 0) { + help(); + } else if (strcmp(arg, "-version") == 0) { version(); exit(1); } else if (strcmp(arg, "-debug") == 0) { @@ -992,7 +1003,7 @@ int main(int argc, char** argv) { } else if (strcmp(arg, "-gen") == 0) { arg = argv[++i]; if (arg == NULL) { - fprintf(stderr, "!!! Missing generator specification\n"); + fprintf(stderr, "Missing generator specification\n"); usage(); } generator_strings.push_back(arg); @@ -1055,7 +1066,7 @@ int main(int argc, char** argv) { arg = argv[++i]; if (arg == NULL) { - fprintf(stderr, "!!! Missing Include directory\n"); + fprintf(stderr, "Missing Include directory\n"); usage(); } g_incl_searchpath.push_back(arg); @@ -1088,7 +1099,7 @@ int main(int argc, char** argv) { return -1; } } else { - fprintf(stderr, "!!! Unrecognized option: %s\n", arg); + fprintf(stderr, "Unrecognized option: %s\n", arg); usage(); } @@ -1097,103 +1108,27 @@ int main(int argc, char** argv) { } } + // display help + if ((strcmp(argv[argc-1], "-help") == 0) || (strcmp(argv[argc-1], "--help") == 0)) { + help(); + } + // if you're asking for version, you have a right not to pass a file - if (strcmp(argv[argc-1], "-version") == 0) { + if ((strcmp(argv[argc-1], "-version") == 0) || (strcmp(argv[argc-1], "--version") == 0)) { version(); exit(1); } - // TODO(dreiss): Delete these when everyone is using the new hotness. - if (gen_cpp) { - pwarning(1, "-cpp is deprecated. Use --gen cpp"); - string gen_string = "cpp:"; - if (gen_dense) { - gen_string.append("dense,"); - } - if (g_cpp_use_include_prefix) { - gen_string.append("include_prefix,"); - } - generator_strings.push_back(gen_string); - } - if (gen_java) { - pwarning(1, "-java is deprecated. Use --gen java"); - generator_strings.push_back("java"); - } - if (gen_javabean) { - pwarning(1, "-javabean is deprecated. Use --gen java:beans"); - generator_strings.push_back("java:beans"); - } - if (gen_csharp) { - pwarning(1, "-csharp is deprecated. Use --gen csharp"); - generator_strings.push_back("csharp"); - } - if (gen_delphi) { - pwarning(1, "-delphi is deprecated. Use --gen delphi"); - generator_strings.push_back("delphi"); - } - if (gen_py) { - pwarning(1, "-py is deprecated. Use --gen py"); - generator_strings.push_back("py"); - } - if (gen_rb) { - pwarning(1, "-rb is deprecated. Use --gen rb"); - generator_strings.push_back("rb"); - } - if (gen_perl) { - pwarning(1, "-perl is deprecated. Use --gen perl"); - generator_strings.push_back("perl"); - } - if (gen_php || gen_phpi) { - pwarning(1, "-php is deprecated. Use --gen php"); - string gen_string = "php:"; - if (gen_phpi) { - gen_string.append("inlined,"); - } else if(gen_phps) { - gen_string.append("server,"); - } else if(gen_phpa) { - gen_string.append("autoload,"); - } else if(gen_phpo) { - gen_string.append("oop,"); - } else if(gen_rest) { - gen_string.append("rest,"); - } - generator_strings.push_back(gen_string); - } - if (gen_cocoa) { - pwarning(1, "-cocoa is deprecated. Use --gen cocoa"); - generator_strings.push_back("cocoa"); - } - if (gen_erl) { - pwarning(1, "-erl is deprecated. Use --gen erl"); - generator_strings.push_back("erl"); - } - if (gen_st) { - pwarning(1, "-st is deprecated. Use --gen st"); - generator_strings.push_back("st"); - } - if (gen_ocaml) { - pwarning(1, "-ocaml is deprecated. Use --gen ocaml"); - generator_strings.push_back("ocaml"); - } - if (gen_hs) { - pwarning(1, "-hs is deprecated. Use --gen hs"); - generator_strings.push_back("hs"); - } - if (gen_xsd) { - pwarning(1, "-xsd is deprecated. Use --gen xsd"); - generator_strings.push_back("xsd"); - } - // You gotta generate something! if (generator_strings.empty()) { - fprintf(stderr, "!!! No output language(s) specified\n\n"); + fprintf(stderr, "No output language(s) specified\n"); usage(); } // Real-pathify it char rp[PATH_MAX]; if (argv[i] == NULL) { - fprintf(stderr, "!!! Missing file name\n"); + fprintf(stderr, "Missing file name\n"); usage(); } if (saferealpath(argv[i], rp) == NULL) { -- 2.17.1