forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.sh
executable file
·227 lines (176 loc) · 7.5 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#! /bin/bash
################################################################################
# CARLA Setup.sh
#
# This script sets up the environment and dependencies for compiling CARLA on
# Linux.
#
# 1) Download CARLA Content if necessary.
# 2) Download and compile libc++.
# 3) Download other third-party libraries and compile them with libc++.
#
# Thanks to the people at https://github.com/Microsoft/AirSim for providing the
# important parts of this script.
################################################################################
set -e
DOC_STRING="Download and compile CARLA content and dependencies."
USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download] [--jobs=N]"
# ==============================================================================
# -- Parse arguments -----------------------------------------------------------
# ==============================================================================
UPDATE_SCRIPT_FLAGS=
NUMBER_OF_ASYNC_JOBS=1
OPTS=`getopt -o hs --long help,skip-download,jobs:: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
eval set -- "$OPTS"
while true; do
case "$1" in
-s | --skip-download )
UPDATE_SCRIPT_FLAGS=--skip-download;
shift ;;
--jobs)
case "$2" in
"") NUMBER_OF_ASYNC_JOBS=4 ; shift 2 ;;
*) NUMBER_OF_ASYNC_JOBS=$2 ; shift 2 ;;
esac ;;
-h | --help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
# ==============================================================================
# -- Set up environment --------------------------------------------------------
# ==============================================================================
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null
# Require clang 3.9
command -v clang++-3.9 >/dev/null 2>&1 || {
echo >&2 "clang 3.9 is required, but it's not installed.";
echo >&2 "make sure you build Unreal Engine with clang 3.9 too.";
exit 1;
}
mkdir -p Util/Build
pushd Util/Build >/dev/null
# ==============================================================================
# -- Get and compile libc++ ----------------------------------------------------
# ==============================================================================
# Get libc++ source
if [[ ! -d "llvm-source" ]]; then
echo "Retrieving libc++..."
git clone --depth=1 -b release_39 https://github.com/llvm-mirror/llvm.git llvm-source
git clone --depth=1 -b release_39 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx
git clone --depth=1 -b release_39 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi
else
echo "Folder llvm-source already exists, skipping git clone..."
fi
# Build libc++
rm -rf llvm-build
mkdir -p llvm-build
pushd llvm-build >/dev/null
export C_COMPILER=clang-3.9
export COMPILER=clang++-3.9
cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="../llvm-install" \
../llvm-source
make -j $NUMBER_OF_ASYNC_JOBS cxx
#install libc++ locally in llvm-install folder
make -j $NUMBER_OF_ASYNC_JOBS install-libcxx install-libcxxabi
popd >/dev/null
# ==============================================================================
# -- Get Boost and compile it with libc++ --------------------------------------
# ==============================================================================
# Get boost source
if [[ ! -d "boost-source" ]]; then
echo "Retrieving boost..."
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar -xvzf boost_1_64_0.tar.gz
rm boost_1_64_0.tar.gz
mv boost_1_64_0 boost-source
else
echo "Folder boost-source already exists, skipping download..."
fi
pushd boost-source >/dev/null
BOOST_TOOLSET="clang-3.9"
BOOST_CFLAGS="-fPIC -std=c++1y -stdlib=libc++ -I../llvm-install/include/c++/v1"
BOOST_LFLAGS="-stdlib=libc++ -L../llvm-install/lib"
./bootstrap.sh \
--with-toolset=clang \
--prefix=../boost-install \
--with-libraries=system
./b2 clean
./b2 toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS stage release
./b2 install toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS
popd >/dev/null
# ==============================================================================
# -- Get Protobuf and compile it with libc++ -----------------------------------
# ==============================================================================
# Get protobuf source
if [[ ! -d "protobuf-source" ]]; then
echo "Retrieving protobuf..."
git clone --depth=1 -b v3.3.0 --recurse-submodules https://github.com/google/protobuf.git protobuf-source
else
echo "Folder protobuf-source already exists, skipping git clone..."
fi
pushd protobuf-source >/dev/null
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/../llvm-install/lib/"
./autogen.sh
./configure \
CC="clang-3.9" \
CXX="clang++-3.9" \
CXXFLAGS="-fPIC -stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1" \
LDFLAGS="-stdlib=libc++ -L$PWD/../llvm-install/lib/" \
--prefix="$PWD/../protobuf-install" \
--disable-shared
make -j $NUMBER_OF_ASYNC_JOBS
make -j $NUMBER_OF_ASYNC_JOBS install
popd >/dev/null
# ==============================================================================
# -- Get GTest and compile it with libc++ --------------------------------------
# ==============================================================================
# Get googletest source
if [[ ! -d "googletest-source" ]]; then
echo "Retrieving googletest..."
git clone --depth=1 -b release-1.8.0 https://github.com/google/googletest.git googletest-source
else
echo "Folder googletest-source already exists, skipping git clone..."
fi
pushd googletest-source >/dev/null
cmake -H. -B./build \
-DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1 -Wl,-L$PWD/../llvm-install/lib" \
-DCMAKE_INSTALL_PREFIX="../googletest-install" \
-G "Ninja"
pushd build >/dev/null
ninja
ninja install
popd >/dev/null
popd >/dev/null
# ==============================================================================
# -- Other CARLA files ---------------------------------------------------------
# ==============================================================================
popd >/dev/null
CARLA_SETTINGS_FILE="./Unreal/CarlaUE4/Config/CarlaSettings.ini"
if [[ ! -f $CARLA_SETTINGS_FILE ]]; then
echo "Copying CarlaSettings.ini..."
sed -e 's/UseNetworking=true/UseNetworking=false/' ./Docs/Example.CarlaSettings.ini > $CARLA_SETTINGS_FILE
fi
./Util/Protoc.sh
# ==============================================================================
# -- Update CARLA Content ------------------------------------------------------
# ==============================================================================
echo
./Update.sh $UPDATE_SCRIPT_FLAGS
# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
popd >/dev/null
set +x
echo ""
echo "****************"
echo "*** Success! ***"
echo "****************"