Skip to content

Commit

Permalink
Added MPNG target for make and added build all script for autobuild s…
Browse files Browse the repository at this point in the history
…ystem
  • Loading branch information
SirAlex committed Sep 25, 2013
1 parent 2a6b456 commit a4d0550
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 3 deletions.
230 changes: 230 additions & 0 deletions Tools/scripts/build_binaries_mpng.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
#!/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"

date
git checkout master
githash=$(git rev-parse HEAD)

hdate=$(date +"%Y-%m/%Y-%m-%d-%H:%m")
mkdir -p binaries/$hdate
binaries=$PWD/../buildlogs/binaries

. 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() {
[ "$FORCE_BUILD" -eq "1" ] && return 1
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
}

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"
}
}

# copy the built firmware to the right directory
copyit() {
file="$1"
dir="$2"
tag="$3"
bname=$(basename $dir)
tdir=$(dirname $(dirname $(dirname $dir)))/$tag/$bname
if [ "$tag" = "latest" ]; then
mkdir -p "$dir"
/bin/cp "$file" "$dir"
addfwversion "$dir"
fi
echo "Copying $file to $tdir"
mkdir -p "$tdir"
addfwversion "$tdir"

rsync "$file" "$tdir"
}

# build plane binaries
build_arduplane() {
tag="$1"
echo "Building ArduPlane $tag binaries"
checkout ArduPlane $tag || return
pushd ArduPlane
for b in apm1 apm2 apm1-hilsensors apm2-hilsensors; do
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
touch $binaries/Plane/$tag
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 &&
rsync ArduPlane.px4 px4fmu.px4 &&
copyit px4fmu.px4 $ddir $tag &&
copyit ArduPlane.px4 $ddir $tag
}
}
popd
git checkout master
}

# build copter binaries
build_arducopter() {
tag="$1"
checkout ArduCopter $tag || return
echo "Building ArduCopter $tag binaries"
pushd ArduCopter
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"
touch $binaries/Copter/$tag
done
done
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
rsync ArduCopter.px4 px4fmu.px4 &&
copyit px4fmu.px4 $ddir $tag &&
copyit ArduCopter.px4 $ddir $tag
done
}
popd
git checkout master
}

# build rover binaries
build_rover() {
tag="$1"
checkout APMrover2 $tag || return
echo "Building APMrover2 $tag binaries"
pushd APMrover2
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
touch $binaries/Rover/$tag
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 &&
rsync APMrover2.px4 px4fmu.px4 &&
copyit px4fmu.px4 $ddir $tag &&
copyit APMrover2.px4 $binaries/Rover/$hdate/PX4 $tag
}
}
popd
git checkout master
}

# 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 || {
popd
pushd ArduPlane
make px4-clean &&
make px4-io &&
copyit px4io.bin $ddir $tag
popd
}
pushd $PX4_ROOT
git checkout master
popd
}
}

build_arducopter() {
tag="$1"
checkout ArduCopter $tag || return
echo "Building ArduCopter $tag binaries"
pushd ArduCopter
for f in quad tri hexa y6 octa octa-quad; do
echo "Building ArduCopter mpng-$f binaries"
ddir="$binaries/Copter/$hdate/mpng-$f"
skip_build $tag $ddir && continue
make clean || continue
make "mpng-$f" -j4 || exit 1
copyit $TMPDIR/ArduCopter.build/ArduCopter.hex "$ddir" "$tag"
touch $binaries/Copter/$tag
done

popd
git checkout master
}

for build in stable; do
#for build in stable beta latest; do
# build_arduplane $build
build_arducopter $build
# build_rover $build
done
#build_px4io latest

rm -rf $TMPDIR

exit 0
4 changes: 4 additions & 0 deletions mk/apm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ ifeq ($(HAL_BOARD),HAL_BOARD_APM1)
include $(MK_DIR)/board_avr.mk
endif

ifeq ($(HAL_BOARD),HAL_BOARD_MPNG)
include $(MK_DIR)/board_avr.mk
endif

