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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 PROTOCOL_VERSION \"1.0\"" >>"$OUTFILE"
  11. echo "#define DEFAULT_SOURCE_URL \"https://github.com/MarlinFirmware/Marlin\"" >>"$OUTFILE"
  12. echo "#define DEFAULT_MACHINE_NAME \"Travis 3D Printer\"" >>"$OUTFILE"
  13. echo "#define DEFAULT_MACHINE_UUID \"3442baa1-08ee-435b-8a10-99d185bd43b8\"" >>"$OUTFILE"
  14. echo "" >>"$OUTFILE"
  15. echo "#define BUILD_UNIX_DATETIME" `date +%s` >>"$OUTFILE"
  16. echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE"
  17. echo "" >>"$OUTFILE"
  18. ( set +e
  19. cd "$DIR"
  20. BRANCH=`git symbolic-ref -q --short HEAD`
  21. if [ "x$BRANCH" == "x" ] ; then
  22. BRANCH=""
  23. elif [ "x$BRANCH" == "xDevelopment" ] ; then
  24. BRANCH=" dev"
  25. else
  26. BRANCH=" $BRANCH"
  27. fi
  28. VERSION=`git describe --tags --first-parent 2>/dev/null`
  29. if [ "x$VERSION" != "x" ] ; then
  30. echo "#define SHORT_BUILD_VERSION \"$VERSION\"" | sed "s/-.*/$BRANCH\"/" >>"$OUTFILE"
  31. echo "#define DETAILED_BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
  32. else
  33. VERSION=`git describe --tags --first-parent --always 2>/dev/null`
  34. echo "#define SHORT_BUILD_VERSION \"$BRANCH\"" >>"$OUTFILE"
  35. echo "#define DETAILED_BUILD_VERSION \"${BRANCH}-$VERSION\"" >>"$OUTFILE"
  36. fi
  37. URL=`git config --local --get remote.origin.url | sed "sx.*github.com.xhttps://github.com/x" | sed "sx\.gitx/x"`
  38. if [ "x$URL" != "x" ] ; then
  39. echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
  40. fi
  41. )