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.

genbuild.sh 793B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. if [ $# -gt 0 ]; then
  3. FILE="$1"
  4. shift
  5. if [ -f "$FILE" ]; then
  6. INFO="$(head -n 1 "$FILE")"
  7. fi
  8. else
  9. echo "Usage: $0 <filename>"
  10. exit 1
  11. fi
  12. if [ -e "$(which git)" ]; then
  13. # clean 'dirty' status of touched files that haven't been modified
  14. git diff >/dev/null 2>/dev/null
  15. # get a string like "v0.6.0-66-g59887e8-dirty"
  16. DESC="$(git describe --dirty 2>/dev/null)"
  17. # get a string like "2012-04-10 16:27:19 +0200"
  18. TIME="$(git log -n 1 --format="%ci")"
  19. fi
  20. if [ -n "$DESC" ]; then
  21. NEWINFO="#define BUILD_DESC \"$DESC\""
  22. else
  23. NEWINFO="// No build information available"
  24. fi
  25. # only update build.h if necessary
  26. if [ "$INFO" != "$NEWINFO" ]; then
  27. echo "$NEWINFO" >"$FILE"
  28. echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"
  29. fi