/
setup.sh
executable file
·53 lines (43 loc) · 1.14 KB
/
setup.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
46
47
48
49
50
51
52
53
#!/bin/sh
set -e
script_dir=$(dirname $(readlink -f "$0"))
build_dir="$1"
if [ ! -n "$build_dir" ]; then
echo "Error: Must specify build directory"
exit 1
fi
case $2 in
armel|armhf)
arch=$2
;;
*)
echo "Error: Must specify 'armel' or 'armhf'"
exit 1
;;
esac
if ! which docker >/dev/null; then
echo "Error: Docker is not installed"
exit 1
fi
image_name="ev3devkit-$arch"
container_name="ev3devkit_$arch"
docker build \
--tag $image_name \
--no-cache \
--file "$script_dir/$arch.dockerfile" \
"$script_dir/"
mkdir -p $build_dir
docker rm --force $container_name >/dev/null 2>&1 || true
docker run \
--volume "$build_dir:/build" \
--volume "$(pwd):/src" \
--workdir /build \
--name $container_name \
--env "TERM=$TERM" \
--env "DESTDIR=/build/dist" \
--tty \
--detach \
$image_name tail
docker exec --tty $container_name cmake /src -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/toolchain.cmake
echo "Done. You can now compile by running 'docker exec --tty $container_name make'"