forked from fredpy/trex2-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trex_build_new.bash
182 lines (159 loc) · 5.14 KB
/
trex_build_new.bash
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
#! /bin/bash
# Number of CPU cores.
export CORES="$(grep "processor[^:]:" /proc/cpuinfo | wc -l)"
# Java folder.
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-arm64"
# Make flags.
export MAKEFLAGS="-j$CORES"
# DUNE settings.
export DUNE_GIT='https://github.com/LSTS/dune.git'
export DUNE_BRANCH='master'
export DUNE_SRC="$PWD/src/dune"
export DUNE_HOME="$PWD/dist/dune"
# EUROPA settings, using the new fixed hash_map.hh
export EUROPA_GIT='https://github.com/zepinto/europa.git'
export EUROPA_BRANCH='entice'
export EUROPA_SRC="$PWD/src/europa"
export EUROPA_HOME="$PWD/dist/europa"
export PLASMA_HOME="$EUROPA_SRC"
# TREX settings.
export TREX_GIT='https://github.com/trygvefossum/trex2-agent'
export TREX_BRANCH='Chla'
export TREX_SRC="$PWD/src/trex"
export TREX_HOME="$PWD/dist/trex"
die()
{
echo "ERROR: failed to $1"
exit 1
}
################################################################################
# DUNE #
################################################################################
build_dune()
{
if [ -d "$DUNE_SRC" ]; then
git -C "$DUNE_HOME" clean -xdf
else
git clone "$DUNE_GIT" "$DUNE_SRC" || die 'download DUNE'
git -C "$DUNE_SRC" checkout "$DUNE_BRANCH" || die 'checkout DUNE release'
fi
cd "$DUNE_SRC" &&
mkdir -p build &&
cd build &&
cmake \
-DSHARED=ON \
-DCMAKE_INSTALL_PREFIX="$DUNE_HOME" \
.. &&
make install || die 'build DUNE'
}
################################################################################
# EUROPA 2.6 #
################################################################################
build_europa()
{
if [ -d "$PLASMA_HOME" ]; then
git -C "$PLASMA_HOME" clean -xdf
else
git clone "$EUROPA_GIT" "$EUROPA_SRC" || die 'download EUROPA'
git -C "$EUROPA_SRC" checkout "$EUROPA_BRANCH" || die 'checkout EUROPA release'
fi
cd "$EUROPA_SRC" || die 'change folder to EUROPA root'
# Fixes.
file="$EUROPA_SRC/src/PLASMA/SWIGRules"
grep fpermissive "$file" > /dev/null 2>&1
if [ $? -ne 0 ]; then
sed 's/= -O1/= -O1 -fpermissive/g' "$file" -i
fi
file="$EUROPA_SRC/src/Java/PSEngine/src/psengine/PSUtil.java"
grep 'retval.add(PSResource' "$file" > /dev/null 2>&1
if [ $? -eq 0 ]; then
sed -e '39,40d' "$file" -i
fi
# Build distribution.
ant \
-Djam.args="-dx" \
-Djam.antlr.include="-I$JAVA_HOME/include" \
-Djam.num.cores="$CORES" \
-Djam.variant=OPTIMIZED \
-Djam.libraries=SHARED \
release-dist || die "build EUROPA"
cd "$DUNE_SRC" &&
mkdir -p build &&
cd build &&
cmake \
-DSHARED=ON \
-DCMAKE_INSTALL_PREFIX="$DUNE_HOME" \
.. &&
make install || die 'build DUNE'
}
################################################################################
# EUROPA 2.6 #
################################################################################
build_europa()
{
if [ -d "$PLASMA_HOME" ]; then
git -C "$PLASMA_HOME" clean -xdf
else
git clone "$EUROPA_GIT" "$EUROPA_SRC" || die 'download EUROPA'
git -C "$EUROPA_SRC" checkout "$EUROPA_BRANCH" || die 'checkout EUROPA release'
fi
cd "$EUROPA_SRC" || die 'change folder to EUROPA root'
# Fixes.
file="$EUROPA_SRC/src/PLASMA/SWIGRules"
grep fpermissive "$file" > /dev/null 2>&1
if [ $? -ne 0 ]; then
sed 's/= -O1/= -O1 -fpermissive/g' "$file" -i
fi
file="$EUROPA_SRC/src/Java/PSEngine/src/psengine/PSUtil.java"
grep 'retval.add(PSResource' "$file" > /dev/null 2>&1
if [ $? -eq 0 ]; then
sed -e '39,40d' "$file" -i
fi
# Build distribution.
ant \
-Djam.args="-dx" \
-Djam.antlr.include="-I$JAVA_HOME/include" \
-Djam.num.cores="$CORES" \
-Djam.variant=OPTIMIZED \
-Djam.libraries=SHARED \
release-dist || die "build EUROPA"
mkdir -p $EUROPA_HOME
cd $EUROPA_HOME && unzip "$EUROPA_SRC/dist/europa-"*".zip"
}
################################################################################
# TREX #
################################################################################
build_trex()
{
if [ -d "$TREX_HOME" ]; then
git -C "$TREX_HOME" clean -xdf
else
git clone "$TREX_GIT" "$TREX_SRC" || die 'download TREX'
git -C "$TREX_SRC" checkout "$TREX_BRANCH" || die 'checkout stable branch'
fi
# Fixes.
sed 's%Dune/Dune%DUNE/DUNE%g' "$TREX_SRC/extra/third_party/lsts/CMakeLists.txt" -i
# Build.
cd "$TREX_SRC" || die 'change folder to TREX folder'
mkdir -p build || die 'create build folder'
cd build || die 'change to build folder'
cmake \
-DCMAKE_INSTALL_PREFIX="$TREX_HOME" \
-DEUROPA_HINTS="$EUROPA_HOME" \
-DWITH_EUROPA=ON \
-DWITH_LSTS=ON \
-DWITH_LSTS_ONBOARD=ON \
-DWITH_LSTS_SHORESIDE=ON \
-DWITH_PYTHON=ON \
-DDUNE_HOME="$DUNE_HOME" .. || die "configure TREX"
make install || die "compile TREX"
}
if [ $# -eq 0 ]; then
build_dune
build_europa
build_trex
else
for t in $*; do
build_$t
done
fi