-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunbuild.sh
45 lines (40 loc) · 984 Bytes
/
runbuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
# Assumes, and requires, user to launch from the same folder as this script.
TOP_DIR="$PWD"
BUILD_ARCH="$1"
BUILD_TYPE="$2"
PI_TOOLCHAIN_FILE="~/dev/Toolchain-rpi.cmake"
case "$BUILD_ARCH" in
x86)
;;
pi)
TOOLCHAIN="$PI_TOOLCHAIN_FILE"
;;
*)
echo "Please use \"x86\" or \"pi\" as first architecture argument."
exit 1
;;
esac
case "$BUILD_TYPE" in
Debug|Release)
;;
*)
echo "Please use \"Release\" or \"Debug\" as second build type argument."
exit 1
;;
esac
echo "Building for $BUILD_ARCH $BUILD_TYPE."
BUILD_FOLDER="build/$BUILD_ARCH/$BUILD_TYPE"
if [ ! -d "$BUILD_FOLDER" ]; then
mkdir -p "$BUILD_FOLDER"
fi
pushd "$BUILD_FOLDER"
cmake "$TOP_DIR" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DCMAKE_INSTALL_PREFIX="$TOP_DIR"
if [ $? -eq 0 ]; then
make -j4 package
if [ $? -eq 0 ] && [ "$BUILD_ARCH" = "pi" ]; then
echo "Attempting to upload to pi:"
scp *.deb pi: || echo "Could not upload to RPi."
fi
fi
popd