Skip to content

Commit

Permalink
updated gcc setup and added build cache to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
admercs committed Apr 26, 2024
1 parent 0ce30a9 commit 4c2ab59
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ on:
types: [opened, synchronize, reopened, closed]
# workflow_dispatch:

env:
GCC_VERSION: "13.2.0"

jobs:
build-ubuntu:
runs-on: ${{ matrix.os }} # ubuntu-latest
Expand All @@ -37,6 +40,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: "Cache GCC build"
id: cache-gcc
uses: actions/cache@v4
with:
path: "gcc-$GCC_VERSION/"
key: ${{ runner.os }}-gcc

- name: "Build GCC from source"
if: steps.cache-gcc.outputs.cache-hit != 'true'
shell: bash
run: bash /scripts/build_gcc.sh --version "$GCC_VERSION"

- name: "Install AutonomySim Dependencies"
shell: bash
run: bash ./scripts/setup.sh
Expand Down
5 changes: 3 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RPCLIB_VERSION='2.3.0'
PROJECT_DIR="$(realpath $PWD)"
SCRIPT_DIR="$(realpath ${BASH_SOURCE[0]})"

GCC_DIR="${PROJECT_DIR}/deps/gcc-${GCC_VERSION}/bin"
GCC_VERSION_MAJOR="${GCC_VERSION%%.*}"

if [ "$(uname)" = 'Darwin' ]; then
Expand Down Expand Up @@ -131,8 +132,8 @@ if [ "$(uname)" = 'Darwin' ]; then
CMAKE_VARS="-DCXX_STANDARD=c++${CXX_STANDARD} -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_APPLE_SILICON_PROCESSOR=${SYSTEM_PLATFORM}"
elif [ "$(uname)" = 'Linux' ]; then
if [ "$USE_GCC" = 'true' ]; then
export CC="gcc-${GCC_VERSION_MAJOR}"
export CXX="g++-${GCC_VERSION_MAJOR}"
export CC="${GCC_DIR}/gcc"
export CXX="${GCC_DIR}/g++"
CMAKE_VARS="-DCXX_STANDARD=c++${CXX_STANDARD}"
else
export CC="clang-${CLANG_VERSION}"
Expand Down
23 changes: 14 additions & 9 deletions scripts/build_gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set -e # exit on error return code
# NOTE: for the latest release version see: https://mirrors.kernel.org/gnu/gcc/
GCC_VERSION='13.2.0'

# Script is to be run from base AutonomySim directory.
PROJECT_DIR="$PWD"

# process command-line interface (CLI) arguments.
while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -38,8 +41,9 @@ while [ $# -gt 0 ]; do
done

# create dependencies directory if it does not exist.
mkdir -p deps
mkdir -p deps/gcc_build
pushd deps
pushd gcc_build

echo "Downloading GCC from GNU/Linux mirror: GCC ${GCC_VERSION}..."
wget "https://mirrors.kernel.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz.sig"
Expand All @@ -59,19 +63,20 @@ source ./contrib/download_prerequisites
echo 'Building GCC from source...'
mkdir build
pushd build
../configure --prefix="${HOME}/gcc-${GCC_VERSION}" --disable-multilib
../configure --prefix="${PROJECT_DIR}/deps/gcc-${GCC_VERSION}" --disable-multilib
make
make install

echo 'Removing temporary files...'
popd
popd
rm -rf "gcc-${GCC_VERSION}" "gcc-${GCC_VERSION}.tar.gz" "gcc-${GCC_VERSION}.tar.gz.sig"
popd
popd # exit build
popd # exit gcc-$GCC_VERSION
popd # exit gcc_build
rm -rf gcc_build
popd # exit deps

echo "Prepending GCC ${GCC_VERSION} binary directory path to user PATH variable..."
echo 'WARNING: This may have undesirable side-effects.'
echo "export PATH=\$HOME/gcc-${GCC_VERSION}/bin:\$PATH" | tee -a "${HOME}/.bashrc"
# echo "Prepending GCC ${GCC_VERSION} binary directory path to user PATH variable..."
# echo 'WARNING: This may have some undesirable side-effects.'
# echo "export PATH=\$HOME/AutonomySim/deps/gcc-${GCC_VERSION}/bin:\$PATH" | tee -a "${HOME}/.bashrc"

echo 'GCC build completed successfully.'

Expand Down
6 changes: 4 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ else
sudo apt-get install -y \
"libc++-${CLANG_VERSION}-dev" \
"libc++abi-${CLANG_VERSION}-dev"
# Download and build GCC from source
source "${SCRIPT_DIR}/build_gcc.sh" --version "$GCC_VERSION"
# Conditionally download and build GCC from source
if [ ! -d "${PROJECT_DIR}/deps/gcc-${GCC_VERSION}/bin" ]; then
source "${SCRIPT_DIR}/build_gcc.sh" --version "$GCC_VERSION"
fi
#sudo apt-get install -y \
# "gcc-${GCC_VERSION}" \
# "libstdc++-${GCC_VERSION}-dev"
Expand Down

0 comments on commit 4c2ab59

Please sign in to comment.