2015-06-02 13:01:40 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-09-02 08:27:39 +00:00
|
|
|
#
|
|
|
|
# generate_version
|
|
|
|
#
|
|
|
|
# Make a _Version.h file
|
|
|
|
#
|
2015-06-02 13:01:40 +00:00
|
|
|
|
2019-07-05 08:40:32 +00:00
|
|
|
DIR=${1:-"Marlin/src/inc"}
|
|
|
|
|
|
|
|
# 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
|
2016-05-01 02:31:19 +00:00
|
|
|
|
|
|
|
BUILDATE=$(date '+%s')
|
|
|
|
DISTDATE=$(date '+%Y-%m-%d %H:%M')
|
|
|
|
|
|
|
|
BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
|
|
|
|
VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
|
|
|
|
|
2018-09-02 08:27:39 +00:00
|
|
|
[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}")
|
|
|
|
[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
|
2016-05-01 02:31:19 +00:00
|
|
|
|
2016-05-20 01:30:03 +00:00
|
|
|
SHORT_BUILD_VERSION=$(echo "${BRANCH}")
|
|
|
|
DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
|
|
|
|
|
2016-05-01 02:31:19 +00:00
|
|
|
# Gets some misc options from their defaults
|
|
|
|
DEFAULT_MACHINE_UUID=$(awk -F'"' \
|
|
|
|
'/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
|
|
|
|
MACHINE_NAME=$(awk -F'"' \
|
|
|
|
'/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h")
|
|
|
|
PROTOCOL_VERSION=$(awk -F'"' \
|
|
|
|
'/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h")
|
|
|
|
SOURCE_CODE_URL=$(awk -F'"' \
|
|
|
|
'/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h")
|
|
|
|
WEBSITE_URL=$(awk -F'"' \
|
|
|
|
'/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
|
2016-04-24 04:43:29 +00:00
|
|
|
|
2016-05-20 01:30:03 +00:00
|
|
|
cat > "${DIR}/_Version.h" <<EOF
|
2016-04-24 04:43:29 +00:00
|
|
|
/**
|
|
|
|
* THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
|
|
|
|
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
|
2016-05-20 01:30:03 +00:00
|
|
|
*
|
|
|
|
* Branch: ${BRANCH}
|
|
|
|
* Version: ${VERSION}
|
2016-04-24 04:43:29 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-01 02:31:19 +00:00
|
|
|
#define BUILD_UNIX_DATETIME "${BUILDATE}"
|
|
|
|
#define STRING_DISTRIBUTION_DATE "${DISTDATE}"
|
2016-04-22 15:07:26 +00:00
|
|
|
|
2016-05-01 02:31:19 +00:00
|
|
|
#define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
|
|
|
|
#define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
|
|
|
|
|
|
|
|
#define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
|
|
|
|
#define MACHINE_NAME "${MACHINE_NAME}"
|
|
|
|
#define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
|
|
|
|
#define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
|
|
|
|
#define WEBSITE_URL "${WEBSITE_URL}"
|
|
|
|
EOF
|