From 75feacbafa2a1fe258f85963205b8c28a976badc Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 26 Mar 2013 23:30:49 +0000 Subject: [PATCH] Make all commands print git version and improve version string. Currently the format of the first line of the help output varies between executables, for example: para_afh git (0.4.12.12.g15a4: spectral gravity) para_audioc git This difference comes from the fact that para_afh has its own ->print_help method which uses the VERSION_SINGLE_LINE macro of version.h while para_audioc relies on gengetopt's help output. The latter uses the make variable PACKAGE_VERSION which gets initialized at configure time through the second argument in AC_INIT of configure.ac. This value is either the version number for or the string "git". It's a good thing to have the abbreviated git version encoded in all executables, so this commit changes the argument of gengetopt's --set-version to the git version string including the codename. With the patch applied, the output of all commands looks like this if --version was given: para_filter 0.4.12.12.g11d7 (spectral gravity) To make sure things stay consistent, the patch introduces the VERSION_SINGLE_LINE macro and changes all commands to use it instead of open coding the version string. --- audiod.c | 3 +-- filter.c | 3 +-- m4/gengetopt/makefile | 4 ++-- play.c | 4 +--- recv.c | 3 +-- version.h | 6 ++++-- write.c | 3 +-- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/audiod.c b/audiod.c index e3e3bd9a..e0ca15ef 100644 --- a/audiod.c +++ b/audiod.c @@ -1305,8 +1305,7 @@ __noreturn static void print_help_and_die(void) const char **p = d? audiod_args_info_detailed_help : audiod_args_info_help; - printf_or_die("%s\n\n", AUDIOD_CMDLINE_PARSER_PACKAGE "-" - AUDIOD_CMDLINE_PARSER_VERSION); + printf_or_die("%s\n\n", VERSION_SINGLE_LINE("audiod")); printf_or_die("%s\n\n", audiod_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); diff --git a/filter.c b/filter.c index c6af586d..65d6c64b 100644 --- a/filter.c +++ b/filter.c @@ -51,8 +51,7 @@ __noreturn static void print_help_and_die(void) const char **p = d? filter_args_info_detailed_help : filter_args_info_help; - printf_or_die("%s\n\n", FILTER_CMDLINE_PARSER_PACKAGE "-" - FILTER_CMDLINE_PARSER_VERSION); + printf_or_die("%s\n\n", VERSION_SINGLE_LINE("filter")); printf_or_die("%s\n\n", filter_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index 05be1379..7e1d10b5 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -1,6 +1,6 @@ define ggo_opts --output-dir=$(cmdline_dir) \ - --set-version="$(PACKAGE_VERSION)" \ + --set-version="$(GIT_VERSION) ($(codename))" \ --arg-struct-name=$(*F)_args_info \ --file-name=$(*F).cmdline \ --func-name=$(*F)_cmdline_parser \ @@ -9,7 +9,7 @@ endef .PRECIOUS: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h $(ggo_dir)/%.ggo -$(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo | $(cmdline_dir) +$(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo git-version.h | $(cmdline_dir) @[ -z "$(Q)" ] || echo 'GGO $<' $(Q) $(GENGETOPT) $(ggo_opts) < $< diff --git a/play.c b/play.c index 814ec16a..9204792d 100644 --- a/play.c +++ b/play.c @@ -153,9 +153,7 @@ __noreturn static void print_help_and_die(void) const char **p = d? play_args_info_detailed_help : play_args_info_help; -// printf_or_die("%s\n\n", PLAY_CMDLINE_PARSER_PACKAGE "-" -// PLAY_CMDLINE_PARSER_VERSION); - + printf_or_die("%s\n\n", VERSION_SINGLE_LINE("play")); printf_or_die("%s\n\n", play_args_info_usage); if (d) printf_or_die("%s\n", PP_DESC); diff --git a/recv.c b/recv.c index bc727de0..f8b5847c 100644 --- a/recv.c +++ b/recv.c @@ -43,8 +43,7 @@ __noreturn static void print_help_and_die(void) const char **p = d? recv_args_info_detailed_help : recv_args_info_help; - printf_or_die("%s\n\n", RECV_CMDLINE_PARSER_PACKAGE "-" - RECV_CMDLINE_PARSER_VERSION); + printf_or_die("%s\n\n", VERSION_SINGLE_LINE("recv")); printf_or_die("%s\n\n", recv_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); diff --git a/version.h b/version.h index 3d865211..6309fd02 100644 --- a/version.h +++ b/version.h @@ -2,9 +2,11 @@ #include "git-version.h" +#define VERSION_SINGLE_LINE(prefix) "para_" prefix \ + " " GIT_VERSION " (" CODENAME ")" + /** Version text printed by all executables if -V was given. */ -#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \ - " (" GIT_VERSION ": " CODENAME ")" "\n" \ +#define VERSION_TEXT(prefix) VERSION_SINGLE_LINE(prefix) "\n" \ "Copyright (C) 2013 Andre Noll\n" \ "This is free software with ABSOLUTELY NO WARRANTY." \ " See COPYING for details.\n" \ diff --git a/write.c b/write.c index f4f757ff..0f04fe52 100644 --- a/write.c +++ b/write.c @@ -39,8 +39,7 @@ __noreturn static void print_help_and_die(void) const char **p = d? write_args_info_detailed_help : write_args_info_help; - printf_or_die("%s\n\n", WRITE_CMDLINE_PARSER_PACKAGE "-" - WRITE_CMDLINE_PARSER_VERSION); + printf_or_die("%s\n\n", VERSION_SINGLE_LINE("write")); printf_or_die("%s\n\n", write_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); -- 2.39.2