Skip to content

Commit 79b33c7

Browse files
committed
update linux build
1 parent 599407b commit 79b33c7

File tree

6 files changed

+93
-106
lines changed

6 files changed

+93
-106
lines changed

.github/workflows/test_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Copyright © 2024 Nervosys, LLC
1414
#----------------------------------------------------------------------------------------
1515

16-
name: "Build & Deploy: Documentation"
16+
name: "Build & Deploy: Docs"
1717

1818
on:
1919
push:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<p align="center" width="100%">
4545
<img src="https://img.shields.io/badge/Unreal-313131.svg?style=for-the-badge&logo=unrealengine&logoColor=white">
46-
<img src="https://img.shields.io/badge/PowerShell-2CA5E0?style=for-the-badge&logo=powershell&logoColor=white">
46+
<img src="https://img.shields.io/badge/PWSH-2CA5E0?style=for-the-badge&logo=powershell&logoColor=white">
4747
<img src="https://img.shields.io/badge/BASH-313131?style=for-the-badge&logo=gnu-bash&logoColor=white">
4848
<img src="https://img.shields.io/badge/C%2B%2B-00599C?style=for-the-badge&logo=c%2B%2B&logoColor=white">
4949
<img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white">
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
#!/bin/bash
22

3-
# Get path of current script
4-
SCRIPT_DIR="$(realpath ${BASH_SOURCE[0]})"
5-
pushd "$SCRIPT_DIR" > /dev/null
6-
73
set -e
84
set -x
95

6+
# Get path of current script
7+
SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]}")
8+
ENV_DIR="${SCRIPT_DIR}/.."
9+
10+
echo "Script directory: ${SCRIPT_DIR}"
11+
echo "Environment directory: ${ENV_DIR}"
12+
13+
pushd "${ENV_DIR}" >/dev/null
14+
1015
# clean temporary unreal folders
11-
rm -rf Binaries
12-
rm -rf Intermediate
13-
rm -rf Saved
14-
rm -rf Plugins/AutonomySim/Binaries
15-
rm -rf Plugins/AutonomySim/Intermediate
16-
rm -rf Plugins/AutonomySim/Saved
17-
rm -f CMakeLists.txt
18-
rm -f Makefile
16+
rm -rf ./Binaries
17+
rm -rf ./Intermediate
18+
rm -rf ./Saved
19+
rm -rf ./Plugins/AutonomySim/Binaries
20+
rm -rf ./Plugins/AutonomySim/Intermediate
21+
rm -rf ./Plugins/AutonomySim/Saved
22+
rm -f ./CMakeLists.txt
23+
rm -f ./Makefile
1924

20-
popd > /dev/null
25+
popd >/dev/null
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

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

77
set -e
88
set -x
99

10-
./clean.sh
10+
./scripts/clean.sh
1111

1212
rsync -a --exclude 'temp' --delete ../../Plugins/AutonomySim Plugins/
1313
rsync -a --exclude 'temp' --delete ../../../AutonomyLib Plugins/AutonomySim/Source/
1414

15-
popd >/dev/null
15+
#popd >/dev/null

