My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

generate_version_header_for_marlin 1.6KB

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