forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rebuild.sh
executable file
·121 lines (88 loc) · 3.55 KB
/
Rebuild.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
#!/bin/bash
################################################################################
# Updates CARLA content.
################################################################################
set -e
DOC_STRING="Update CARLA content to the latest version, to be run after 'git pull'."
USAGE_STRING="Usage: $0 [-h|--help] [--no-editor]"
# ==============================================================================
# -- Parse arguments -----------------------------------------------------------
# ==============================================================================
LAUNCH_UE4_EDITOR=true
OPTS=`getopt -o h --long help,no-editor -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
eval set -- "$OPTS"
while true; do
case "$1" in
--no-editor )
LAUNCH_UE4_EDITOR=false;
shift ;;
-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
UNREAL_PROJECT_FOLDER=./Unreal/CarlaUE4
UE4_INTERMEDIATE_FOLDERS="Binaries Build Intermediate DerivedDataCache"
function fatal_error {
echo -e "\033[0;31mERROR: $1\033[0m"
exit 1
}
function log {
echo -e "\033[0;33m$1\033[0m"
}
if [ ! -d "${UE4_ROOT}" ]; then
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
else
echo "Using Unreal Engine at '$UE4_ROOT'"
fi
# ==============================================================================
# -- Make CarlaServer ----------------------------------------------------------
# ==============================================================================
log "Making CarlaServer..."
make clean && make debug && make release
# ==============================================================================
# -- Clean up intermediate Unreal files ----------------------------------------
# ==============================================================================
pushd "$UNREAL_PROJECT_FOLDER" >/dev/null
pushd "Plugins/Carla" >/dev/null
log "Cleaning up CARLA Plugin..."
rm -Rf ${UE4_INTERMEDIATE_FOLDERS}
popd > /dev/null
log "Cleaning up CARLAUE4..."
rm -Rf ${UE4_INTERMEDIATE_FOLDERS}
popd >/dev/null
# ==============================================================================
# -- Build and launch Unreal project -------------------------------------------
# ==============================================================================
pushd "$UNREAL_PROJECT_FOLDER" >/dev/null
# This command usually fails but normally we can continue anyway.
set +e
log "Generate Unreal project files..."
${UE4_ROOT}/GenerateProjectFiles.sh -project="${PWD}/CarlaUE4.uproject" -game -engine -makefiles
set -e
log "Build CarlaUE4 project..."
make CarlaUE4Editor
if $LAUNCH_UE4_EDITOR ; then
log "Launching UE4Editor..."
${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject"
else
echo ""
echo "****************"
echo "*** Success! ***"
echo "****************"
fi
popd >/dev/null
# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
popd >/dev/null