scripts/build.sh

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ function version_less_than_equal_to {
4545
### Variables
4646
###
4747

48-
# Script directory.
48+
# Directory paths.
49+
PROJECT_DIR="$(realpath $PWD)"
4950
SCRIPT_DIR="$(realpath ${BASH_SOURCE[0]})"
5051

5152
# Static variables.
5253
DEBUG='false'
5354
GCC='false'
5455

56+
GCC_VERSION='11'
57+
CLANG_VERSION='14'
5558
CMAKE_VERSION='3.10.2'
5659
EIGEN_VERSION='3.4.0'
5760
RPCLIB_VERSION='2.3.0'
@@ -86,8 +89,8 @@ done
8689

8790
# Check for existing rpclib installation.
8891
if [ ! -d "./external/rpclib/rpclib-${RPCLIB_VERSION}" ]; then
89-
echo "ERROR: new version of AutonomySim requires newer rpclib."
90-
echo "please run setup.sh first and then run build.sh again."
92+
echo "ERROR: rpclib version not found: ${RPCLIB_VERSION}"
93+
echo 'Please run `setup.sh` and then `build.sh` again.'
9194
exit 1
9295
fi
9396

@@ -115,11 +118,11 @@ if [ "$(uname)" = 'Darwin' ]; then
115118
export CXX="$(brew --prefix)/opt/llvm/bin/clang++"
116119
elif [ "$(uname)" = 'Linux' ]; then
117120
if [ "${GCC}" = 'true' ]; then
118-
export CC="gcc-8"
119-
export CXX="g++-8"
121+
export CC="gcc"
122+
export CXX="g++"
120123
else
121-
export CC="clang-8"
122-
export CXX="clang++-8"
124+
export CC="clang"
125+
export CXX="clang++"
123126
fi
124127
else
125128
echo 'ERROR: This build script only supports Linux and MacOS.'
@@ -132,58 +135,58 @@ if [ ! -d "./AutonomyLib/deps/eigen3/Eigen" ]; then
132135
exit 1
133136
fi
134137

135-
echo "Moving build into ${build_dir} directory. To clean, delete the directory."
138+
echo "Moving build into directory: ${build_dir}"
136139

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

145+
# Enter build directory.
146+
pushd "$build_dir"
147+
142148
# Fix for Unreal on Apple/ARM silicon using x86_64 (Rosetta).
143149
CMAKE_VARS=''
144150
[ "$(uname)" = 'Darwin' ] && CMAKE_VARS='-DCMAKE_APPLE_SILICON_PROCESSOR=x86_64'
145151

146-
pushd "$build_dir" >/dev/null # push directory onto stack
147-
148152
if [ "${DEBUG}" = 'true' ]; then
149153
folder_name='Debug'
150-
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_VARS || (popd && rm -r "$build_dir" && exit 1)
154+
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_VARS || (cd .. && rm -r "$build_dir" && exit 1)
151155
else
152156
folder_name='Release'
153-
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_VARS || (popd && rm -r "$build_dir" && exit 1)
157+
"$CMAKE" ../cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_VARS || (cd .. && rm -r "$build_dir" && exit 1)
154158
fi
155159

156-
#popd >/dev/null # pop directory from stack
157-
#pushd "$build_dir" >/dev/null # push directory onto stack
158-
159-
# final linking of the binaries can fail due to a missing libc++abi library
160+
# Final linking of the binaries can fail due to a missing libc++abi library
160161
# (happens on Fedora, see https://bugzilla.redhat.com/show_bug.cgi?id=1332306).
161-
# So we only build the libraries here for now
162+
# So we only build the libraries here for now.
162163
make -j"${SYSTEM_CPU_MAX}"
163-
popd > /dev/null # pop directory from stack
164164

165-
mkdir -p "AutonomyLib/lib/x64/${folder_name}"
166-
mkdir -p 'AutonomyLib/deps/rpclib/lib'
167-
mkdir -p 'AutonomyLib/deps/MavLinkCom/lib'
165+
# Drop back down into project directory.
166+
popd
168167

169-
cp "${build_dir}/output/lib/libAutonomyLib.a AutonomyLib/lib"
170-
cp "${build_dir}/output/lib/libMavLinkCom.a AutonomyLib/deps/MavLinkCom/lib"
171-
cp "${build_dir}/output/lib/librpc.a AutonomyLib/deps/rpclib/lib/librpc.a"
168+
mkdir -p "./AutonomyLib/lib/x64/${folder_name}"
169+
mkdir -p './AutonomyLib/deps/rpclib/lib'
170+
mkdir -p './AutonomyLib/deps/MavLinkCom/lib'
171+
172+
cp "./${build_dir}/output/lib/libAutonomyLib.a" ./AutonomyLib/lib
173+
cp "./${build_dir}/output/lib/libMavLinkCom.a" ./AutonomyLib/deps/MavLinkCom/lib
174+
cp "./${build_dir}/output/lib/librpc.a" ./AutonomyLib/deps/rpclib/lib/librpc.a
172175

173176
# Update AutonomyLib/lib, AutonomyLib/deps, Plugins folders with new binaries
174-
rsync -a --delete "${build_dir}/output/lib/ AutonomyLib/lib/x64/${folder_name}"
175-
rsync -a --delete "external/rpclib/rpclib-${RPCLIB_VERSION}/include AutonomyLib/deps/rpclib"
176-
rsync -a --delete 'MavLinkCom/include AutonomyLib/deps/MavLinkCom'
177-
rsync -a --delete 'AutonomyLib Unreal/Plugins/AutonomySim/Source'
177+
rsync -a --delete "./${build_dir}/output/lib/" "./AutonomyLib/lib/x64/${folder_name}"
178+
rsync -a --delete "./external/rpclib/rpclib-${RPCLIB_VERSION}/include" ./AutonomyLib/deps/rpclib
179+
rsync -a --delete ./MavLinkCom/include ./AutonomyLib/deps/MavLinkCom
180+
rsync -a --delete ./AutonomyLib ./UnrealPlugin/Unreal/Plugins/AutonomySim/Source
178181

179-
rm -rf 'Unreal/Plugins/AutonomySim/Source/AutonomyLib/src'
182+
rm -rf ./UnrealPlugin/Unreal/Plugins/AutonomySim/Source/AutonomyLib/src
180183

181184
# Update all environment projects
182-
for d in ./Unreal/Environments/*; do
185+
for d in ./UnrealPlugin/Unreal/Environments/*; do
183186
[ -L "${d%/}" ] && continue
184-
"${d}/clean.sh"
187+
bash "${d}/scripts/clean.sh"
185188
mkdir -p "${d}/Plugins"
186-
rsync -a --delete Unreal/Plugins/AutonomySim "${d}/Plugins"
189+
rsync -a --delete ./UnrealPlugin/Unreal/Plugins/AutonomySim "${d}/Plugins"
187190
done
188191

189192
set +x
@@ -196,6 +199,4 @@ echo ' For further info see:'
196199
echo ' https://github.com/nervosys/AutonomySim/blob/master/docs/build_linux.md'
197200
echo '-----------------------------------------------------------------------------------------'
198201

199-
popd >/dev/null # pop directory from stack
200-
201202
exit 0

scripts/setup.sh

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function brew_install {
3232
brew list "$1" &>/dev/null || brew install "$1"
3333
}
3434

35+
# check version compatability
3536
function version_less_than_equal_to {
3637
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$1"
3738
}
@@ -40,7 +41,8 @@ function version_less_than_equal_to {
4041
### Variables
4142
###
4243

43-
# Script directory.
44+
# Directory paths.
45+
PROJECT_DIR="$(realpath $PWD)"
4446
SCRIPT_DIR="$(realpath ${BASH_SOURCE[0]})"
4547

4648
# Ensure CMake supports CMAKE_APPLE_SILICON_PROCESSOR for MacOS.
@@ -58,6 +60,7 @@ UNREAL_ASSET_VERSION='1.2.0'
5860

5961
# download high-polycount SUV model.
6062
HIGH_POLYCOUNT_SUV='false'
63+
HIGH_POLYCOUNT_SUV_URL='https://github.com/microsoft/AirSim/releases/download/v1.2.0/car_assets.zip'
6164

6265
DEBUG="${DEBUG:-false}"
6366

@@ -93,15 +96,16 @@ else
9396
rsync \
9497
software-properties-common \
9598
wget \
96-
vulkan \
97-
vulkan-utils \
99+
vulkan-tools \
98100
libvulkan1
99-
VERSION=$(lsb_release -rs | cut -d. -f1)
100-
if [ "$VERSION" -lt '20' ]; then
101-
wget -O - 'http://apt.llvm.org/llvm-snapshot.gpg.key' | sudo apt-key add -
102-
sudo apt-get update -y
103-
fi
104-
sudo apt-get install -y clang-17 clang++-17 libc++-17-dev libc++abi-17-dev
101+
# vulkan vulkan-utils
102+
VERSION=$(lsb_release -rs | cut -d '.' -f1)
103+
#if [ "$VERSION" -lt '20' ]; then
104+
wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
105+
sudo apt-get update -y
106+
#fi
107+
CLANG_VERSION='14'
108+
sudo apt-get install -y clang-${CLANG_VERSION} libc++-${CLANG_VERSION}-dev libc++abi-${CLANG_VERSION}-dev
105109
fi
106110

107111
# Get/set CMake version.
@@ -112,8 +116,7 @@ else
112116
fi
113117

114118
# Give user permissions to access USB port, not needed if not using PX4 HIL.
115-
# TODO: figure out how to do below in travis.
116-
# Install additional tools, CMake if required.
119+
# TODO: figure out how to do below in travis. Install additional tools, CMake if required.
117120
if [ "$(uname)" = 'Darwin' ]; then
118121
if [ -n "${whoami}" ]; then # travis
119122
sudo dseditgroup -o edit -a "$(whoami)" -t user dialout
@@ -134,28 +137,8 @@ else
134137
fi
135138
sudo apt-get install -y build-essential unzip
136139
if version_less_than_equal_to "$cmake_ver" "$CMAKE_VERSION_MIN"; then
137-
if [ "$(lsb_release -rs)" = "18.04" ]; then
138-
sudo apt-get -y install apt-transport-https ca-certificates gnupg
139-
wget -O - 'https://apt.kitware.com/keys/kitware-archive-latest.asc' 2>/dev/null |
140-
gpg --dearmor - |
141-
sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
142-
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
143-
sudo apt-get -y install --no-install-recommends make cmake
144-
else
145-
# If CMake binary not found, build it from source.
146-
if [ ! -d './cmake_build/bin' ]; then
147-
echo 'Downloading CMake...'
148-
wget "https://cmake.org/files/v${CMAKE_VERSION_MIN_MAJ_MIN}/cmake-${CMAKE_VERSION}.tar.gz" -O cmake.tar.gz
149-
tar -xzf ./cmake.tar.gz
150-
rm ./cmake.tar.gz
151-
rm -rf ./cmake_build
152-
mv "./cmake-${CMAKE_VERSION}" ./cmake_build
153-
pushd cmake_build # push directory onto stack
154-
./bootstrap
155-
make
156-
popd # pop directory from stack
157-
fi
158-
fi
140+
sudo apt-get -y install apt-transport-https ca-certificates gnupg
141+
sudo apt-get -y install --no-install-recommends make cmake
159142
else
160143
echo "Compatible version of CMake already installed: $cmake_ver"
161144
fi
@@ -176,39 +159,37 @@ fi
176159

177160
# Download and unpack high-polycount SUV asset for Unreal Engine.
178161
if [ "${HIGH_POLYCOUNT_SUV}" = 'true' ]; then
179-
if [ ! -d './Unreal/Plugins/AutonomySim/Content/VehicleAdv' ]; then
180-
mkdir -p './Unreal/Plugins/AutonomySim/Content/VehicleAdv'
162+
if [ ! -d ./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv ]; then
163+
mkdir -p ./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv
181164
fi
182-
if [ ! -d "./Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV/v${UNREAL_ASSET_VERSION}" ]; then
165+
if [ ! -d "./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV/v${UNREAL_ASSET_VERSION}" ]; then
183166
echo '-----------------------------------------------------------------------------------------'
184167
echo ' Downloading Unreal high-polycount SUV asset...'
185168
echo '-----------------------------------------------------------------------------------------'
186-
if [ -d ./suv_download_tmp ]; then
187-
rm -rf ./suv_download_tmp
169+
if [ -d ./temp/suv ]; then
170+
rm -rf ./temp/suv
188171
fi
189-
mkdir -p ./suv_download_tmp
190-
cd suv_download_tmp
191-
wget 'https://github.com/microsoft/AirSim/releases/download/v2.0.0-beta.0/car_assets.zip'
192-
if [ -d '../Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV' ]; then
193-
rm -rf ../Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV
172+
mkdir -p ./temp/suv
173+
wget "$HIGH_POLYCOUNT_SUV_URL" -P ./temp/suv
174+
if [ -d ./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV ]; then
175+
rm -rf ./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv/SUV
194176
fi
195-
unzip -q ./car_assets.zip -d ../Unreal/Plugins/ASim/Content/VehicleAdv
196-
cd ..
197-
rm -rf ./suv_download_tmp
177+
unzip -q ./temp/suv/car_assets.zip -d ./UnrealPlugin/Unreal/Plugins/AutonomySim/Content/VehicleAdv
178+
rm -rf ./temp/suv
198179
fi
199180
else
200181
echo "Skipped: Download of Unreal high-polycount SUV asset. The default Unreal Engine vehicle will be used."
201182
fi
202183

203184
# Download and unpack Eigen3 C++ library.
204185
if [ ! -d './AutonomyLib/deps/eigen3' ]; then
205-
echo 'Installing Eigen3 C++ library. Downloading Eigen...'
206-
wget -O eigen3.zip "https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.zip"
207-
unzip -q eigen3.zip -d ./temp_eigen
186+
echo 'Installing Eigen C++ library...'
187+
mkdir -p ./temp/eigen
188+
wget "https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.zip" -P ./temp/eigen
189+
unzip -q "./temp/eigen/eigen-${EIGEN_VERSION}.zip" -d ./temp/eigen
208190
mkdir -p ./AutonomyLib/deps/eigen3
209-
mv ./temp_eigen/eigen*/Eigen ./AutonomyLib/deps/eigen3
210-
rm -rf temp_eigen
211-
rm eigen3.zip
191+
mv "./temp/eigen/eigen-${EIGEN_VERSION}/Eigen" ./AutonomyLib/deps/eigen3
192+
rm -rf ./temp/eigen
212193
else
213194
echo "Skipped: Eigen is already installed."
214195
fi

0 commit comments

Comments
 (0)