build: identify the build time of the binary in the versioning output

Based on a patch by qyot27. Add export LC_ALL=C on top of version.sh to
make the output locale independent.

Note that the build time will not be updated on every "make" invocation,
but only when the git revision is updated. This is a good thing, as
repeated make invocations should not rebuild the binary. (This would
break "sudo make install" too.)
This commit is contained in:
Stephen Hutchinson 2012-11-23 18:16:50 -05:00 committed by wm4
parent 7146a57cfe
commit 54ce8af6e0
4 changed files with 7 additions and 1 deletions

View File

@ -31,6 +31,7 @@
#define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5))
extern const char *mplayer_version;
extern const char *mplayer_builddate;
char *mp_format_time(double time, bool fractions);

View File

@ -4186,7 +4186,7 @@ static void play_files(struct MPContext *mpctx)
static void print_version(int always)
{
mp_msg(MSGT_CPLAYER, always ? MSGL_INFO : MSGL_V,
"%s (C) 2000-2012 mpv/MPlayer/mplayer2 projects\n", mplayer_version);
"%s (C) 2000-2012 mpv/MPlayer/mplayer2 projects\n built on %s\n", mplayer_version, mplayer_builddate);
}
static bool handle_help_options(struct MPContext *mpctx)

View File

@ -19,3 +19,4 @@
#include "version.h"
const char *mplayer_version = "mpv " VERSION;
const char *mplayer_builddate = BUILDDATE;

View File

@ -1,5 +1,7 @@
#!/bin/sh
export LC_ALL=C
test "$1" && extra="-$1"
# Extract revision number from file used by daily tarball snapshots
@ -15,10 +17,12 @@ test $version || version=git-$git_revision
NEW_REVISION="#define VERSION \"${version}${extra}\""
OLD_REVISION=$(head -n 1 version.h 2> /dev/null)
BUILDDATE="#define BUILDDATE \"$(date)\""
# Update version.h only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
cat <<EOF > version.h
$NEW_REVISION
$BUILDDATE
EOF
fi