Skip to content
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@v3
with:
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: Verify drm.h in sysroot
# run: |
# find . -iname drm.h
# ls ./sysroot/usr/include/libdrm/drm.h
- name: Build raylib (static) for Raspberry Pi
run: |
export SYSROOT=$(pwd)/sysroot
git clone --depth 1 https://github.com/raysan5/raylib.git
cd raylib
mkdir build
cd build
cmake -DPLATFORM="DRM" \
-DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="-I${SYSROOT}/usr/include/libdrm" \
..
make
make install
- 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