version.sh 840 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. revision=$(cd "$1" && cat snapshot_version 2> /dev/null)
  3. test "$revision" && revision=SVN-r$revision
  4. # check for git short hash
  5. if ! test "$revision"; then
  6. revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
  7. test "$revision" && revision=git-$revision
  8. fi
  9. # no revision number found
  10. test "$revision" || revision=UNKNOWN
  11. # releases extract the version number from the VERSION file
  12. version=$(cd "$1" && cat VERSION 2> /dev/null)
  13. test "$version" || version=$revision
  14. test -n "$3" && version=$version-$3
  15. if [ -z "$2" ]; then
  16. echo "$version"
  17. exit
  18. fi
  19. NEW_REVISION="#define FFMPEG_VERSION \"$version\""
  20. OLD_REVISION=$(cat version.h 2> /dev/null)
  21. # Update version.h only on revision changes to avoid spurious rebuilds
  22. if test "$NEW_REVISION" != "$OLD_REVISION"; then
  23. echo "$NEW_REVISION" > "$2"
  24. fi