OSDN Git Service

lavc/mjpegenc: check av_frame_alloc() failure.
[android-x86/external-ffmpeg.git] / version.sh
1 #!/bin/sh
2
3 # check for git short hash
4 if ! test "$revision"; then
5     revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
6 fi
7
8 # Shallow Git clones (--depth) do not have the N tag:
9 # use 'git-YYYY-MM-DD-hhhhhhh'.
10 test "$revision" || revision=$(cd "$1" &&
11   git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
12
13 # Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
14 # ffmpeg-HEAD-hhhhhhh.
15 if [ -z "$revision" ]; then
16   srcdir=$(cd "$1" && pwd)
17   case "$srcdir" in
18     */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
19       git_hash="${srcdir##*-}";;
20     */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
21       git_hash="${srcdir##*-}";;
22   esac
23 fi
24
25 # no revision number found
26 test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
27
28 # Append the Git hash if we have one
29 test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
30
31 # releases extract the version number from the VERSION file
32 version=$(cd "$1" && cat VERSION 2> /dev/null)
33 test "$version" || version=$revision
34
35 test -n "$3" && version=$version-$3
36
37 if [ -z "$2" ]; then
38     echo "$version"
39     exit
40 fi
41
42 NEW_REVISION="#define FFMPEG_VERSION \"$version\""
43 OLD_REVISION=$(cat version.h 2> /dev/null)
44
45 # Update version.h only on revision changes to avoid spurious rebuilds
46 if test "$NEW_REVISION" != "$OLD_REVISION"; then
47     echo "$NEW_REVISION" > "$2"
48 fi