This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/buildroot/bin/generate_version_header_for_marlin

56 lines
1.6 KiB
Text
Raw Normal View History

2015-06-02 15:01:40 +02:00
#!/usr/bin/env bash
# generate_version_header_for_marlin
DIR="${1}"
2016-05-01 04:31:19 +02: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)
if [ -z "${BRANCH}" ]; then
BRANCH=$(echo "${TRAVIS_BRANCH}")
fi
2016-05-01 04:31:19 +02:00
if [ -z "${VERSION}" ]; then
VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
fi
SHORT_BUILD_VERSION=$(echo "${BRANCH}")
DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
2016-05-01 04:31:19 +02: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 06:43:29 +02:00
cat > "${DIR}/_Version.h" <<EOF
2016-04-24 06:43:29 +02:00
/**
* THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
*
* Branch: ${BRANCH}
* Version: ${VERSION}
2016-04-24 06:43:29 +02:00
*/
2016-05-01 04:31:19 +02:00
#define BUILD_UNIX_DATETIME "${BUILDATE}"
#define STRING_DISTRIBUTION_DATE "${DISTDATE}"
2016-04-22 17:07:26 +02:00
2016-05-01 04:31:19 +02: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