From 931c1902e15aeefb2e320f2c029e76ac3976f6ce Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 18 Sep 2015 23:01:04 +0200 Subject: [PATCH] dist: added script for merging Arduino sketches --- dist/tools/arduino/pre_build.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 dist/tools/arduino/pre_build.sh diff --git a/dist/tools/arduino/pre_build.sh b/dist/tools/arduino/pre_build.sh new file mode 100755 index 000000000..baf455fbe --- /dev/null +++ b/dist/tools/arduino/pre_build.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# check if at least the application dir and one sketch is given +if [ $# -lt 2 ] +then + echo "[Arduino pre-build] Error: not enough arguments given" + exit 1 +fi + +# 'consume' the application and arduino directories (first argument) +SRCDIR=$1 +shift +APPDIR=$1 +shift + +# create temporary file and put in the file header +cat ${SRCDIR}/pre.snip > ${APPDIR}/_sketches.cpp +# loop through the given sketches and include them into the temp file +for sketch in $@ +do + cat ${sketch} >> ${APPDIR}/_sketches.cpp +done +# and prepend the file with the arduino bootstrapping code +cat ${SRCDIR}/post.snip >> ${APPDIR}/_sketches.cpp