From 54375cc7a418cb3e04e766c3f24c06ac253e14e6 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Wed, 3 Jun 2015 15:55:38 -0700 Subject: [PATCH 1/2] Quote paths so build scripts work when directories have space in their name. Currently if you clone Marlin to a directory with a space in the name, Arduino will generate an error. Because when executed the path ends up split into two separate arguments. --- .../hardware/marlin/avr/platform.local.txt | 2 +- .../bin/generate_version_header_for_marlin | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/platform.local.txt b/ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/platform.local.txt index 2beeabaa2..7516f5065 100644 --- a/ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/platform.local.txt +++ b/ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/platform.local.txt @@ -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" diff --git a/LinuxAddons/bin/generate_version_header_for_marlin b/LinuxAddons/bin/generate_version_header_for_marlin index baee86cfb..1a864f5fb 100755 --- a/LinuxAddons/bin/generate_version_header_for_marlin +++ b/LinuxAddons/bin/generate_version_header_for_marlin @@ -1,18 +1,18 @@ #!/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 + cd "$DIR" BRANCH=`git symbolic-ref --short HEAD` if [ "x$BRANCH" == "xHEAD" ] ; then BRANCH="" @@ -23,13 +23,13 @@ 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 ) From b3a3080b4b3565b3f59f8627212e59960abeeb87 Mon Sep 17 00:00:00 2001 From: Richard Wackerbarth Date: Wed, 3 Jun 2015 22:55:11 -0500 Subject: [PATCH 2/2] Suppress error when on detached head --- LinuxAddons/bin/generate_version_header_for_marlin | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/LinuxAddons/bin/generate_version_header_for_marlin b/LinuxAddons/bin/generate_version_header_for_marlin index 1a864f5fb..0fa120bde 100755 --- a/LinuxAddons/bin/generate_version_header_for_marlin +++ b/LinuxAddons/bin/generate_version_header_for_marlin @@ -13,8 +13,8 @@ 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 + BRANCH=`git symbolic-ref -q --short HEAD` + if [ "x$BRANCH" == "x" ] ; then BRANCH="" elif [ "x$BRANCH" == "xDevelopment" ] ; then BRANCH=" dev" @@ -31,5 +31,4 @@ echo "#define STRING_DISTRIBUTION_DATE" `date '+"%Y-%m-%d %H:%M"'` >>"$OUTFILE" echo "// Deprecated URL definition" >>"$OUTFILE" echo "#define FIRMWARE_URL \""$URL"\"" >>"$OUTFILE" fi - )