-
Notifications
You must be signed in to change notification settings - Fork 46
/
install_hailo_gstreamer.sh
executable file
·114 lines (99 loc) · 3.97 KB
/
install_hailo_gstreamer.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
#!/bin/bash
set -e
script_dir=$(dirname $(realpath "$0"))
source $script_dir/../misc/checks_before_run.sh --export-only
BUILD_DIR="$TAPPAS_WORKSPACE/core/hailo"
BUILD_MODE=release
SKIP_HAILORT=false
COMPILE_LIBGSTHAILO=false
INCLUDE_UNIT_TESTS=true
PYTHON_VERSION=$(python3 --version | awk '{print $2}' | awk -F'.' '{print $1"."$2}')
TARGET="all"
TARGET_PLATFORM="x86"
INSTALLATION_DIR=/opt/hailo/tappas
# Occupy all the cores could sometimes freeze the PC
num_cores_to_use=$(($(nproc)/2))
function print_usage() {
echo "Install Hailo GStreamer:"
echo ""
echo "Options:"
echo " --help Show this help"
echo " --build-dir Path to the GStreamer build dir"
echo " --build-mode Build mode, debug/release, default is $BUILD_MODE"
echo " --skip-hailort Skip compiling HailoRT"
echo " --python-version Python version"
echo " --compile-libgsthailo Compile libgsthailo instead of copying it from the release"
echo " --skip-unit-tests Skip compilation of unit tests"
echo " --target Tappas build target [all, plugins, libs, apps] (default = all)"
echo " --target-platform Target platform, used for installing only required media and hef files [x86, arm, hailo15] (Default is $TARGET_PLATFORM)"
echo " --compile-num-of-cores Number of cpu cores to compile with (more cores makes the compilation process faster, but may cause 'out of swap memory' issue on weak machines)"
exit 1
}
function parse_args() {
while test $# -gt 0; do
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
print_usage
elif [ "$1" == "--build-dir" ]; then
BUILD_DIR=$2
shift
elif [ "$1" == "--build-mode" ]; then
BUILD_MODE=$2
shift
elif [ "$1" == "--python-version" ]; then
PYTHON_VERSION=$2
shift
elif [ "$1" == "--target" ]; then
TARGET=$2
shift
elif [ "$1" == "--target-platform" ]; then
TARGET_PLATFORM=$2
shift
elif [ "$1" == "--skip-hailort" ]; then
SKIP_HAILORT=true
elif [ "$1" == "--skip-unit-tests" ]; then
INCLUDE_UNIT_TESTS=false
elif [ "$1" == "--compile-num-of-cores" ]; then
num_cores_to_use=$2
shift
elif [ "$1" == "--compile-libgsthailo" ]; then
COMPILE_LIBGSTHAILO=true
else
echo "Unknown parameters, exiting"
print_usage
fi
shift
done
}
function handle_libgsthailo() {
# Compile from sources if the user selects to or the .deb has not placed it already there
if [ "$COMPILE_LIBGSTHAILO" = true ] || [ ! -f /usr/lib/$(uname -m)-linux-gnu/gstreamer-1.0/libgsthailo.so ]; then
${TAPPAS_WORKSPACE}/scripts/gstreamer/compile_libgsthailo.sh --build-type $BUILD_MODE
fi
}
function main() {
if [ "$SKIP_HAILORT" = false ]; then
handle_libgsthailo
fi
# Handle the build of gsthailotools
pushd "$BUILD_DIR"
reconfigure_flag=
if [ -d "./build.$BUILD_MODE" ]
then
reconfigure_flag=--reconfigure
fi
echo "Compiling Hailo Gstreamer target $TARGET, with $num_cores_to_use cpu cores, build type $BUILD_MODE $reconfigure_flag"
CC=gcc-9 CXX=g++-9 meson build.$BUILD_MODE $reconfigure_flag --prefix "${INSTALLATION_DIR}" --buildtype $BUILD_MODE \
-Dtarget=$TARGET \
-Dtarget_platform=$TARGET_PLATFORM \
-Dlibargs="-I/usr/include/hailo/,-I/usr/include/gstreamer-1.0/gst/hailo/" \
-Dinclude_python=true -Dpython_version=$PYTHON_VERSION
if [[ -f "build.$BUILD_MODE/.ninja_log" ]]; then
# Solve permission bug
chown $(id -u):$(id -g) build.$BUILD_MODE/.ninja_log
fi
ninja -j $num_cores_to_use -C build.$BUILD_MODE
sudo env "PATH=$PATH" ninja install -C build.$BUILD_MODE
popd
}
parse_args "$@"
main