Browse Source

Clean up / improve generate_version script (#21674)

vanilla_fb_2.0.x
Ryan Finnie 4 years ago
committed by Scott Lahteine
parent
commit
309d82b6aa
  1. 60
      buildroot/bin/generate_version

60
buildroot/bin/generate_version

@ -4,47 +4,35 @@
# #
# Make a Version.h file to accompany CUSTOM_VERSION_FILE # Make a Version.h file to accompany CUSTOM_VERSION_FILE
# #
# Authors: jbrazio, thinkyhead, InsanityAutomation, rfinnie
#
DIR=${1:-"Marlin"} set -e
# MRCC3=$( git merge-base HEAD upstream/bugfix-2.0.x 2>/dev/null )
# MRCC2=$( git merge-base HEAD upstream/bugfix-1.1.x 2>/dev/null )
# MRCC1=$( git merge-base HEAD upstream/1.1.x 2>/dev/null )
# BASE='?'
# if [[ -n $MRCC3 && $MRCC3 != $MRCC2 ]]; then
# BASE=bugfix-2.0.x
# elif [[ -n $MRCC2 ]]; then
# BASE=bugfix-1.1.x
# elif [[ -n $MRCC1 ]]; then
# BASE=1.1.x
# fi
BUILDATE=$(date '+%s')
DISTDATE=$(date '+%Y-%m-%d %H:%M')
BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD) DIR="${1:-Marlin}"
VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null) READ_FILE="${READ_FILE:-${DIR}/Version.h}"
WRITE_FILE="${WRITE_FILE:-${READ_FILE}}"
[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}") BRANCH="$(git -C "${DIR}" symbolic-ref -q --short HEAD 2>/dev/null || true)"
[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null) VERSION="$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null || true)"
SHORT_BUILD_VERSION=$(echo "${BRANCH}") STRING_DISTRIBUTION_DATE="${STRING_DISTRIBUTION_DATE:-$(date '+%Y-%m-%d %H:%M')}"
DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}") SHORT_BUILD_VERSION="${SHORT_BUILD_VERSION:-${BRANCH}}"
DETAILED_BUILD_VERSION="${DETAILED_BUILD_VERSION:-${BRANCH}-${VERSION}}"
# Gets some misc options from their defaults # Gets some misc options from their defaults
DEFAULT_MACHINE_UUID=$(awk -F'"' \ DEFAULT_MACHINE_UUID="${DEFAULT_MACHINE_UUID:-$(awk -F'"' \
'/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h") '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${READ_FILE}")}"
MACHINE_NAME=$(awk -F'"' \ MACHINE_NAME="${MACHINE_NAME:-$(awk -F'"' \
'/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h") '/#define MACHINE_NAME/{ print $2 }' < "${READ_FILE}")}"
PROTOCOL_VERSION=$(awk -F'"' \ PROTOCOL_VERSION="${PROTOCOL_VERSION:-$(awk -F'"' \
'/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h") '/#define PROTOCOL_VERSION/{ print $2 }' < "${READ_FILE}")}"
SOURCE_CODE_URL=$(awk -F'"' \ SOURCE_CODE_URL="${SOURCE_CODE_URL:-$(awk -F'"' \
'/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h") '/#define SOURCE_CODE_URL/{ print $2 }' < "${READ_FILE}")}"
WEBSITE_URL=$(awk -F'"' \ WEBSITE_URL="${WEBSITE_URL:-$(awk -F'"' \
'/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h") '/#define WEBSITE_URL/{ print $2 }' < "${READ_FILE}")}"
cat > "${DIR}/Version.h" <<EOF cat > "${WRITE_FILE}" <<EOF
/** /**
* Marlin 3D Printer Firmware * Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
@ -97,7 +85,7 @@ cat > "${DIR}/Version.h" <<EOF
* version was tagged. * version was tagged.
*/ */
#ifndef STRING_DISTRIBUTION_DATE #ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "${DISTDATE}" #define STRING_DISTRIBUTION_DATE "${STRING_DISTRIBUTION_DATE}"
#endif #endif
/** /**

Loading…
Cancel
Save