ifeq ($(HAL_BOARD),HAL_BOARD_APM2)
include $(MK_DIR)/board_avr.mk
endif
Expand Down
2 changes: 1 addition & 1 deletion mk/configure.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ configure:
@echo BOARD = mega2560 >> $(SKETCHBOOK)/config.mk
@echo >> $(SKETCHBOOK)/config.mk
@echo \# HAL_BOARD determines default HAL target. >> $(SKETCHBOOK)/config.mk
@echo HAL_BOARD ?= HAL_BOARD_APM2 >> $(SKETCHBOOK)/config.mk
@echo HAL_BOARD ?= HAL_BOARD_MPNG >> $(SKETCHBOOK)/config.mk
@echo >> $(SKETCHBOOK)/config.mk
@echo \# The communication port used to communicate with the APM. >> $(SKETCHBOOK)/config.mk
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
Expand Down
4 changes: 4 additions & 0 deletions mk/environ.mk
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ ifneq ($(findstring apm2, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM2
endif

ifneq ($(findstring mpng, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_MPNG
endif

# default to APM2
ifeq ($(HAL_BOARD),)
#$(warning No HAL_BOARD in config.mk - defaulting to HAL_BOARD_APM2)
Expand Down
35 changes: 33 additions & 2 deletions mk/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ apm2: HAL_BOARD = HAL_BOARD_APM2
apm2: TOOLCHAIN = AVR
apm2: all

mpng: HAL_BOARD = HAL_BOARD_MPNG
mpng: TOOLCHAIN = AVR
mpng: all

empty: HAL_BOARD = HAL_BOARD_EMPTY
empty: TOOLCHAIN = AVR
empty: all
Expand Down Expand Up @@ -51,6 +55,9 @@ apm2-hilsensors: apm2
apm2-nologging: EXTRAFLAGS += "-DLOGGING_ENABLED=DISABLED "
apm2-nologging: apm2

mpng-nologging: EXTRAFLAGS += "-DLOGGING_ENABLED=DISABLED "
mpng-nologging: mpng

heli: EXTRAFLAGS += "-DFRAME_CONFIG=HELI_FRAME "
heli: all

Expand Down Expand Up @@ -117,6 +124,31 @@ apm2-heli-hil: EXTRAFLAGS += "-DFRAME_CONFIG=HELI_FRAME "
apm2-heli-hil: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_ATTITUDE "
apm2-heli-hil: apm2

mpng-quad: EXTRAFLAGS += "-DFRAME_CONFIG=QUAD_FRAME "
mpng-quad: mpng

mpng-quad-hil: EXTRAFLAGS += "-DFRAME_CONFIG=QUAD_FRAME "
mpng-quad-hil: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_ATTITUDE "
mpng-quad-hil: mpng

mpng-tri: EXTRAFLAGS += "-DFRAME_CONFIG=TRI_FRAME "
mpng-tri: mpng

mpng-hexa: EXTRAFLAGS += "-DFRAME_CONFIG=HEXA_FRAME "
mpng-hexa: mpng

mpng-y6: EXTRAFLAGS += "-DFRAME_CONFIG=Y6_FRAME "
mpng-y6: mpng

mpng-octa: EXTRAFLAGS += "-DFRAME_CONFIG=OCTA_FRAME "
mpng-octa: mpng

mpng-octa-quad: EXTRAFLAGS += "-DFRAME_CONFIG=OCTA_QUAD_FRAME "
mpng-octa-quad: mpng

mpng-heli: EXTRAFLAGS += "-DFRAME_CONFIG=HELI_FRAME "
mpng-heli: mpng


px4-quad: EXTRAFLAGS += "-DFRAME_CONFIG=QUAD_FRAME "
px4-quad: px4
Expand Down Expand Up @@ -182,5 +214,4 @@ etags:
cd .. && etags -f APMrover2/TAGS --lang=c++ $$(git ls-files APMrover2 libraries)

clean:
@rm -fr $(BUILDROOT)

@rm -fr $(BUILDROOT)

0 comments on commit a4d0550

Please sign in to comment.