Commit c5806910 authored by Timothy Gu's avatar Timothy Gu Committed by Michael Niedermayer

version.sh: add preprocessing guards

Signed-off-by: 's avatarTimothy Gu <timothygu99@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 3c5c4cfa
...@@ -42,9 +42,17 @@ if [ -z "$2" ]; then ...@@ -42,9 +42,17 @@ if [ -z "$2" ]; then
fi fi
NEW_REVISION="#define FFMPEG_VERSION \"$version\"" NEW_REVISION="#define FFMPEG_VERSION \"$version\""
OLD_REVISION=$(cat "$2" 2> /dev/null) OLD_REVISION=$(cat "$2" 2> /dev/null | head -3 | tail -1)
# String used for preprocessor guard
GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
# Update version header only on revision changes to avoid spurious rebuilds # Update version header only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then if test "$NEW_REVISION" != "$OLD_REVISION"; then
echo "$NEW_REVISION" > "$2" cat << EOF > "$2"
#ifndef $GUARD
#define $GUARD
$NEW_REVISION
#endif /* $GUARD */
EOF
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment