2015-06-02 08:01:40 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# generate_version_header_for_marlin
|
|
|
|
|
2015-06-03 17:55:38 -05:00
|
|
|
DIR="$1" export DIR
|
|
|
|
OUTFILE="$2" export OUTFILE
|
2016-04-23 23:43:29 -05:00
|
|
|
|
|
|
|
BUILDATE=$(date '+"%s"')
|
|
|
|
DISTDATE=$(date '+"%Y-%m-%d %H:%M"')
|
|
|
|
|
|
|
|
|
|
|
|
cat > "$OUTFILE" <<EOF
|
|
|
|
/**
|
|
|
|
* THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
|
|
|
|
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BUILD_UNIX_DATETIME ${BUILDATE}
|
|
|
|
#define STRING_DISTRIBUTION_DATE ${DISTDATE}
|
|
|
|
#define PROTOCOL_VERSION "1.0"
|
|
|
|
#define MACHINE_NAME "Travis CI"
|
|
|
|
#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin"
|
|
|
|
#define DEFAULT_MACHINE_UUID "3442baa1-08ee-435b-8a10-99d185bd43b8"
|
|
|
|
#define WEBSITE_URL "http://marlinfw.org"
|
|
|
|
EOF
|
2016-04-22 10:07:26 -05:00
|
|
|
|
2015-06-02 08:01:40 -05:00
|
|
|
( set +e
|
2015-06-03 17:55:38 -05:00
|
|
|
cd "$DIR"
|
2016-04-23 23:43:29 -05:00
|
|
|
|
2015-06-03 22:55:11 -05:00
|
|
|
BRANCH=`git symbolic-ref -q --short HEAD`
|
|
|
|
if [ "x$BRANCH" == "x" ] ; then
|
2015-06-02 08:01:40 -05:00
|
|
|
BRANCH=""
|
|
|
|
elif [ "x$BRANCH" == "xDevelopment" ] ; then
|
|
|
|
BRANCH=" dev"
|
|
|
|
else
|
|
|
|
BRANCH=" $BRANCH"
|
|
|
|
fi
|
2016-04-23 23:43:29 -05:00
|
|
|
|
2015-08-01 10:03:46 -05:00
|
|
|
VERSION=`git describe --tags --first-parent 2>/dev/null`
|
2015-06-02 08:01:40 -05:00
|
|
|
if [ "x$VERSION" != "x" ] ; then
|
2015-08-01 10:03:46 -05:00
|
|
|
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"
|
2015-06-02 08:01:40 -05:00
|
|
|
fi
|
|
|
|
)
|