Skip to content

Commit

Permalink
update linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
admercs committed Mar 2, 2024
1 parent 79b33c7 commit 22bb210
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 36 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
</a>
</p>

<!---
<p align="center" width="100%">
<img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white">
<img src="https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white">
<img src="https://img.shields.io/badge/macOS-313131?style=for-the-badge&logo=apple&logoColor=white">
</p>
--->

<p align="center" width="100%">
<img src="https://img.shields.io/badge/Unreal-313131.svg?style=for-the-badge&logo=unrealengine&logoColor=white">
Expand Down
25 changes: 20 additions & 5 deletions UnrealPlugin/Unreal/Environments/Blocks/scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#!/bin/bash
#----------------------------------------------------------------------------------------
# Filename
# clean.sh
# Description
# BASH script to cleanup Unreal Environment.
# Authors
# Microsoft (original)
# Adam Erickson (Nervosys)
# Date
# 2024-03-01
# Usage
# Notes
# - This script is a cleaned up version of the original AirSim script.
# TODO
#----------------------------------------------------------------------------------------

set -e
set -x

# Get path of current script
SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]}")
SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))
ENV_DIR="${SCRIPT_DIR}/.."

echo "Script directory: ${SCRIPT_DIR}"
echo "Environment directory: ${ENV_DIR}"

pushd "${ENV_DIR}" >/dev/null
pushd "${ENV_DIR}"

# clean temporary unreal folders
rm -rf ./Binaries
Expand All @@ -19,7 +34,7 @@ rm -rf ./Saved
rm -rf ./Plugins/AutonomySim/Binaries
rm -rf ./Plugins/AutonomySim/Intermediate
rm -rf ./Plugins/AutonomySim/Saved
rm -f ./CMakeLists.txt
rm -f ./Makefile
rm -rf ./CMakeLists.txt
rm -rf ./Makefile

popd >/dev/null
popd
40 changes: 19 additions & 21 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,22 @@ set -e # exit on error return code
### Functions
###

# System information.
function system_info {
uname -a && lscpu
}

