This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build for Raspberry Pi 3 with raylib (static) | |
on: | |
push: | |
branches: | |
- main | |
- github-actions | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y \ | |
qemu-utils qemu-user-static debootstrap \ | |
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \ | |
make cmake | |
- name: Cache sysroot | |
id: cache-sysroot | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: ./sysroot | |
key: sysroot-buster | |
- name: Create sysroot for Raspbian Buster | |
if: steps.cache-sysroot.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p ./sysroot | |
sudo debootstrap --arch=armhf --foreign buster ./sysroot http://raspbian.raspberrypi.org/raspbian/ | |
sudo cp /usr/bin/qemu-arm-static ./sysroot/usr/bin/ | |
sudo chroot ./sysroot /debootstrap/debootstrap --second-stage | |
sudo chroot ./sysroot apt update | |
sudo chroot ./sysroot apt install -y libgbm-dev libasound2-dev libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libdrm-dev | |
- name: Create CMake toolchain file | |
run: | | |
echo "set(CMAKE_SYSTEM_NAME Linux)" > toolchain.cmake | |
echo "set(CMAKE_SYSTEM_PROCESSOR arm)" >> toolchain.cmake | |
echo "set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)" >> toolchain.cmake | |
echo "set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)" >> toolchain.cmake | |
echo "set(CMAKE_SYSROOT $(pwd)/sysroot)" >> toolchain.cmake | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> toolchain.cmake | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> toolchain.cmake | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> toolchain.cmake | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)" >> toolchain.cmake | |
- name: Build raylib (static) for Raspberry Pi | |
run: | | |
export SYSROOT=$(pwd)/sysroot | |
git clone --depth 1 https://github.com/raysan5/raylib.git | |
cd raylib/src | |
make PLATFORM=PLATFORM_DRM USE_RPI_CROSS_COMPILER=TRUE RPI_TOOLCHAIN=/usr RPI_TOOLCHAIN_NAME=arm-linux-gnueabihf INCLUDE_PATHS='-I . -I ../../sysroot/usr/include/libdrm' | |
- name: Build the project | |
run: | | |
export SYSROOT=$(pwd)/sysroot | |
make SYSROOT=$SYSROOT | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rpi3-binary | |
path: ./snake_animation | |