forked from JT8D-17/opentrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz_Build.sh
executable file
·133 lines (118 loc) · 3.27 KB
/
z_Build.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#! /bin/bash
clear
# Package requirements (Arch Linux names):
# cmake, ninja, pkgconf, qt5-base, opencv, vtk, hdf5, openmpi, onnxruntime
# Set installation prefix path
otdir="$(dirname "$PWD")/opentrack-install"
# echo "Install prefix: $otdir"
otsrc="$PWD"
logfile="$otsrc/z_buildlog.txt"
arucodir="$otsrc/0_libaruco"
# Function: Pause
function pause(){
echo "Press any key to continue"
read -p "$*"
}
function clean_buildlog(){
if [ -f "$logfile" ]; then
rm "$logfile"
fi
echo "Previous log file deleted" 2>&1 | tee "$logfile"
}
function build_folder(){
if [ ! -d "$otsrc/build" ]; then
echo "Creating build folder"
mkdir "$otsrc/build"
fi
}
function clean_build(){
if [ -d "$otsrc/build" ]; then
echo "Deleting and recreating build folder"
rm -rf "$otsrc/build"
mkdir "$otsrc/build"
fi
}
function link_xplane_sdk(){
echo "Linking X-Plane SDK headers"
cd "$otsrc/build"
# Link X-Plane SDK headers
mkdir -p xplane_sdk/CHeaders
ln -sf /usr/include/xplane_sdk/Wrappers xplane_sdk/CHeaders/
ln -sf /usr/include/xplane_sdk/Widgets xplane_sdk/CHeaders/
ln -sf /usr/include/xplane_sdk/XPLM xplane_sdk/CHeaders/
}
function build_aruco(){
if [ ! -d "$arucodir" ]; then
mkdir "$arucodir"
git clone https://github.com/opentrack/aruco.git "$arucodir"
else
cd "$arucodir"
git pull
fi
if [ ! -d "$arucodir/build" ]; then
mkdir "$arucodir/build"
else
rm -rf "$arucodir/build"
mkdir "$arucodir/build"
fi
cd "$arucodir/build"
cmake ".."
cmake --build .
make
cd "$otsrc/build"
}
function build_opentrack(){
echo "Building Opentrack"
cd "$otsrc/build"
if [[ $1 == "noaruco" ]]; then
echo "Building without Aruco."
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DSDK_XPLANE="$otsrc/xplane_sdk" \
-DSDK_WINE=ON \
-DCMAKE_INSTALL_PREFIX="$otdir"
## -DPATH_WINE_GPP="/home/bjoern/Downloads/wine-4.0-1-x86_64.pkg" \
ninja
# make -j$(nproc)
fi
if [[ $1 == "aruco" || $1 == "" ]]; then
echo "Building with Aruco."
build_aruco
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DSDK_XPLANE="$otsrc/xplane_sdk" \
-DSDK_ARUCO_LIBPATH="$arucodir/build/src/libaruco.a" \
-DSDK_WINE=ON \
-DCMAKE_INSTALL_PREFIX="$otdir"
ninja
fi
if [ $? -ne '0' ]; then
echo "ERROR: OPENTRACK BUILD FAILED"
exit 1
fi
if [[ $1 == "install" || $2 == "install" ]]; then
ninja install
# make install
fi
}
clean_buildlog
build_folder 2>&1 | tee "$logfile"
link_xplane_sdk 2>&1 | tee "$logfile"
if [[ "$@" == "noaruco" && "$@" == "clean" ]]; then
clean_build
build_opentrack "noaruco" "install" 2>&1 | tee "$logfile"
fi
if [[ "$@" == "noaruco" ]]; then
build_opentrack "noaruco" "install" 2>&1 | tee "$logfile"
fi
if [[ "$@" == "aruco" && "$@" == "clean" ]]; then
clean_build
build_opentrack "aruco" "install" 2>&1 | tee "$logfile"
fi
if [[ "$@" == "aruco" || "$@" == "" ]]; then
clean_build
build_opentrack "aruco" "install" 2>&1 | tee "$logfile"
fi
pause