Skip to content

Commit

Permalink
adding the dockerfile and the modified build.sh and setup.sh for ubun…
Browse files Browse the repository at this point in the history
…tu 20.04,22.04+ installation guide inside a docker_build dir
  • Loading branch information
RoyAmoyal committed Oct 21, 2024
1 parent 08042ad commit 44d6c1a
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 0 deletions.
50 changes: 50 additions & 0 deletions AirSim/docker_build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
git \
build-essential \
cmake \
libboost-all-dev \
libasio-dev \
libtinyxml2-dev \
libcurl4-openssl-dev \
libglfw3-dev \
libglew-dev \
libpng-dev \
libjpeg-dev \
libopencv-dev \
libtiff-dev \
python3 \
python3-pip \
python3-dev \
unzip \
wget \
lsb-release \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \
clang-8 \
lld-8 \
llvm-8 \
llvm-8-dev \
llvm-8-tools

RUN apt-get update && apt-get install -y \
g++ \
libc++-dev \
libc++abi-dev

RUN apt-get update && apt-get install -y \
wget \
software-properties-common \
gnupg \
rsync \
&& apt-get clean

WORKDIR /home/airsim/Formula-Student-Driverless-Simulator/AirSim

ENTRYPOINT ["/bin/bash"]

91 changes: 91 additions & 0 deletions AirSim/docker_build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#! /bin/bash

# get path of current script: https://stackoverflow.com/a/39340259/207661
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null

set -e
set -x

function version_less_than_equal_to() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$1"; }

# check for rpclib
if [ ! -d "./external/rpclib/include" ]; then
echo "ERROR: rpclib missing. Please run initialize git submodules."
exit 1
fi

# check for local cmake build created by setup.sh
if [ -d "./cmake_build" ]; then
if [ "$(uname)" == "Darwin" ]; then
CMAKE="$(greadlink -f cmake_build/bin/cmake)"
else
CMAKE="$(readlink -f cmake_build/bin/cmake)"
fi
else
CMAKE=$(which cmake)
fi

# variable for build output
build_dir=build_debug
if [ "$(uname)" == "Darwin" ]; then
export CC=/usr/local/opt/llvm@8/bin/clang
export CXX=/usr/local/opt/llvm@8/bin/clang++
else
export CC="clang-8"
export CXX="clang++-8"
fi

#install EIGEN library
if [[ !(-d "./AirLib/deps/eigen3/Eigen") ]]; then
echo "### Eigen is not installed. Please run setup.sh first."
exit 1
fi

echo "putting build in $build_dir folder, to clean, just delete the directory..."

# this ensures the cmake files will be built in our $build_dir instead.
if [[ -f "./cmake/CMakeCache.txt" ]]; then
rm "./cmake/CMakeCache.txt"
fi
if [[ -d "./cmake/CMakeFiles" ]]; then
rm -rf "./cmake/CMakeFiles"
fi

if [[ ! -d $build_dir ]]; then
mkdir -p $build_dir
pushd $build_dir >/dev/null

"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Debug \
|| (popd && rm -r $build_dir && exit 1)
popd >/dev/null
fi

pushd $build_dir >/dev/null
# final linking of the binaries can fail due to a missing libc++abi library
# (happens on Fedora, see https://bugzilla.redhat.com/show_bug.cgi?id=1332306).
# So we only build the libraries here for now
make -j`nproc`
popd >/dev/null

mkdir -p AirLib/lib/x64/Debug
mkdir -p AirLib/deps/rpclib/lib
cp $build_dir/output/lib/libAirLib.a AirLib/lib
cp $build_dir/output/lib/librpc.a AirLib/deps/rpclib/lib/librpc.a

# Update AirLib/lib, AirLib/deps, Plugins folders with new binaries
rsync -a --delete $build_dir/output/lib/ AirLib/lib/x64/Debug
rsync -a --delete external/rpclib/include AirLib/deps/rpclib

../UE4Project/clean.sh
rsync -a --delete AirLib ../UE4Project/Plugins/AirSim/Source

set +x

echo ""
echo ""
echo "=================================================================="
echo " AirSim libraries are built and installed."
echo "=================================================================="

popd >/dev/null
89 changes: 89 additions & 0 deletions AirSim/docker_build/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#! /bin/bash
set -x
set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null

downloadHighPolySuv=true
MIN_CMAKE_VERSION=3.10.0
function version_less_than_equal_to() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$1"; }

# Parse command line arguments
while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--no-full-poly-car)
downloadHighPolySuv=false
shift # past value
;;
esac
done

#install clang and build tools
VERSION=$(lsb_release -rs | cut -d. -f1)
# Since Ubuntu 17 clang is part of the core repository
# See https://packages.ubuntu.com/search?keywords=clang-8
if [ "$VERSION" -lt "20" ]; then
#sudo apt install wget lsb-release software-properties-common
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 8
# instead 12
fi
#sudo apt-get install -y clang-12 clang++-12 libc++-12-dev libc++abi-12-dev
apt-get install -y clang-8 clang++-8 libc++-8-dev libc++abi-8-dev

#install additional tools
apt-get install -y build-essential
apt-get install -y unzip

if ! which cmake; then
# CMake not installed
cmake_ver=0
else
cmake_ver=$(cmake --version 2>&1 | head -n1 | cut -d ' ' -f3 | awk '{print $NF}')
fi

#download cmake - v3.10.2 is not out of box in Ubuntu 16.04
if version_less_than_equal_to $cmake_ver $MIN_CMAKE_VERSION; then
if [[ ! -d "cmake_build/bin" ]]; then
echo "Downloading cmake..."
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz \
-O cmake.tar.gz
tar -xzf cmake.tar.gz
rm cmake.tar.gz
rm -rf ./cmake_build
mv ./cmake-3.10.2 ./cmake_build
pushd cmake_build
./bootstrap
make
popd
fi
else
echo "Already have good version of cmake: $cmake_ver"
fi

echo "Installing Eigen library..."

if [ ! -d "AirLib/deps/eigen3" ]; then
echo "Downloading Eigen..."
wget -O eigen3.zip https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip
unzip eigen3.zip -d temp_eigen
mkdir -p AirLib/deps/eigen3
mv temp_eigen/eigen*/Eigen AirLib/deps/eigen3
rm -rf temp_eigen
rm eigen3.zip
else
echo "Eigen is already installed."
fi

popd >/dev/null

set +x
echo ""
echo "************************************"
echo "AirSim setup completed successfully!"
echo "************************************"

0 comments on commit 44d6c1a

Please sign in to comment.