1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 23:06:38 +02:00

core: add git version in build, display it in "weechat-curses --help" and /version

This commit is contained in:
Sebastien Helleu
2012-12-16 23:07:33 +01:00
parent fc0b73207b
commit 2b78673aa9
38 changed files with 425 additions and 70 deletions
+2 -1
View File
@@ -42,7 +42,8 @@ wee-upgrade.c wee-upgrade.h
wee-upgrade-file.c wee-upgrade-file.h
wee-url.c wee-url.h
wee-utf8.c wee-utf8.h
wee-util.c wee-util.h)
wee-util.c wee-util.h
wee-version.c wee-version.h)
# Check for flock support
INCLUDE(CheckSymbolExists)
+3 -1
View File
@@ -66,6 +66,8 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-utf8.c \
wee-utf8.h \
wee-util.c \
wee-util.h
wee-util.h \
wee-version.c \
wee-version.h
EXTRA_DIST = CMakeLists.txt
+4 -1
View File
@@ -42,6 +42,7 @@
#include "wee-backtrace.h"
#include "wee-log.h"
#include "wee-string.h"
#include "wee-version.h"
#include "../plugins/plugin.h"
@@ -157,7 +158,9 @@ weechat_backtrace ()
weechat_backtrace_printf ("======= WeeChat backtrace =======");
weechat_backtrace_printf ("(written by %s, compiled on %s %s)",
PACKAGE_STRING, __DATE__, __TIME__);
version_get_name_version (),
version_get_compilation_date (),
version_get_compilation_time ());
#ifdef HAVE_BACKTRACE
trace_size = backtrace (trace, BACKTRACE_MAX);
+29 -14
View File
@@ -49,6 +49,7 @@
#include "wee-upgrade.h"
#include "wee-utf8.h"
#include "wee-util.h"
#include "wee-version.h"
#include "../gui/gui-bar.h"
#include "../gui/gui-bar-item.h"
#include "../gui/gui-buffer.h"
@@ -4999,20 +5000,28 @@ COMMAND_CALLBACK(uptime)
void
command_version_display (struct t_gui_buffer *buffer,
int send_to_buffer_as_input,
int translated_string)
int translated_string,
int display_git_version)
{
char string[512];
const char *git_version;
/* get git version */
git_version = (display_git_version) ? version_get_git () : NULL;
if (send_to_buffer_as_input)
{
if (translated_string)
{
snprintf (string, sizeof (string),
"WeeChat %s [%s %s %s]",
PACKAGE_VERSION,
"WeeChat %s%s%s%s [%s %s %s]",
version_get_version (),
(git_version && git_version[0]) ? " (git: " : "",
(git_version && git_version[0]) ? git_version : "",
(git_version && git_version[0]) ? ")" : "",
_("compiled on"),
__DATE__,
__TIME__);
version_get_compilation_date (),
version_get_compilation_time ());
input_data (buffer, string);
if (weechat_upgrade_count > 0)
{
@@ -5028,11 +5037,14 @@ command_version_display (struct t_gui_buffer *buffer,
else
{
snprintf (string, sizeof (string),
"WeeChat %s [%s %s %s]",
PACKAGE_VERSION,
"WeeChat %s%s%s%s [%s %s %s]",
version_get_version (),
(git_version && git_version[0]) ? " (git: " : "",
(git_version && git_version[0]) ? git_version : "",
(git_version && git_version[0]) ? ")" : "",
"compiled on",
__DATE__,
__TIME__);
version_get_compilation_date (),
version_get_compilation_time ());
input_data (buffer, string);
if (weechat_upgrade_count > 0)
{
@@ -5048,14 +5060,17 @@ command_version_display (struct t_gui_buffer *buffer,
}
else
{
gui_chat_printf (NULL, "%sWeeChat %s %s[%s%s %s %s%s]",
gui_chat_printf (NULL, "%sWeeChat %s%s%s%s %s[%s%s %s %s%s]",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_VERSION,
version_get_version (),
(git_version && git_version[0]) ? " (git: " : "",
(git_version && git_version[0]) ? git_version : "",
(git_version && git_version[0]) ? ")" : "",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_VALUE),
_("compiled on"),
__DATE__,
__TIME__,
version_get_compilation_date (),
version_get_compilation_time (),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
if (weechat_upgrade_count > 0)
{
@@ -5096,7 +5111,7 @@ COMMAND_CALLBACK(version)
}
command_version_display (buffer, send_to_buffer_as_input,
translated_string);
translated_string, 1);
return WEECHAT_RC_OK;
}
+2 -1
View File
@@ -65,6 +65,7 @@ extern void command_init ();
extern void command_startup (int plugins_loaded);
extern void command_version_display (struct t_gui_buffer *buffer,
int send_to_buffer_as_input,
int translated_string);
int translated_string,
int display_git_version);
#endif /* __WEECHAT_COMMAND_H */
+4 -1
View File
@@ -39,6 +39,7 @@
#include "wee-infolist.h"
#include "wee-log.h"
#include "wee-string.h"
#include "wee-version.h"
#include "../gui/gui-color.h"
#include "../gui/gui-chat.h"
#include "../plugins/plugin.h"
@@ -2042,7 +2043,9 @@ config_file_write_internal (struct t_config_file *config_file,
goto error;
if (!string_iconv_fprintf (config_file->file,
"# %s -- %s v%s\n#\n",
config_file->filename, PACKAGE_NAME, PACKAGE_VERSION))
config_file->filename,
version_get_name (),
version_get_version ()))
goto error;
/* write all sections */
+2 -1
View File
@@ -45,6 +45,7 @@
#include "wee-list.h"
#include "wee-proxy.h"
#include "wee-string.h"
#include "wee-version.h"
#include "../gui/gui-bar.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
@@ -304,7 +305,7 @@ config_change_title (void *data, struct t_config_option *option)
(void) option;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
gui_window_set_title (version_get_name_version ());
}
/*
+5 -1
View File
@@ -41,6 +41,7 @@
#include "wee-log.h"
#include "wee-debug.h"
#include "wee-string.h"
#include "wee-version.h"
#include "../plugins/plugin.h"
@@ -118,7 +119,10 @@ log_init ()
exit (1);
}
log_printf ("%s (%s %s %s)",
PACKAGE_STRING, _("compiled on"), __DATE__, __TIME__);
version_get_name_version (),
_("compiled on"),
version_get_compilation_date (),
version_get_compilation_time ());
}
/*
+106
View File
@@ -0,0 +1,106 @@
/*
* wee-version.c - functions for WeeChat version
*
* Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "config-git.h"
/*
* Returns package name ("weechat").
*/
const char *
version_get_name ()
{
return PACKAGE_NAME;
}
/*
* Returns the WeeChat version.
*
* Examples:
* 0.3.9-dev
* 0.3.9-rc1
* 0.3.9
*/
const char *
version_get_version ()
{
return PACKAGE_VERSION;
}
/*
* Returns the package name ("weechat") + WeeChat version.
*
* Examples:
* weechat 0.3.9-dev
* weechat 0.3.9-rc1
* weechat 0.3.9
*/
const char *
version_get_name_version ()
{
return PACKAGE_STRING;
}
/*
* Returns the output of "git describe" (non-empty only for a devel version,
* if compilation was made* using the git repository, if git command was found).
*
* Example:
* v0.3.9-104-g7eb5cc
*/
const char *
version_get_git ()
{
return PACKAGE_VERSION_GIT;
}
/*
* Returns date of WeeChat compilation.
*
* Example:
* Dec 16 2012
*/
const char *
version_get_compilation_date ()
{
return __DATE__;
}
/*
* Returns time of WeeChat compilation.
*
* Example:
* 18:10:22
*/
const char *
version_get_compilation_time ()
{
return __TIME__;
}
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_VERSION_H
#define __WEECHAT_VERSION_H 1
extern const char *version_get_name ();
extern const char *version_get_version ();
extern const char *version_get_name_version ();
extern const char *version_get_git ();
extern const char *version_get_compilation_date ();
extern const char *version_get_compilation_time ();
#endif /* __WEECHAT_VERSION_H */
+17 -6
View File
@@ -65,6 +65,7 @@
#include "wee-upgrade.h"
#include "wee-utf8.h"
#include "wee-util.h"
#include "wee-version.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-completion.h"
@@ -103,14 +104,23 @@ char *weechat_startup_commands = NULL; /* startup commands (-r flag) */
void
weechat_display_copyright ()
{
const char *git_version;
git_version = version_get_git ();
string_iconv_fprintf (stdout, "\n");
string_iconv_fprintf (stdout,
/* TRANSLATORS: "%s %s" after "compiled on" is date and time */
_("WeeChat %s Copyright %s, compiled on %s %s\n"
_("WeeChat %s%s%s%s Copyright %s, compiled on %s %s\n"
"Developed by Sebastien Helleu <flashcode@flashtux.org> "
"- %s"),
PACKAGE_VERSION, WEECHAT_COPYRIGHT_DATE,
__DATE__, __TIME__, WEECHAT_WEBSITE);
version_get_version (),
(git_version && git_version[0]) ? " (git: " : "",
(git_version && git_version[0]) ? git_version : "",
(git_version && git_version[0]) ? ")" : "",
WEECHAT_COPYRIGHT_DATE,
version_get_compilation_date (),
version_get_compilation_time (),
WEECHAT_WEBSITE);
string_iconv_fprintf (stdout, "\n");
}
@@ -168,7 +178,7 @@ weechat_display_keys ()
_("%s default keys (context: \"%s\"):\n"),
(gui_key_context_string[i] && gui_key_context_string[i][0]) ?
_(gui_key_context_string[i]) : "",
PACKAGE_NAME);
version_get_name ());
string_iconv_fprintf (stdout, "\n");
for (ptr_key = gui_keys[i]; ptr_key; ptr_key = ptr_key->next_key)
{
@@ -299,7 +309,8 @@ weechat_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
string_iconv_fprintf (stdout, PACKAGE_VERSION "\n");
string_iconv_fprintf (stdout, version_get_version ());
fprintf (stdout, "\n");
weechat_shutdown (EXIT_SUCCESS, 0);
}
}
@@ -412,7 +423,7 @@ weechat_welcome_message ()
}
if (CONFIG_BOOLEAN(config_startup_display_version))
{
command_version_display (NULL, 0, 0);
command_version_display (NULL, 0, 0, 0);
}
if (CONFIG_BOOLEAN(config_startup_display_logo) ||
CONFIG_BOOLEAN(config_startup_display_version))
+8 -4
View File
@@ -38,6 +38,7 @@
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../../core/wee-util.h"
#include "../../core/wee-version.h"
#include "../../plugins/plugin.h"
#include "../gui-main.h"
#include "../gui-bar.h"
@@ -90,6 +91,7 @@ gui_main_init ()
struct t_gui_buffer *ptr_buffer;
struct t_gui_bar *ptr_bar;
struct t_gui_bar_window *ptr_bar_win;
char title[256];
initscr ();
@@ -138,9 +140,11 @@ gui_main_init ()
ptr_buffer->short_name = strdup (GUI_BUFFER_MAIN);
/* set title for core buffer */
gui_buffer_set_title (ptr_buffer,
"WeeChat " PACKAGE_VERSION " "
WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE);
snprintf (title, sizeof (title), "WeeChat %s %s - %s",
version_get_version (),
WEECHAT_COPYRIGHT_DATE,
WEECHAT_WEBSITE);
gui_buffer_set_title (ptr_buffer, title);
/* create main window (using full space) */
if (gui_window_new (NULL, ptr_buffer, 0, 0,
@@ -149,7 +153,7 @@ gui_main_init ()
gui_current_window = gui_windows;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
gui_window_set_title (version_get_name_version ());
}
/*
+4 -2
View File
@@ -32,6 +32,7 @@
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
#include "../../core/wee-version.h"
#include "../../plugins/plugin.h"
#include "../gui-bar.h"
#include "../gui-bar-item.h"
@@ -103,7 +104,8 @@ gui_main_init ()
gdk_color_parse ("black", &color_bg);
gui_gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window), PACKAGE_STRING);
gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window),
version_get_name_version ());
g_signal_connect (G_OBJECT (gui_gtk_main_window), "destroy", gtk_main_quit, NULL);
@@ -190,7 +192,7 @@ gui_main_init ()
gui_current_window = gui_windows;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
gui_window_set_title (version_get_name_version ());
}
/*
+13 -3
View File
@@ -43,6 +43,7 @@
#include "../core/wee-string.h"
#include "../core/wee-url.h"
#include "../core/wee-util.h"
#include "../core/wee-version.h"
#include "../gui/gui-bar.h"
#include "../gui/gui-bar-item.h"
#include "../gui/gui-bar-window.h"
@@ -295,20 +296,24 @@ plugin_api_info_get_internal (void *data, const char *info_name,
if (string_strcasecmp (info_name, "version") == 0)
{
return PACKAGE_VERSION;
return version_get_version ();
}
else if (string_strcasecmp (info_name, "version_number") == 0)
{
if (!version_number[0])
{
snprintf (version_number, sizeof (version_number), "%d",
util_version_number (PACKAGE_VERSION));
util_version_number (version_get_version ()));
}
return version_number;
}
else if (string_strcasecmp (info_name, "version_git") == 0)
{
return version_get_git ();
}
else if (string_strcasecmp (info_name, "date") == 0)
{
return __DATE__;
return version_get_compilation_date ();
}
else if (string_strcasecmp (info_name, "dir_separator") == 0)
{
@@ -1023,6 +1028,11 @@ plugin_api_init ()
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "version_number", N_("WeeChat version (as number)"), NULL,
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "version_git", N_("WeeChat git version (output of "
"command \"git describe\" for a "
"development version only, empty for a "
"stable release)"), NULL,
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "date", N_("WeeChat compilation date"), NULL,
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "dir_separator", N_("directory separator"), NULL,