From ff7a303a0eb26203d0d268de51bfc5eda99a7ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= Date: Sun, 1 May 2016 03:31:19 +0100 Subject: [PATCH] Updated version header gen script --- .../bin/generate_version_header_for_marlin | 77 ++++++++++--------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/LinuxAddons/bin/generate_version_header_for_marlin b/LinuxAddons/bin/generate_version_header_for_marlin index 539a3fe5a..5fa9fb633 100755 --- a/LinuxAddons/bin/generate_version_header_for_marlin +++ b/LinuxAddons/bin/generate_version_header_for_marlin @@ -1,12 +1,36 @@ #!/usr/bin/env bash # generate_version_header_for_marlin -DIR="$1" export DIR -OUTFILE="$2" export OUTFILE - -BUILDATE=$(date '+"%s"') -DISTDATE=$(date '+"%Y-%m-%d %H:%M"') - +DIR="$1" +OUTFILE="$2" + +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) + +# Voodoo version tag generator +if [ -z "${VERSION}" ]; then + VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null) + SHORT_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-.*/${BRANCH}/") + DETAILED_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-/${BRANCH}-/") +else + SHORT_BUILD_VERSION=$(echo "${BRANCH}") + DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}") +fi + +# 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") cat > "$OUTFILE" < "$OUTFILE" </dev/null` - if [ "x$VERSION" != "x" ] ; then - echo "#define SHORT_BUILD_VERSION \"$VERSION\"" | sed "s/-.*/$BRANCH\"/" >>"$OUTFILE" - echo "#define DETAILED_BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE" - else - VERSION=`git describe --tags --first-parent --always 2>/dev/null` - echo "#define SHORT_BUILD_VERSION \"$BRANCH\"" >>"$OUTFILE" - echo "#define DETAILED_BUILD_VERSION \"${BRANCH}-$VERSION\"" >>"$OUTFILE" - fi -) +#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