1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-28 06:21:31 +00:00

Merge branch 'GenerateVersionHeader' into Development

This commit is contained in:
Richard Wackerbarth 2015-06-06 17:21:35 -05:00
commit 6b095af9b1
2 changed files with 17 additions and 18 deletions

View File

@ -1,2 +1,2 @@
compiler.cpp.extra_flags=-DHAS_AUTOMATIC_VERSIONING
recipe.hooks.prebuild.pattern=/usr/local/bin/generate_version_header_for_marlin {build.source.path} {build.path}/_Version.h
recipe.hooks.prebuild.pattern=/usr/local/bin/generate_version_header_for_marlin "{build.source.path}" "{build.path}/_Version.h"

View File

@ -1,20 +1,20 @@
#!/usr/bin/env bash
# generate_version_header_for_marlin
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
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"
echo "#define BUILD_UNIX_DATETIME" `date +%s` >>$OUTFILE
echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>$OUTFILE
echo "#define BUILD_UNIX_DATETIME" `date +%s` >>"$OUTFILE"
echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE"
( set +e
cd $DIR
BRANCH=`git symbolic-ref --short HEAD`
if [ "x$BRANCH" == "xHEAD" ] ; then
cd "$DIR"
BRANCH=`git symbolic-ref -q --short HEAD`
if [ "x$BRANCH" == "x" ] ; then
BRANCH=""
elif [ "x$BRANCH" == "xDevelopment" ] ; then
BRANCH=" dev"
@ -23,13 +23,12 @@ echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>$OUTFILE
fi
VERSION=`git describe --tags --first-parent 2>/dev/null`
if [ "x$VERSION" != "x" ] ; then
echo "#define BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>$OUTFILE
echo "#define BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
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
echo "#define SOURCE_CODE_URL \""$URL"\"" >>$OUTFILE
echo "// Deprecated URL definition" >>$OUTFILE
echo "#define FIRMWARE_URL \""$URL"\"" >>$OUTFILE
echo "#define SOURCE_CODE_URL \""$URL"\"" >>"$OUTFILE"
echo "// Deprecated URL definition" >>"$OUTFILE"
echo "#define FIRMWARE_URL \""$URL"\"" >>"$OUTFILE"
fi
)