My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

generate_version_header_for_marlin 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. # generate_version_header_for_marlin
  3. DIR="$1" export DIR
  4. OUTFILE="$2" export OUTFILE
  5. echo "/* This file is automatically generated by an Arduino hook" >"$OUTFILE"
  6. echo " * Do not manually edit it" >>"$OUTFILE"
  7. echo " * It does not get committed to the repository" >>"$OUTFILE"
  8. echo " */" >>"$OUTFILE"
  9. echo "" >>"$OUTFILE"
  10. echo "#define BUILD_UNIX_DATETIME" `date +%s` >>"$OUTFILE"
  11. echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE"
  12. ( set +e
  13. cd "$DIR"
  14. BRANCH=`git symbolic-ref -q --short HEAD`
  15. if [ "x$BRANCH" == "x" ] ; then
  16. BRANCH=""
  17. elif [ "x$BRANCH" == "xDevelopment" ] ; then
  18. BRANCH=" dev"
  19. else
  20. BRANCH=" $BRANCH"
  21. fi
  22. VERSION=`git describe --tags --first-parent 2>/dev/null`
  23. if [ "x$VERSION" != "x" ] ; then
  24. echo "#define SHORT_BUILD_VERSION \"$VERSION\"" | sed "s/-.*/$BRANCH\"/" >>"$OUTFILE"
  25. echo "#define DETAILED_BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
  26. else
  27. VERSION=`git describe --tags --first-parent --always 2>/dev/null`
  28. echo "#define SHORT_BUILD_VERSION \"$BRANCH\"" >>"$OUTFILE"
  29. echo "#define DETAILED_BUILD_VERSION \"${BRANCH}-$VERSION\"" >>"$OUTFILE"
  30. fi
  31. URL=`git config --local --get remote.origin.url | sed "sx.*github.com.xhttps://github.com/x" | sed "sx\.gitx/x"`
  32. if [ "x$URL" != "x" ] ; then
  33. echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
  34. echo "// Deprecated URL definition" >>"$OUTFILE"
  35. echo "#define FIRMWARE_URL \""$URL"\"" >>"$OUTFILE"
  36. fi
  37. )