-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.sh
executable file
·105 lines (92 loc) · 2.87 KB
/
deploy.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
fileName=${0##*/}
if [ "$#" -ne 1 ]; then
echo "one argument expected after './$fileName'"
echo "Options are: build, cross-setup, cross, clean, gtest-setup, setup"
exit 1
elif [ "$1" == "build" ]; then
./deploy.sh clean
mkdir build && cd build
cmake ..
retVal=$?
if [ $retVal -ne 0 ]; then
echo "failure detected during cmake"
exit 1
fi
make
retVal=$?
if [ $retVal -ne 0 ]; then
echo "failure detected during make"
exit 1
fi
echo "build finished"
elif [ "$1" == "test" ]; then
./deploy.sh build
rm -rf coverage
mkdir coverage
./out/run_all_tests
gcovr -r . --html --html-details -o coverage/coverage-report.html -e Test/
echo "Open ${PWD}/coverage/coverage-report.html to view coverage report"
elif [ "$1" == "cross-setup" ]; then
cd /tmp/
wget -c https://releases.linaro.org/components/toolchain/binaries/6.5-2018.12/arm-linux-gnueabihf/gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar.xz
if [ $? -ne 0 ]; then
echo "Failure to get arm-linux-gnueabihf"
fi
sudo tar xf gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar.xz -C /opt/
rm gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar.xz
echo "cross build setup finished"
elif [ "$1" == "cross" ]; then
./deploy.sh clean
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/beaglebone.cmake ../
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failure detected during cmake (cross compiling). You might want to run './$fileName cross-setup' first."
exit 1
fi
make
retVal=$?
if [ $retVal -ne 0 ]; then
echo "failure detected during make"
exit 1
fi
echo "cross build finished"
elif [ "$1" == "gtest-setup" ]; then
echo "Installing Dependencies (Assumes Debian based System) - Sudo access required"
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake libgtest-dev
sudo apt-get install -y gcovr
echo "Building GTest"
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp *.a /usr/lib
echo "GTest Install Complete"
elif [ "$1" == "setup" ]; then
echo "Installing Dependencies (Assumes Debian based System) - Sudo access required"
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake libgtest-dev
sudo apt-get install -y python3 python3-pip python-is-python3 clang-format
if [ $? -ne 0 ]; then
echo "failure detected during dependency installation"
exit 1
fi
echo "setup finished"
elif [ "$1" == "format" ]; then
find . -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format -style=file -i {} \;
echo "Format successful"
elif [ "$1" == "clean" ]; then
rm -rf build
rm -rf out
rm -rf coverage
echo "clean finished"
elif [ "$1" == "codecov" ]; then
gcovr -r . -x --xml-pretty -o coverage.xml -e Test/
else
echo "Invalid argument: please put it in the form './$fileName build' or './$fileName cross-setup' or './$fileName cross' or './$fileName clean'"
exit 1
fi
exit 0