2013-03-10 03:16:56 -03:00
|
|
|
#!/bin/bash
|
|
|
|
# script to build the latest binaries for each vehicle type, ready to upload
|
|
|
|
# Andrew Tridgell, March 2013
|
|
|
|
|
|
|
|
export PATH=$PATH:/bin:/usr/bin
|
|
|
|
|
|
|
|
export TMPDIR=$PWD/build.tmp.$$
|
|
|
|
echo $TMDIR
|
|
|
|
rm -rf $TMPDIR
|
|
|
|
echo "Building in $TMPDIR"
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
date
|
|
|
|
git checkout master
|
2013-03-10 03:16:56 -03:00
|
|
|
githash=$(git rev-parse HEAD)
|
|
|
|
|
|
|
|
hdate=$(date +"%Y-%m/%Y-%m-%d-%H:%m")
|
|
|
|
mkdir -p binaries/$hdate
|
|
|
|
binaries=$PWD/../buildlogs/binaries
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
. config.mk
|
|
|
|
|
|
|
|
# checkout the right version of the tree
|
|
|
|
checkout() {
|
|
|
|
vehicle="$1"
|
|
|
|
tag="$2"
|
|
|
|
git stash
|
|
|
|
if [ "$tag" = "latest" ]; then
|
|
|
|
git checkout master || return 1
|
|
|
|
else
|
|
|
|
git checkout "$vehicle-$tag" || return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if we should skip this build because we have already
|
|
|
|
# built this version
|
|
|
|
skip_build() {
|
2013-05-22 06:20:35 -03:00
|
|
|
[ "$FORCE_BUILD" -eq "1" ] && return 1
|
2013-03-23 00:30:44 -03:00
|
|
|
tag="$1"
|
|
|
|
ddir="$2"
|
|
|
|
bname=$(basename $ddir)
|
|
|
|
ldir=$(dirname $(dirname $(dirname $ddir)))/$tag/$bname
|
|
|
|
[ -d "$ldir" ] || {
|
|
|
|
echo "$ldir doesn't exist - building"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
oldversion=$(cat "$ldir/git-version.txt" | head -1)
|
|
|
|
newversion=$(git log -1 | head -1)
|
|
|
|
[ "$oldversion" = "$newversion" ] && {
|
|
|
|
echo "Skipping build - version match $newversion"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
echo "$ldir needs rebuild"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-04-24 03:14:12 -03:00
|
|
|
addfwversion() {
|
|
|
|
destdir="$1"
|
|
|
|
git log -1 > "$destdir/git-version.txt"
|
|
|
|
[ -f APM_Config.h ] && {
|
|
|
|
version=$(grep 'define.THISFIRMWARE' *.pde 2> /dev/null | cut -d'"' -f2)
|
|
|
|
echo >> "$destdir/git-version.txt"
|
|
|
|
echo "APMVERSION: $version" >> "$destdir/git-version.txt"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
# copy the built firmware to the right directory
|
2013-03-10 03:16:56 -03:00
|
|
|
copyit() {
|
|
|
|
file="$1"
|
|
|
|
dir="$2"
|
2013-03-23 00:30:44 -03:00
|
|
|
tag="$3"
|
2013-03-10 03:16:56 -03:00
|
|
|
bname=$(basename $dir)
|
2013-03-23 00:30:44 -03:00
|
|
|
tdir=$(dirname $(dirname $(dirname $dir)))/$tag/$bname
|
|
|
|
if [ "$tag" = "latest" ]; then
|
|
|
|
mkdir -p "$dir"
|
|
|
|
/bin/cp "$file" "$dir"
|
2013-04-24 03:14:12 -03:00
|
|
|
addfwversion "$dir"
|
2013-03-23 00:30:44 -03:00
|
|
|
fi
|
|
|
|
echo "Copying $file to $tdir"
|
|
|
|
mkdir -p "$tdir"
|
2013-04-24 03:14:12 -03:00
|
|
|
addfwversion "$tdir"
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
rsync "$file" "$tdir"
|
2013-03-10 03:16:56 -03:00
|
|
|
}
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
# build plane binaries
|
|
|
|
build_arduplane() {
|
|
|
|
tag="$1"
|
|
|
|
echo "Building ArduPlane $tag binaries"
|
|
|
|
checkout ArduPlane $tag || return
|
2013-03-10 03:16:56 -03:00
|
|
|
pushd ArduPlane
|
2013-05-31 05:30:11 -03:00
|
|
|
for b in apm1 apm2 apm1-hilsensors apm2-hilsensors; do
|
2013-03-23 00:30:44 -03:00
|
|
|
echo "Building ArduPlane $b binaries"
|
|
|
|
ddir=$binaries/Plane/$hdate/$b
|
|
|
|
skip_build $tag $ddir && continue
|
|
|
|
make clean || continue
|
|
|
|
make $b -j4 || continue
|
|
|
|
copyit $TMPDIR/ArduPlane.build/ArduPlane.hex $ddir $tag
|
2013-04-22 22:23:47 -03:00
|
|
|
touch $binaries/Plane/$tag
|
2013-03-23 00:30:44 -03:00
|
|
|
done
|
|
|
|
test -n "$PX4_ROOT" && test -d "$PX4_ROOT" && {
|
|
|
|
echo "Building ArduPlane PX4 binaries"
|
|
|
|
ddir=$binaries/Plane/$hdate/PX4
|
|
|
|
skip_build $tag $ddir || {
|
|
|
|
make px4-clean &&
|
|
|
|
make px4 &&
|
2013-05-22 06:14:43 -03:00
|
|
|
rsync ArduPlane.px4 px4fmu.px4 &&
|
|
|
|
copyit px4fmu.px4 $ddir $tag &&
|
2013-05-04 05:46:52 -03:00
|
|
|
copyit ArduPlane.px4 $ddir $tag
|
2013-03-23 00:30:44 -03:00
|
|
|
}
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
popd
|
2013-03-23 00:30:44 -03:00
|
|
|
git checkout master
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
# build copter binaries
|
|
|
|
build_arducopter() {
|
|
|
|
tag="$1"
|
|
|
|
checkout ArduCopter $tag || return
|
|
|
|
echo "Building ArduCopter $tag binaries"
|
2013-03-10 03:16:56 -03:00
|
|
|
pushd ArduCopter
|
2013-03-23 00:30:44 -03:00
|
|
|
for b in apm1 apm2; do
|
|
|
|
for f in quad tri hexa y6 octa octa-quad heli quad-hil heli-hil; do
|
|
|
|
echo "Building ArduCopter $b-$f binaries"
|
|
|
|
ddir="$binaries/Copter/$hdate/$b-$f"
|
|
|
|
skip_build $tag $ddir && continue
|
|
|
|
make clean || continue
|
|
|
|
make "$b-$f" -j4 || exit 1
|
|
|
|
copyit $TMPDIR/ArduCopter.build/ArduCopter.hex "$ddir" "$tag"
|
2013-04-22 22:23:47 -03:00
|
|
|
touch $binaries/Copter/$tag
|
2013-03-23 00:30:44 -03:00
|
|
|
done
|
2013-03-18 01:23:09 -03:00
|
|
|
done
|
2013-03-23 00:30:44 -03:00
|
|
|
test -n "$PX4_ROOT" && test -d "$PX4_ROOT" && {
|
|
|
|
for f in quad tri hexa y6 octa octa-quad heli quad-hil heli-hil; do
|
|
|
|
echo "Building ArduCopter PX4-$f binaries"
|
|
|
|
ddir="$binaries/Copter/$hdate/PX4-$f"
|
|
|
|
skip_build $tag $ddir && continue
|
|
|
|
make px4-clean || continue
|
|
|
|
make px4-$f || continue
|
2013-05-22 06:14:43 -03:00
|
|
|
rsync ArduCopter.px4 px4fmu.px4 &&
|
|
|
|
copyit px4fmu.px4 $ddir $tag &&
|
2013-05-04 05:46:52 -03:00
|
|
|
copyit ArduCopter.px4 $ddir $tag
|
2013-03-23 00:30:44 -03:00
|
|
|
done
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
popd
|
2013-03-23 00:30:44 -03:00
|
|
|
git checkout master
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
# build rover binaries
|
|
|
|
build_rover() {
|
|
|
|
tag="$1"
|
|
|
|
checkout APMrover2 $tag || return
|
2013-05-22 06:14:43 -03:00
|
|
|
echo "Building APMrover2 $tag binaries"
|
2013-03-10 03:16:56 -03:00
|
|
|
pushd APMrover2
|
2013-03-23 00:30:44 -03:00
|
|
|
for b in apm1 apm2 apm1-1280; do
|
|
|
|
echo "Building APMrover2 $b binaries"
|
|
|
|
ddir=$binaries/Rover/$hdate/$b
|
|
|
|
skip_build $tag $ddir && continue
|
|
|
|
make clean || continue
|
|
|
|
make $b -j4 || continue
|
|
|
|
copyit $TMPDIR/APMrover2.build/APMrover2.hex $ddir $tag
|
2013-04-22 22:23:47 -03:00
|
|
|
touch $binaries/Rover/$tag
|
2013-03-23 00:30:44 -03:00
|
|
|
done
|
|
|
|
test -n "$PX4_ROOT" && test -d "$PX4_ROOT" && {
|
|
|
|
echo "Building APMrover2 PX4 binaries"
|
|
|
|
ddir=$binaries/Rover/$hdate/PX4
|
|
|
|
skip_build $tag $ddir || {
|
|
|
|
make px4-clean &&
|
|
|
|
make px4 &&
|
2013-05-22 06:14:43 -03:00
|
|
|
rsync APMrover2.px4 px4fmu.px4 &&
|
|
|
|
copyit px4fmu.px4 $ddir $tag &&
|
|
|
|
copyit APMrover2.px4 $binaries/Rover/$hdate/PX4 $tag
|
2013-03-23 00:30:44 -03:00
|
|
|
}
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
popd
|
2013-03-23 00:30:44 -03:00
|
|
|
git checkout master
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
# build PX4io firmware
|
|
|
|
build_px4io() {
|
|
|
|
tag="$1"
|
|
|
|
test -n "$PX4_ROOT" && test -d "$PX4_ROOT" && {
|
|
|
|
echo "Building PX4IO $tag firmware"
|
|
|
|
pushd $PX4_ROOT
|
|
|
|
checkout PX4IO $tag || return
|
|
|
|
ddir=$binaries/PX4IO/$hdate/PX4IO
|
|
|
|
skip_build $tag $ddir || {
|
2013-05-09 17:43:29 -03:00
|
|
|
popd
|
|
|
|
pushd ArduPlane
|
|
|
|
make px4-clean &&
|
|
|
|
make px4-io &&
|
|
|
|
copyit px4io.bin $ddir $tag
|
|
|
|
popd
|
2013-03-23 00:30:44 -03:00
|
|
|
}
|
2013-05-09 17:43:29 -03:00
|
|
|
pushd $PX4_ROOT
|
2013-03-23 00:30:44 -03:00
|
|
|
git checkout master
|
|
|
|
popd
|
|
|
|
}
|
2013-03-10 03:16:56 -03:00
|
|
|
}
|
|
|
|
|
2013-03-23 00:30:44 -03:00
|
|
|
for build in stable beta latest; do
|
|
|
|
build_arduplane $build
|
|
|
|
build_arducopter $build
|
|
|
|
build_rover $build
|
|
|
|
done
|
|
|
|
build_px4io latest
|
|
|
|
|
2013-03-10 03:16:56 -03:00
|
|
|
rm -rf $TMPDIR
|
|
|
|
|
|
|
|
exit 0
|