From c6c418ed0cc00d4e50b9e1d0b7c37bd2707a9f32 Mon Sep 17 00:00:00 2001 From: Wouter Heerwegh Date: Tue, 22 Oct 2024 11:03:42 +0200 Subject: [PATCH] Modify `setup.sh` and `build.sh` to work with multiple ubuntu versions. This removes the need for multiple build.sh and setup.sh files. --- AirSim/build.sh | 4 ++ AirSim/docker_build/Dockerfile | 1 + AirSim/docker_build/build.sh | 91 ---------------------------------- AirSim/docker_build/setup.sh | 89 --------------------------------- AirSim/setup.sh | 9 ++-- docs/getting-started.md | 11 ++-- 6 files changed, 15 insertions(+), 190 deletions(-) delete mode 100755 AirSim/docker_build/build.sh delete mode 100755 AirSim/docker_build/setup.sh diff --git a/AirSim/build.sh b/AirSim/build.sh index db4262d6..d9475015 100755 --- a/AirSim/build.sh +++ b/AirSim/build.sh @@ -28,9 +28,13 @@ fi # variable for build output build_dir=build_debug +VERSION=$(lsb_release -rs | cut -d. -f1) if [ "$(uname)" == "Darwin" ]; then export CC=/usr/local/opt/llvm@8/bin/clang export CXX=/usr/local/opt/llvm@8/bin/clang++ +elif [ "$VERSION" -lt "22" ]; then + export CC="clang-8" + export CXX="clang++-8" else export CC="clang-12" export CXX="clang++-12" diff --git a/AirSim/docker_build/Dockerfile b/AirSim/docker_build/Dockerfile index 6017ef14..9fd9c721 100644 --- a/AirSim/docker_build/Dockerfile +++ b/AirSim/docker_build/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ + sudo \ git \ build-essential \ cmake \ diff --git a/AirSim/docker_build/build.sh b/AirSim/docker_build/build.sh deleted file mode 100755 index db3907a5..00000000 --- a/AirSim/docker_build/build.sh +++ /dev/null @@ -1,91 +0,0 @@ -#! /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 diff --git a/AirSim/docker_build/setup.sh b/AirSim/docker_build/setup.sh deleted file mode 100755 index 7f28bfa0..00000000 --- a/AirSim/docker_build/setup.sh +++ /dev/null @@ -1,89 +0,0 @@ -#! /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 "************************************" diff --git a/AirSim/setup.sh b/AirSim/setup.sh index c3cff80a..60068ca7 100755 --- a/AirSim/setup.sh +++ b/AirSim/setup.sh @@ -27,11 +27,12 @@ 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 - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 12 + sudo apt-get install -y clang-8 clang++-8 libc++-8-dev libc++abi-8-dev +elif [ "$VERSION" -lt "22" ]; then + sudo apt-get install -y clang-8 libc++-8-dev libc++abi-8-dev +else + sudo apt-get install -y clang-12 clang++-12 libc++-12-dev libc++abi-12-dev fi -sudo apt-get install -y clang-12 clang++-12 libc++-12-dev libc++abi-12-dev #install additional tools sudo apt-get install -y build-essential diff --git a/docs/getting-started.md b/docs/getting-started.md index 41a2be11..0fe4dc2c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -56,7 +56,7 @@ This guide outlines the steps for building the project from source on Ubuntu 20. #### Build AirSim ##### For Ubuntu 20.04 - cd /home/YOUR_USER/Formula-Student-Driverless-Simulator/AirSsim + cd /home/$USER/Formula-Student-Driverless-Simulator/AirSim cp ./docker_build/setup.sh . cp ./docker_build/build.sh . ./setup.sh && ./build.sh @@ -66,7 +66,7 @@ First, install Docker on your Ubuntu system. Change to the Docker Build Directory: Note that this directory is within the AirSim folder, not the root of the Formula-Student-Driverless-Simulator repository. - cd /home/YOUR_USER/Formula-Student-Driverless-Simulator/AirSim/docker_build + cd /home/$USER/Formula-Student-Driverless-Simulator/AirSim/docker_build 1. Build the Docker Image: @@ -74,8 +74,7 @@ Change to the Docker Build Directory: Note that this directory is within the Air 2. Run the Docker Container: After the build completes, mount your local folder into the container: - - docker run --rm -it -v /home/YOUR_USER/Formula-Student-Driverless-Simulator:/home/airsim/Formula-Student-Driverless-Simulator formula-simulator + docker run --rm -it -v $PWD/../..:/home/airsim/Formula-Student-Driverless-Simulator formula-simulator 3. Inside the Container: Copy the modified setup.sh and build.sh scripts: @@ -91,11 +90,11 @@ Change to the Docker Build Directory: Note that this directory is within the Air 6. Build the final project, use the following command (this process may take some time): - ~/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Linux/bin/mono ~/UnrealEngine/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Linux -Project=/home/YOUR_USER/Formula-Student-Driverless-Simulator/UE4Project/FSOnline.uproject -TargetType=Editor -Progress + ~/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Linux/bin/mono ~/UnrealEngine/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Linux -Project=/home/$uSER/Formula-Student-Driverless-Simulator/UE4Project/FSOnline.uproject -TargetType=Editor -Progress Congratulations! You have successfully built the project from source. You can now open and edit the project by running: - ./home/YOUR_USERNAME/Formula-Student-Driverless-Simulator/UE4Project/FSOnline.uproject + ./home/$USER/Formula-Student-Driverless-Simulator/UE4Project/FSOnline.uproject ### Building from source using the Unreal Engine Editor for earlier versions of Ubuntu (e.g., Ubuntu 18.04) Instead of running the simulator from release binaries, you can compile it manually using unreal engine.