-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·125 lines (111 loc) · 4.23 KB
/
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
#!/bin/bash
################################################################################
#
# Copyright (c) The Ultraschall Project (http://ultraschall.fm)
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
################################################################################
source scripts/BuildTools.sh
TOOLS_DIRECTORY=`pwd`/tools
BUILD_DIRECTORY=`pwd`/build
BUILD_CONFIGURATION=Debug
BUILD_DOCUMENTATION=0
BUILD_GENERATOR=Ninja
CMAKE_EXTRA_ARGS=""
if [ "$1" = "--help" ]; then
echo "Usage: build.sh [ --bootstrap | --rebuild | --clean | --cleanall ]"
exit 0
elif [ "$1" = "--bootstrap" ]; then
RemoveDirectory $BUILD_DIRECTORY
RemoveDirectory $TOOLS_DIRECTORY
source ./bootstrap.sh
exit 0
elif [ "$1" = "--cleanall" ]; then
RemoveDirectory $BUILD_DIRECTORY
RemoveDirectory $TOOLS_DIRECTORY
exit 0
elif [ "$1" = "--clean" ]; then
RemoveDirectory $BUILD_DIRECTORY
exit 0
elif [ "$1" = "--docs" ]; then
BUILD_DOCUMENTATION=1
elif [ "$1" == "--rebuild" ]; then
CMAKE_EXTRA_ARGS="--clean-first"
elif [ "$1" == "--release" ]; then
BUILD_CONFIGURATION=Release
fi
CMAKE_INSTALL_DIRECTORY=$TOOLS_DIRECTORY/cmake
CMAKE_INSTALL_FOUND=0
CMAKE_REQUIRED_VERSION="3.12.0"
echo "Looking for CMake $CMAKE_REQUIRED_VERSION. Checking system install..."
if [ $CMAKE_INSTALL_FOUND -eq 0 ]; then
CMAKE_INSTALL_PATH=cmake
if [ -x "$(command -v $CMAKE_INSTALL_PATH)" ]; then
CMAKE_CURRENT_VERSION=`$CMAKE_INSTALL_PATH --version | sort -V | tail -n 1 | awk -v n=3 '{print $n}'`
echo "Found CMake version $CMAKE_CURRENT_VERSION."
CompareVersions $CMAKE_CURRENT_VERSION $CMAKE_REQUIRED_VERSION
if [ ! $? -eq 2 ]; then
CMAKE_INSTALL_FOUND=1
fi
fi
fi
if [ $CMAKE_INSTALL_FOUND -eq 0 ]; then
echo "CMake $CMAKE_REQUIRED_VERSION does not seem to be installed on this system. Checking local install..."
CMAKE_INSTALL_PATH=$CMAKE_INSTALL_DIRECTORY/bin/cmake
if [ -x "$(command -v $CMAKE_INSTALL_PATH)" ]; then
CMAKE_CURRENT_VERSION=`$CMAKE_INSTALL_PATH --version | sort -V | tail -n 1 | awk -v n=3 '{print $n}'`
echo "Found CMake version $CMAKE_CURRENT_VERSION."
CompareVersions $CMAKE_CURRENT_VERSION $CMAKE_REQUIRED_VERSION
if [ ! $? -eq 2 ]; then
CMAKE_INSTALL_FOUND=1
export PATH=$CMAKE_INSTALL_DIRECTORY/bin:$PATH
fi
fi
fi
if [ $CMAKE_INSTALL_FOUND -ne 0 ]; then
echo "Configuring projects using $CMAKE_GENERATOR..."
cmake -B "$BUILD_DIRECTORY" -G "$BUILD_GENERATOR" -Wno-dev --warn-uninitialized --warn-unused-vars -DCMAKE_BUILD_TYPE=$BUILD_CONFIGURATION
if [ $? -ne 0 ]; then
echo "Failed to configure projects."
exit -1
fi
echo "Done."
echo "Building projects using $CMAKE_GENERATOR..."
cmake --build "$BUILD_DIRECTORY" $CMAKE_EXTRA_ARGS --target reaper_ultraschall --config $BUILD_CONFIGURATION -j
if [ $? -ne 0 ]; then
echo "Failed to build projects."
exit -1
fi
echo "Done."
if [ $BUILD_DOCUMENTATION -ne 0 ]; then
echo "Building documentation using doxygen..."
cmake --build "$BUILD_DIRECTORY" --target doxygen
if [ $? -eq 0 ]; then
cd $BUILD_DIRECTORY/docs/latex && make && cp refman.pdf ../../../reaper_ultraschall.pdf && cd -
else
echo "Failed to build documentation."
exit -1
fi
echo "Done."
fi
fi
exit 0