You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
10 years ago
|
#!/usr/bin/env bash
|
||
6 years ago
|
#
|
||
|
# generate_version
|
||
|
#
|
||
|
# Make a _Version.h file
|
||
|
#
|
||
10 years ago
|
|
||
9 years ago
|
DIR="${1}"
|
||
9 years ago
|
|
||
|
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)
|
||
|
|
||
6 years ago
|
[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}")
|
||
|
[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
|
||
9 years ago
|
|
||
9 years ago
|
SHORT_BUILD_VERSION=$(echo "${BRANCH}")
|
||
|
DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
|
||
|
|
||
9 years ago
|
# 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")
|
||
9 years ago
|
|
||
9 years ago
|
cat > "${DIR}/_Version.h" <<EOF
|
||
9 years ago
|
/**
|
||
|
* THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
|
||
|
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
|
||
9 years ago
|
*
|
||
|
* Branch: ${BRANCH}
|
||
|
* Version: ${VERSION}
|
||
9 years ago
|
*/
|
||
|
|
||
9 years ago
|
#define BUILD_UNIX_DATETIME "${BUILDATE}"
|
||
|
#define STRING_DISTRIBUTION_DATE "${DISTDATE}"
|
||
9 years ago
|
|
||
9 years ago
|
#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
|