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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # generate_version_header_for_marlin
  3. DIR="$1"
  4. OUTFILE="$2"
  5. BUILDATE=$(date '+%s')
  6. DISTDATE=$(date '+%Y-%m-%d %H:%M')
  7. BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
  8. VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
  9. # Voodoo version tag generator
  10. if [ -z "${VERSION}" ]; then
  11. VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
  12. SHORT_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-.*/${BRANCH}/")
  13. DETAILED_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-/${BRANCH}-/")
  14. else
  15. SHORT_BUILD_VERSION=$(echo "${BRANCH}")
  16. DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
  17. fi
  18. # Gets some misc options from their defaults
  19. DEFAULT_MACHINE_UUID=$(awk -F'"' \
  20. '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
  21. MACHINE_NAME=$(awk -F'"' \
  22. '/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h")
  23. PROTOCOL_VERSION=$(awk -F'"' \
  24. '/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h")
  25. SOURCE_CODE_URL=$(awk -F'"' \
  26. '/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h")
  27. WEBSITE_URL=$(awk -F'"' \
  28. '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
  29. cat > "$OUTFILE" <<EOF
  30. /**
  31. * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
  32. * IT DOES NOT GET COMMITTED TO THE REPOSITORY.
  33. */
  34. #define BUILD_UNIX_DATETIME "${BUILDATE}"
  35. #define STRING_DISTRIBUTION_DATE "${DISTDATE}"
  36. #define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
  37. #define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
  38. #define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
  39. #define MACHINE_NAME "${MACHINE_NAME}"
  40. #define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
  41. #define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
  42. #define WEBSITE_URL "${WEBSITE_URL}"
  43. EOF