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.2KB

12345678910111213141516171819202122232425262728293031323334
  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 BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
  25. fi
  26. URL=`git config --local --get remote.origin.url | sed "sx.*github.com:xhttps://github.com/x" | sed "sx\.gitx/x"`
  27. if [ "x$URL" != "x" ] ; then
  28. echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
  29. echo "// Deprecated URL definition" >>"$OUTFILE"
  30. echo "#define FIRMWARE_URL \""$URL"\"" >>"$OUTFILE"
  31. fi
  32. )