2024-03-21 16:07:22 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
# -- FUNCTIONS -------------------------------------------------------------------------------------
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
satisfies_minimum_version() {
|
|
|
|
CMAKE_VERSION="$(cmake --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"
|
|
|
|
CMAKE_MINIMUM_VERSION=$1
|
|
|
|
MAJOR="${CMAKE_VERSION%%.*}"
|
|
|
|
REMAINDER="${CMAKE_VERSION#*.}"
|
|
|
|
MINOR="${REMAINDER%.*}"
|
|
|
|
REVISION="${REMAINDER#*.}"
|
|
|
|
MINIMUM_MAJOR="${CMAKE_MINIMUM_VERSION%%.*}"
|
|
|
|
MINIMUM_REMAINDER="${CMAKE_MINIMUM_VERSION#*.}"
|
|
|
|
MINIMUM_MINOR="${MINIMUM_REMAINDER%.*}"
|
|
|
|
|
|
|
|
if [ $MAJOR -gt $MINIMUM_MAJOR ] ||
|
|
|
|
( [ $MAJOR -eq $MINIMUM_MAJOR ] &&
|
|
|
|
( [ $MINOR -gt $MINIMUM_MINOR ] || [ $MINOR -eq $MINIMUM_MINOR ])) ; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
# -- MAIN ------------------------------------------------------------------------------------------
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
|
|
set -e
|
|
|
|
sudo echo "Got super powers..."
|
|
|
|
|
2024-07-23 14:34:24 +08:00
|
|
|
echo "Parsing GIT_LOCAL_CREDENTIALS local variable "
|
|
|
|
arrIN=(${GIT_LOCAL_CREDENTIALS//@/ })
|
|
|
|
GIT_LOCAL_USER=${arrIN[0]}
|
|
|
|
GIT_LOCAL_TOKEN=${arrIN[1]}
|
|
|
|
if [ -z "$GIT_LOCAL_CREDENTIALS" ]
|
|
|
|
then
|
|
|
|
echo "Git credentials are not set, they will be requested later on during the download of Unreal Engine Carla fork"
|
|
|
|
fi
|
|
|
|
|
2024-07-31 20:36:14 +08:00
|
|
|
echo "Installing Ubuntu Packages..."
|
2024-03-21 16:07:22 +08:00
|
|
|
if ! command -v retry &> /dev/null
|
|
|
|
then
|
|
|
|
sudo apt update
|
|
|
|
sudo apt-get install retry
|
|
|
|
fi
|
|
|
|
retry --until=success --times=12 --delay=300 -- sudo apt-get update
|
2024-05-23 15:42:12 +08:00
|
|
|
retry --until=success --times=12 --delay=300 -- sudo apt-get -y install \
|
|
|
|
build-essential \
|
|
|
|
g++-12 \
|
|
|
|
gcc-12 \
|
|
|
|
make \
|
|
|
|
ninja-build \
|
|
|
|
libvulkan1 \
|
|
|
|
python3 \
|
|
|
|
python3-dev \
|
|
|
|
python3-pip \
|
|
|
|
libpng-dev \
|
|
|
|
libtiff5-dev \
|
|
|
|
libjpeg-dev \
|
|
|
|
tzdata \
|
|
|
|
sed \
|
|
|
|
curl \
|
|
|
|
libtool \
|
|
|
|
rsync \
|
|
|
|
libxml2-dev \
|
|
|
|
git \
|
|
|
|
git-lfs
|
2024-07-31 20:36:14 +08:00
|
|
|
echo "Ubuntu Packages Installed..."
|
2024-03-21 16:07:22 +08:00
|
|
|
|
2024-07-31 20:36:14 +08:00
|
|
|
echo "Installing Python Packages..."
|
2024-04-16 21:54:28 +08:00
|
|
|
pip3 install --upgrade pip
|
2024-04-16 16:07:34 +08:00
|
|
|
pip3 install -r requirements.txt
|
2024-07-31 20:36:14 +08:00
|
|
|
echo "Python Packages Installed..."
|
2024-03-21 16:07:22 +08:00
|
|
|
|
|
|
|
echo "Clonning CARLA Content asynchronously... (see the progres in ContentClone.log)"
|
|
|
|
mkdir -p Unreal/CarlaUnreal/Content
|
|
|
|
git -C Unreal/CarlaUnreal/Content clone -b ue5-dev https://bitbucket.org/carla-simulator/carla-content.git Carla &> ContentClone.log&
|
|
|
|
|
|
|
|
CMAKE_MINIMUM_VERSION=3.28.0
|
|
|
|
if satisfies_minimum_version $CMAKE_MINIMUM_VERSION; then
|
|
|
|
echo "Found CMake $CMAKE_VERSION - OK"
|
|
|
|
else
|
|
|
|
echo "Found CMake $CMAKE_VERSION - FAIL"
|
|
|
|
echo "Installing CMake 3.28.3..."
|
|
|
|
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.tar.gz
|
|
|
|
sudo mkdir -p /opt
|
|
|
|
sudo tar -xzf cmake-3.28.3-linux-x86_64.tar.gz -C /opt
|
2024-04-09 15:49:18 +08:00
|
|
|
echo -e '\n#CARLA CMake 3.28.3\nPATH=/opt/cmake-3.28.3-linux-x86_64/bin:$PATH' >> ~/.bashrc
|
2024-03-21 16:07:22 +08:00
|
|
|
export PATH=/opt/cmake-3.28.3-linux-x86_64/bin:$PATH
|
|
|
|
rm -rf cmake-3.28.3-linux-x86_64.tar.gz
|
|
|
|
echo "CMake Intalled 3.28.3..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z $CARLA_UNREAL_ENGINE_PATH ] && [ -d $CARLA_UNREAL_ENGINE_PATH ]; then
|
|
|
|
echo "Found UnrealEngine5 $CARLA_UNREAL_ENGINE_PATH - OK"
|
|
|
|
elif [ -d ../UnrealEngine5_carla ]; then
|
2024-04-24 21:30:28 +08:00
|
|
|
pushd ..
|
|
|
|
pushd UnrealEngine5_carla
|
2024-03-21 16:07:22 +08:00
|
|
|
echo "Found UnrealEngine5 ../UnrealEngine5_carla - OK"
|
2024-04-24 21:30:28 +08:00
|
|
|
export CARLA_UNREAL_ENGINE_PATH=$PWD
|
2024-04-09 15:49:18 +08:00
|
|
|
echo -e '\n#CARLA UnrealEngine5\nexport CARLA_UNREAL_ENGINE_PATH='$CARLA_UNREAL_ENGINE_PATH >> ~/.bashrc
|
2024-04-24 21:30:28 +08:00
|
|
|
popd
|
|
|
|
popd
|
2024-03-21 16:07:22 +08:00
|
|
|
else
|
|
|
|
echo "Found UnrealEngine5 $CARLA_UNREAL_ENGINE_PATH - FAIL"
|
|
|
|
echo "Cloning CARLA UnrealEngine5..."
|
|
|
|
pushd ..
|
2024-07-23 14:34:24 +08:00
|
|
|
if [ -z "$GIT_LOCAL_CREDENTIALS" ]
|
|
|
|
then
|
|
|
|
git clone -b ue5-dev-carla https://github.com/CarlaUnreal/UnrealEngine.git UnrealEngine5_carla
|
|
|
|
else
|
|
|
|
git clone -b ue5-dev-carla https://$GIT_LOCAL_USER:$GIT_LOCAL_TOKEN@github.com/CarlaUnreal/UnrealEngine.git UnrealEngine5_carla
|
|
|
|
fi
|
2024-03-21 16:07:22 +08:00
|
|
|
pushd UnrealEngine5_carla
|
2024-04-09 15:49:18 +08:00
|
|
|
echo -e '\n#CARLA UnrealEngine5\nexport CARLA_UNREAL_ENGINE_PATH='$PWD >> ~/.bashrc
|
2024-03-21 16:07:22 +08:00
|
|
|
export CARLA_UNREAL_ENGINE_PATH=$PWD
|
|
|
|
popd
|
|
|
|
popd
|
|
|
|
echo "CARLA UnrealEngine5 Installed..."
|
|
|
|
fi
|
2024-05-03 16:11:58 +08:00
|
|
|
pushd ..
|
2024-05-27 20:55:14 +08:00
|
|
|
pushd $CARLA_UNREAL_ENGINE_PATH
|
2024-05-24 01:05:54 +08:00
|
|
|
echo Checking if UnreaEngine5 is in the last commit...
|
2024-05-23 19:30:51 +08:00
|
|
|
git fetch
|
|
|
|
if [[ $(git status) =~ "up to date" ]]; then
|
|
|
|
echo UnreaEngine5 is already in the last commit - OK
|
|
|
|
else
|
|
|
|
echo UnreaEngine5 is NOT in the last commit - FAIL
|
|
|
|
echo Cleaning UnrealEngine5 build...
|
|
|
|
git clean -fdx
|
|
|
|
echo Pulling last UnrealEngine5 changes...
|
|
|
|
git pull
|
|
|
|
fi
|
2024-05-03 16:11:58 +08:00
|
|
|
echo "Setup CARLA UnrealEngine5..."
|
|
|
|
./Setup.sh --force
|
|
|
|
echo "GenerateProjectFiles CARLA UnrealEngine5..."
|
|
|
|
./GenerateProjectFiles.sh
|
|
|
|
echo "Build CARLA UnrealEngine5..."
|
|
|
|
make
|
|
|
|
popd
|
|
|
|
popd
|
2024-03-21 16:07:22 +08:00
|
|
|
|
|
|
|
echo "Configuring CARLA..."
|
2024-05-23 15:42:12 +08:00
|
|
|
retry --until=success --times=10 -- cmake -G Ninja -S . -B Build \
|
|
|
|
--toolchain=$PWD/CMake/LinuxToolchain.cmake \
|
|
|
|
-DLAUNCH_ARGS="-prefernvidia" \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DENABLE_ROS2=ON \
|
|
|
|
-DBUILD_CARLA_UNREAL=ON \
|
|
|
|
-DCARLA_UNREAL_ENGINE_PATH=$CARLA_UNREAL_ENGINE_PATH
|
2024-03-21 16:07:22 +08:00
|
|
|
echo "Building CARLA..."
|
|
|
|
retry --until=success --times=10 -- cmake --build Build
|
2024-04-26 16:43:26 +08:00
|
|
|
echo "Installing PythonAPI..."
|
|
|
|
cmake --build Build --target carla-python-api-install
|
2024-03-21 16:07:22 +08:00
|
|
|
echo "Waitting for Content to be downloaded... (see the progres in ContentClone.log)"
|
|
|
|
wait #Waitting for content
|
|
|
|
echo "Instalation and build succesfull! :)"
|
|
|
|
echo "Lauching Carla with Unreal Editor..."
|
|
|
|
cmake --build Build --target launch
|