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
|
|
|
|
echo "/* This file is automatically generated by an Arduino hook" >"$OUTFILE"
|
|
|
|
echo " * Do not manually edit it" >>"$OUTFILE"
|
|
|
|
echo " * It does not get committed to the repository" >>"$OUTFILE"
|
|
|
|
echo " */" >>"$OUTFILE"
|
|
|
|
echo "" >>"$OUTFILE"
|
2015-06-02 08:01:40 -05:00
|
|
|
|
2015-06-03 17:55:38 -05:00
|
|
|
echo "#define BUILD_UNIX_DATETIME" `date +%s` >>"$OUTFILE"
|
|
|
|
echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE"
|
2015-06-02 08:01:40 -05:00
|
|
|
( set +e
|
2015-06-03 17:55:38 -05:00
|
|
|
cd "$DIR"
|
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
|
|
|
|
VERSION=`git describe --tags --first-parent 2>/dev/null`
|
|
|
|
if [ "x$VERSION" != "x" ] ; then
|
2015-06-03 17:55:38 -05:00
|
|
|
echo "#define BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
|
2015-06-02 08:01:40 -05:00
|
|
|
fi
|
|
|
|
URL=`git config --local --get remote.origin.url | sed "sx.*github.com:xhttps://github.com/x" | sed "sx\.gitx/x"`
|
|
|
|
if [ "x$URL" != "x" ] ; then
|
2015-06-03 17:55:38 -05:00
|
|
|
echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
|
|
|
|
echo "// Deprecated URL definition" >>"$OUTFILE"
|
|
|
|
echo "#define FIRMWARE_URL \""$URL"\"" >>"$OUTFILE"
|
2015-06-02 08:01:40 -05:00
|
|
|
fi
|
|
|
|
)
|