function system_architecture {
# System architecture.
function system_arch {
# unreliable: uname -m
lscpu | grep 'Architecture' | awk {'print $2'}
}

function system_os_version {
# System OS version.
function system_os {
uname -r
}

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

###
### Variables
###
Expand All @@ -54,17 +53,17 @@ DEBUG='false'
GCC='false'

GCC_VERSION='11'
CLANG_VERSION='14'
CLANG_VERSION='12'
CMAKE_VERSION='3.10.2'
EIGEN_VERSION='3.4.0'
RPCLIB_VERSION='2.3.0'
UNREAL_ASSET_VERSION='1.2.0'

# Dynamic variables.
SYSTEM_INFO="$(system_info)"
SYSTEM_PLATFORM="$(system_architecture)"
SYSTEM_PLATFORM="$(system_arch)"
SYSTEM_CPU_MAX="$(( $(nproc) - 2 ))"
SYSTEM_OS_VERSION="$(system_os_version)"
SYSTEM_OS_VERSION="$(system_os)"

###
### Main
Expand Down Expand Up @@ -121,8 +120,8 @@ elif [ "$(uname)" = 'Linux' ]; then
export CC="gcc"
export CXX="g++"
else
export CC="clang"
export CXX="clang++"
export CC="clang-${CLANG_VERSION}"
export CXX="clang++-${CLANG_VERSION}"
fi
else
echo 'ERROR: This build script only supports Linux and MacOS.'
Expand All @@ -135,26 +134,25 @@ if [ ! -d "./AutonomyLib/deps/eigen3/Eigen" ]; then
exit 1
fi

echo "Moving build into directory: ${build_dir}"

# Ensure CMake files will be built in our build directory.
[ -f "./cmake/CMakeCache.txt" ] && rm "./cmake/CMakeCache.txt"
[ -d "./cmake/CMakeFiles" ] && rm -rf "./cmake/CMakeFiles"
[ ! -d "$build_dir" ] && mkdir -p "$build_dir"
[ ! -d "./cmake/${build_dir}" ] && mkdir -p "./cmake/${build_dir}"

# Enter build directory.
pushd "$build_dir"
echo "Moving into build directory: ./cmake/${build_dir}"
pushd "./cmake/${build_dir}"

# Fix for Unreal on Apple/ARM silicon using x86_64 (Rosetta).
CMAKE_VARS=''
[ "$(uname)" = 'Darwin' ] && CMAKE_VARS='-DCMAKE_APPLE_SILICON_PROCESSOR=x86_64'

if [ "${DEBUG}" = 'true' ]; then
folder_name='Debug'
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_VARS || (cd .. && rm -r "$build_dir" && exit 1)
"$CMAKE" -DCMAKE_BUILD_TYPE=Debug "$CMAKE_VARS" .. || (popd && rm -rf "./$build_dir" && exit 1)
else
folder_name='Release'
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_VARS || (cd .. && rm -r "$build_dir" && exit 1)
"$CMAKE" -DCMAKE_BUILD_TYPE=Release "$CMAKE_VARS" .. || (popd && rm -rf "./$build_dir" && exit 1)
fi

# Final linking of the binaries can fail due to a missing libc++abi library
Expand All @@ -169,12 +167,12 @@ mkdir -p "./AutonomyLib/lib/x64/${folder_name}"
mkdir -p './AutonomyLib/deps/rpclib/lib'
mkdir -p './AutonomyLib/deps/MavLinkCom/lib'

cp "./${build_dir}/output/lib/libAutonomyLib.a" ./AutonomyLib/lib
cp "./${build_dir}/output/lib/libMavLinkCom.a" ./AutonomyLib/deps/MavLinkCom/lib
cp "./${build_dir}/output/lib/librpc.a" ./AutonomyLib/deps/rpclib/lib/librpc.a
cp "./cmake/${build_dir}/output/lib/libAutonomyLib.a" ./AutonomyLib/lib
cp "./cmake/${build_dir}/output/lib/libMavLinkCom.a" ./AutonomyLib/deps/MavLinkCom/lib
cp "./cmake/${build_dir}/output/lib/librpc.a" ./AutonomyLib/deps/rpclib/lib/librpc.a

# Update AutonomyLib/lib, AutonomyLib/deps, Plugins folders with new binaries
rsync -a --delete "./${build_dir}/output/lib/" "./AutonomyLib/lib/x64/${folder_name}"
rsync -a --delete "./cmake/${build_dir}/output/lib/" "./AutonomyLib/lib/x64/${folder_name}"
rsync -a --delete "./external/rpclib/rpclib-${RPCLIB_VERSION}/include" ./AutonomyLib/deps/rpclib
rsync -a --delete ./MavLinkCom/include ./AutonomyLib/deps/MavLinkCom
rsync -a --delete ./AutonomyLib ./UnrealPlugin/Unreal/Plugins/AutonomySim/Source
Expand Down
31 changes: 21 additions & 10 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ set -e # exit on error return code
### Functions
###

# silence brew error if package is already installed.
# Silence brew error if package is already installed.
function brew_install {
brew list "$1" &>/dev/null || brew install "$1"
}

# check version compatability
# Numeric comparator. A more robust version checker.
# USAGE: if ( numeric_comparison '3.3' '<=' '3.4' ); then ...; else ...; fi
# WARNING: cannot handle version numbers.
# function numeric_comparison {
# test "$(echo $1 $2 $3 | bc --mathlib)" = '1'
# }

# Check version compatability.
function version_less_than_equal_to {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$1"
}
Expand Down Expand Up @@ -89,22 +96,28 @@ if [ "$(uname)" = 'Darwin' ]; then
brew update
brew install llvm
else
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo add-apt-repository -y ppa:graphics-drivers/ppa
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
gnupg \
software-properties-common \
build-essential \
unzip \
coreutils \
lsb-release \
rsync \
software-properties-common \
wget \
vulkan-tools \
libvulkan1
# vulkan vulkan-utils
VERSION=$(lsb_release -rs | cut -d '.' -f1)
#if [ "$VERSION" -lt '20' ]; then
wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
sudo apt-get update -y
#fi
CLANG_VERSION='14'
CLANG_VERSION='12' # requires ubuntu >= 20
sudo apt-get install -y clang-${CLANG_VERSION} libc++-${CLANG_VERSION}-dev libc++abi-${CLANG_VERSION}-dev
fi

Expand All @@ -125,7 +138,7 @@ if [ "$(uname)" = 'Darwin' ]; then
brew_install wget
brew_install coreutils
# Conditionally install lower CMake version.
if version_less_than_equal_to "$cmake_ver" "$CMAKE_VERSION_MIN"; then
if ( version_less_than_equal_to "$cmake_ver" "$CMAKE_VERSION_MIN" ); then
brew install cmake
else
echo "Compatible version of CMake already installed: $cmake_ver"
Expand All @@ -135,9 +148,7 @@ else
sudo /usr/sbin/useradd -G dialout "$USER"
sudo usermod -a -G dialout "$USER"
fi
sudo apt-get install -y build-essential unzip
if version_less_than_equal_to "$cmake_ver" "$CMAKE_VERSION_MIN"; then
sudo apt-get -y install apt-transport-https ca-certificates gnupg
if ( version_less_than_equal_to "$cmake_ver" "$CMAKE_VERSION_MIN" ); then
sudo apt-get -y install --no-install-recommends make cmake
else
echo "Compatible version of CMake already installed: $cmake_ver"
Expand Down

0 comments on commit 22bb210

Please sign in to comment.