mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
64 lines
1.9 KiB
19 years ago
|
#!/bin/sh
|
||
|
|
||
11 years ago
|
# Usage: version.sh <ffmpeg-root-dir> <output-version.h> <extra-version>
|
||
|
|
||
17 years ago
|
# check for git short hash
|
||
14 years ago
|
if ! test "$revision"; then
|
||
11 years ago
|
if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then
|
||
|
revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
|
||
|
else
|
||
|
revision=$(cd "$1" && git describe --tags --always 2> /dev/null)
|
||
|
fi
|
||
17 years ago
|
fi
|
||
|
|
||
14 years ago
|
# Shallow Git clones (--depth) do not have the N tag:
|
||
|
# use 'git-YYYY-MM-DD-hhhhhhh'.
|
||
|
test "$revision" || revision=$(cd "$1" &&
|
||
|
git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
|
||
|
|
||
|
# Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
|
||
|
# ffmpeg-HEAD-hhhhhhh.
|
||
|
if [ -z "$revision" ]; then
|
||
|
srcdir=$(cd "$1" && pwd)
|
||
|
case "$srcdir" in
|
||
|
*/ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
|
||
|
git_hash="${srcdir##*-}";;
|
||
|
*/ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
|
||
|
git_hash="${srcdir##*-}";;
|
||
|
esac
|
||
|
fi
|
||
|
|
||
16 years ago
|
# no revision number found
|
||
14 years ago
|
test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
|
||
17 years ago
|
|
||
14 years ago
|
# Append the Git hash if we have one
|
||
|
test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
|
||
|
|
||
16 years ago
|
# releases extract the version number from the VERSION file
|
||
15 years ago
|
version=$(cd "$1" && cat VERSION 2> /dev/null)
|
||
14 years ago
|
test "$version" || version=$revision
|
||
16 years ago
|
|
||
16 years ago
|
test -n "$3" && version=$version-$3
|
||
|
|
||
15 years ago
|
if [ -z "$2" ]; then
|
||
|
echo "$version"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
14 years ago
|
NEW_REVISION="#define FFMPEG_VERSION \"$version\""
|
||
9 years ago
|
OLD_REVISION=$(cat "$2" 2> /dev/null | head -4 | tail -1)
|
||
11 years ago
|
|
||
|
# String used for preprocessor guard
|
||
|
GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
|
||
19 years ago
|
|
||
11 years ago
|
# Update version header only on revision changes to avoid spurious rebuilds
|
||
19 years ago
|
if test "$NEW_REVISION" != "$OLD_REVISION"; then
|
||
11 years ago
|
cat << EOF > "$2"
|
||
9 years ago
|
/* Automatically generated by version.sh, do not manually edit! */
|
||
11 years ago
|
#ifndef $GUARD
|
||
|
#define $GUARD
|
||
|
$NEW_REVISION
|
||
|
#endif /* $GUARD */
|
||
|
EOF
|
||
19 years ago
|
fi
|