2015-06-02 09:01:40 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# generate_version_header_for_marlin
|
|
|
|
|
2015-06-03 18:55:38 -04: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 09:01:40 -04:00
|
|
|
|
2016-04-22 11:07:26 -04:00
|
|
|
echo "#define PROTOCOL_VERSION \"1.0\"" >>"$OUTFILE"
|
|
|
|
echo "#define DEFAULT_SOURCE_URL \"https://github.com/MarlinFirmware/Marlin\"" >>"$OUTFILE"
|
|
|
|
echo "#define DEFAULT_MACHINE_NAME \"Travis 3D Printer\"" >>"$OUTFILE"
|
|
|
|
echo "#define DEFAULT_MACHINE_UUID \"3442baa1-08ee-435b-8a10-99d185bd43b8\"" >>"$OUTFILE"
|
|
|
|
echo "" >>"$OUTFILE"
|
|
|
|
|
2015-06-03 18:55:38 -04:00
|
|
|
echo "#define BUILD_UNIX_DATETIME" `date +%s` >>"$OUTFILE"
|
|
|
|
echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE"
|
2016-04-22 11:07:26 -04:00
|
|
|
echo "" >>"$OUTFILE"
|
|
|
|
|
2015-06-02 09:01:40 -04:00
|
|
|
( set +e
|
2015-06-03 18:55:38 -04:00
|
|
|
cd "$DIR"
|
2015-06-03 23:55:11 -04:00
|
|
|
BRANCH=`git symbolic-ref -q --short HEAD`
|
|
|
|
if [ "x$BRANCH" == "x" ] ; then
|
2015-06-02 09:01:40 -04:00
|
|
|
BRANCH=""
|
|
|
|
elif [ "x$BRANCH" == "xDevelopment" ] ; then
|
|
|
|
BRANCH=" dev"
|
|
|
|
else
|
|
|
|
BRANCH=" $BRANCH"
|
|
|
|
fi
|
2015-08-01 11:03:46 -04:00
|
|
|
VERSION=`git describe --tags --first-parent 2>/dev/null`
|
2015-06-02 09:01:40 -04:00
|
|
|
if [ "x$VERSION" != "x" ] ; then
|
2015-08-01 11:03:46 -04: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 09:01:40 -04:00
|
|
|
fi
|
2015-08-01 11:03:46 -04:00
|
|
|
URL=`git config --local --get remote.origin.url | sed "sx.*github.com.xhttps://github.com/x" | sed "sx\.gitx/x"`
|
2015-06-02 09:01:40 -04:00
|
|
|
if [ "x$URL" != "x" ] ; then
|
2015-06-03 18:55:38 -04:00
|
|
|
echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
|
2015-06-02 09:01:40 -04:00
|
|
|
fi
|
|
|
|
)
|