/
build.sh
executable file
·225 lines (198 loc) · 6.87 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
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
#!/usr/bin/env bash
set -euxo pipefail
readonly this_dir=`cd $(dirname $0); pwd`
readonly artifacts_dir=$this_dir/artifacts
readonly build_dir=$this_dir/build
readonly src_dir=$this_dir/src
mkdir -p $artifacts_dir
mkdir -p $build_dir
mkdir -p $src_dir
# Install pre-requisites packages
sudo apt-get install -y build-essential
echo "::group::Install CMake"
if [ ! -f $this_dir/cmake/bin/cmake ]
then
cd $this_dir
wget --quiet https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Linux-x86_64.tar.gz
tar xzf cmake-3.18.4-Linux-x86_64.tar.gz
rm -f cmake-3.18.4-Linux-x86_64.tar.gz
mv cmake-3.18.4-Linux-x86_64 cmake
fi
export CMAKE=$this_dir/cmake/bin/cmake
if [ ! -f $CMAKE ]
then
echo "CMake installation went wrong" && false
fi
$CMAKE --version
echo "::endgroup::"
echo "::group::Install emscripten"
if [ ! -d $this_dir/emsdk ]
then
cd $this_dir
git clone https://github.com/emscripten-core/emsdk.git
fi
if [ ! -f $this_dir/emsdk/upstream/emscripten/emcc ]
then
cd $this_dir/emsdk
./emsdk install latest
./emsdk activate latest
fi
source $this_dir/emsdk/emsdk_env.sh
export EM_PREFIX=$EMSDK/upstream/emscripten/system
echo "::endgroup::"
export FORCE_JRL_CMAKEMODULES_UPDATE=false
# Helper function to build a CMake project
build_cmake_project()
{
name=$1
src=$2
# FIXME Work around for project that use jrl-cmakemodules but don't have jrl-cmakemodules#459
if $FORCE_JRL_CMAKEMODULES_UPDATE && [ -d $src/cmake ]
then
cd $src/cmake
git pull origin master
fi
# FIXME Patch for Tasks
if [ $name == "Tasks" ]
then
cd $src
sed -i -e's/add_definitions(-mfpmath=sse -msse2)//' CMakeLists.txt
fi
mkdir -p $build_dir/$name
cd $build_dir/$name
emcmake $CMAKE $src -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${EM_PREFIX} ${CMAKE_OPTIONS}
emmake make -j$(nproc)
emmake make install
}
# Helper to build from git
build_git()
{
echo "::group::Install $1"
name=$1
uri=$2
branch=$3
if [ ! -d $src_dir/$name ]
then
cd $src_dir
git clone --recursive $uri $src_dir/$name
cd $src_dir/$name
git checkout origin/$branch -B $branch || git checkout $branch -B $branch
else
cd $src_dir/$name
git pull origin $branch
fi
git submodule sync --recursive && git submodule update --init --recursive
build_cmake_project $name $src_dir/$name
echo "::endgroup::"
}
# Helper to build from a GitHub project
build_github()
{
build_git `basename $1` https://github.com/$1 $2
}
# Helper to build from a tarball
build_release()
{
echo "::group::Install $1"
name=$1
folder=$2
uri=$3
if [ ! -d $src_dir/$folder ]
then
cd $src_dir
wget --quiet $uri -O - | tar -xz
fi
build_cmake_project $name $src_dir/$folder
echo "::endgroup::"
}
echo "::group::Install Boost 1.74.0"
if [ ! -d $src_dir/boost_1_74_0 ]
then
cd $src_dir
wget --quiet https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.bz2
tar xjf boost_1_74_0.tar.bz2
rm -f boost_1_74_0.tar.bz2
fi
cd $src_dir/boost_1_74_0
if [ ! -f ./b2 ]
then
./bootstrap.sh || (cat bootstrap.log && false)
fi
# Options
export CMAKE_BUILD_TYPE=Release
export CXXFLAGS="-matomics -s USE_PTHREADS=1 -s DISABLE_EXCEPTION_CATCHING=0"
export LDFLAGS="-s USE_PTHREADS=1 -s DISABLE_EXCEPTION_CATCHING=0"
# Copy our patched jam configuration
cp $this_dir/emscripten.jam tools/build/src/tools/
emconfigure ./b2 toolset=emscripten --with-filesystem --with-timer --with-program_options --with-system --with-serialization --prefix=$EM_PREFIX variant=release link=static install
echo "::endgroup::"
# Build f2c
echo "::group::Install libf2c"
if [ ! -d $src_dir/libf2c-emscripten ]
then
cd $src_dir
git clone https://github.com/gergondet/libf2c-emscripten.git libf2c-emscripten
fi
cd $src_dir/libf2c-emscripten
emmake make -j$(nproc)
emmake make install
echo "::endgroup::"
# Build other dependencies
export CMAKE_OPTIONS="-DBUILD_TESTING=OFF"
build_release eigen eigen-git-mirror-3.3.7 https://github.com/eigenteam/eigen-git-mirror/archive/3.3.7.tar.gz
build_release tinyxml2 tinyxml2-7.1.0 https://github.com/leethomason/tinyxml2/archive/7.1.0.tar.gz
export CMAKE_OPTIONS="-DBUILD_SHARED_LIBS=OFF -DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF -DASSIMP_BUILD_COLLADA_IMPORTER=ON -DASSIMP_BUILD_STL_IMPORTER=ON -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_BUILD_TESTS=OFF"
build_release assimp assimp-5.0.1 https://github.com/assimp/assimp/archive/v5.0.1.tar.gz
export CMAKE_OPTIONS="-DBUILD_TESTING=OFF -DBUILD_DOCUMENTATION=OFF -DBUILD_SHARED_LIBS=OFF -DDISABLE_GEOS_INLINE=ON"
build_github libgeos/geos master
export CMAKE_OPTIONS="-DYAML_CPP_BUILD_TESTS=OFF"
build_release yaml-cpp yaml-cpp-yaml-cpp-0.6.3 https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.3.tar.gz
export CMAKE_OPTIONS="-DSPDLOG_BUILD_TESTS=OFF -DSPDLOG_BUILD_SHARED=OFF"
build_release spdlog spdlog-1.6.1 https://github.com/gabime/spdlog/archive/v1.6.1.tar.gz
export CMAKE_OPTIONS="-DBUILD_TESTING=OFF -DBUILD_PYTHON_INTERFACE=OFF -DINSTALL_DOCUMENTATION=OFF"
build_github humanoid-path-planner/hpp-spline v4.7.0
export FORCE_JRL_CMAKEMODULES_UPDATE=true
export CMAKE_OPTIONS="-DBUILD_TESTING=OFF -DPYTHON_BINDING=OFF -DUSE_F2C=ON -DINSTALL_DOCUMENTATION=OFF"
build_github jrl-umi3218/SpaceVecAlg master
build_github jrl-umi3218/sch-core master
build_github jrl-umi3218/eigen-qld master
build_github jrl-umi3218/RBDyn master
build_github jrl-umi3218/Tasks master
build_github jrl-umi3218/mc_rbdyn_urdf master
build_github jrl-umi3218/mc_rtc_data master
build_github jrl-umi3218/eigen-quadprog master
build_github jrl-umi3218/copra master
export CMAKE_OPTIONS="${CMAKE_OPTIONS} -DDISABLE_ROS=ON -DMC_RTC_BUILD_STATIC=ON -DMC_RTC_DISABLE_NETWORK=ON -DJVRC_DESCRIPTION_PATH=/assets/jvrc_description -DMC_ENV_DESCRIPTION_PATH=/assets/mc_env_description -DMC_INT_OBJ_DESCRIPTION_PATH=/assets/mc_int_obj_description -DMC_PANDA_WITH_FRANKA=OFF -DMC_PANDA_DISABLE_XACRO=ON -DPANDA_DESCRIPTION_PATH=/assets/mc_panda"
if [ ! -d $src_dir/mc_rtc ]
then
git clone --recursive -b topic/wasm https://github.com/gergondet/mc_rtc $src_dir/mc_rtc
else
cd $src_dir/mc_rtc
git pull origin topic/wasm
fi
cd $src_dir/mc_rtc/controllers/
if [ ! -d lipm_walking_controller ]
then
git clone --recursive -b topic/wasm https://github.com/gergondet/lipm_walking_controller
else
cd lipm_walking_controller
git pull origin topic/wasm
fi
cd $src_dir/mc_rtc/robots/
if [ ! -d mc_panda ]
then
git clone --recursive -b topic/NoFrankaOption https://github.com/gergondet/mc_panda
else
cd mc_panda
git pull origin topic/NoFrankaOption
fi
cd $this_dir
build_github gergondet/mc_rtc topic/wasm
# CMake does not generate proper dependencies for index.html so we force relinking
if [ -f $build_dir/mc_rtc-raylib/index.html ]
then
rm -f $build_dir/mc_rtc-raylib/index.*
fi
build_github gergondet/mc_rtc-raylib master
cp $build_dir/mc_rtc-raylib/index.* $artifacts_dir/
cp -r $build_dir/mc_rtc-raylib/img/ $artifacts_dir