This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_compilation.sh
executable file
·74 lines (60 loc) · 2.19 KB
/
run_compilation.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
#!/bin/bash
# TODO select architecture
compile_arch="armv7"
# TODO ask user
build_image=O
ros_version='kinetic'
img_tag="utcoupe-ros-${ros_version}-${compile_arch}"
img_dir="utcoupe-ros-${ros_version}-${compile_arch}"
img_ws_root_dir="/utcoupe/coupe18"
cross_compilation_dir="${UTCOUPE_WORKSPACE}/cross-compilation"
cross_compilation_install_dir="${cross_compilation_dir}/generated_install/${ros_version}/${compile_arch}"
function green_echo() {
echo -e "\033[32m$1\033[0m"
}
function red_echo() {
echo -e "\033[31m$1\033[0m"
}
function build_image() {
green_echo "Started to build $img_tag..."
docker build -t ${img_tag} "${cross_compilation_dir}/${img_dir}"
green_echo "Done."
}
function run_cross_compilation() {
if [[ -z "$(docker images --format='{{print .Tag}}' | grep ${img_tag})" ]]; then
red_echo "docker image ${img_tag} not found locally."
if [[ ${build_image} -eq 0 ]]; then
docker pull "utcoupe/coupe19:${img_tag}"
else
build_image
fi
fi
mkdir -p "${cross_compilation_install_dir}"
# looks slower than the other method
# docker run \
# -i \
# --mount type=bind,source="${UTCOUPE_WOKSPACE}",target="${img_ws_root_dir}" \
# ${img_tag}
green_echo "Generating files in \"${cross_compilation_install_dir}\"..."
docker run \
-i \
--mount type=bind,source="${UTCOUPE_WORKSPACE}"/ros_ws/src,target="${img_ws_root_dir}"/ros_ws/src \
--mount type=bind,source="${UTCOUPE_WORKSPACE}"/libs,target="${img_ws_root_dir}"/libs,readonly \
--mount type=bind,source="${cross_compilation_install_dir}",target="${img_ws_root_dir}"/ros_ws/install \
"utcoupe/coupe19:${img_tag}" \
/bin/bash -c "catkin_make install -DCMAKE_BUILD_TYPE=Release"
# Makes cmake crash
# --tmpfs "${img_ws_root_dir}"/ros_ws/devel
# --tmpfs "${img_ws_root_dir}"/ros_ws/build
green_echo "Done."
}
function create_archive() {
green_echo "Creating archive..."
pushd .
cd "${cross_compilation_install_dir}/../"
tar -czf "${compile_arch}.tgz" "${compile_arch}"
popd
}
run_cross_compilation
create_archive
green_echo "DONE, ENJOY THE CROSS-COMPILED BINARIES!"