Skip to content

Instantly share code, notes, and snippets.

@popey
Created January 25, 2021 17:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popey/02363a3768d0d01a0ad5c0abb759c7fe to your computer and use it in GitHub Desktop.
Save popey/02363a3768d0d01a0ad5c0abb759c7fe to your computer and use it in GitHub Desktop.
BBCSDL Auto-starting snap for Raspberry Pi
name: bbcsdl
base: core20
version: "master"
summary: BBC BASIC for SDL 2.0
license: "Zlib"
description: |
BBC BASIC for SDL 2.0 is a cross-platform implementation of the BBC BASIC
programming language for Windows, Linux (x86), MacOS, Raspbian (Raspberry Pi),
Android, iOS and Emscripten / WebAssembly. It is highly compatible with BBC
BASIC for Windows and has the same language extensions, but uses SDL 2.0 as
an OS abstraction layer to achieve cross-platform compatibility.
grade: stable
confinement: strict
architectures:
- build-on: armhf
run-on: [ armhf, arm64 ]
layout:
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
/usr/share/alsa:
bind: $SNAP/usr/share/alsa
parts:
alsa-mixin:
plugin: dump
source: https://github.com/diddlesnaps/snapcraft-alsa.git
source-subdir: snapcraft-assets
build-packages:
- libasound2-dev
stage-packages:
- libasound2
- libasound2-plugins
- yad
glib-only:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: glib-only
plugin: make
build-packages:
- libglib2.0-dev
stage-packages:
- libglib2.0-bin
override-prime: |
snapcraftctl prime
# force armhf
sed -i 's/export SNAP_LAUNCHER/export ARCH="arm-linux-gnueabihf"\nexport SNAP_LAUNCHER/' bin/desktop-launch
# do not try to update xdg links in home (HOME is SNAP_COMMON)
sed -i '/# Create links for user-dirs.dirs/,+21 s/^/#/' bin/desktop-launch
pi-libs:
after: [alsa-mixin]
source: https://github.com/raspberrypi/firmware.git
source-depth: 1
plugin: nil
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/usr
cp -av hardfp/opt/vc/bin $SNAPCRAFT_PART_INSTALL/usr/
cp -av hardfp/opt/vc/lib $SNAPCRAFT_PART_INSTALL/usr/
cp -av hardfp/opt/vc/include $SNAPCRAFT_PART_INSTALL/usr/
# we want to link against mesa, drop GLES and EGL includes
rm -rf $SNAPCRAFT_PART_INSTALL/usr/include/*GL*
prime:
- -usr/include
sdl2:
after: [ pi-libs ]
plugin: cmake
source: https://github.com/spurious/SDL-mirror.git
source-tag: release-2.0.14
cmake-parameters:
- -DCMAKE_PREFIX_PATH=${SNAPCRAFT_STAGE}/usr
- -DCMAKE_INSTALL_PREFIX=/usr
- -DVIDEO_OPENGL=OFF
- -DVIDEO_OPENGLES=ON
- -DVIDEO_X11=OFF
- -DVIDEO_WAYLAND=OFF
- -DVIDEO_KMSDRM=ON
- -DVIDEO_RPI=OFF
- -DESD=OFF
build-packages:
- libdrm-dev
- libegl-dev
- libgbm-dev
- libgles-dev
- libinput-dev
build-environment:
- CFLAGS: "-I${SNAPCRAFT_STAGE}/usr/include -I${SNAPCRAFT_STAGE}/usr/include/interface/vcos/pthreads -I${SNAPCRAFT_STAGE}/usr/include/interface/vm"
- CXXFLAGS: "-I${SNAPCRAFT_STAGE}/usr/include -I${SNAPCRAFT_STAGE}/usr/include/interface/vcos/pthreads -I${SNAPCRAFT_STAGE}/usr/include/interface/vm"
stage-packages:
- libdrm2
- libegl1
- libgbm1
- libgles2
sdl2-ttf:
after: [ sdl2 ]
plugin: autotools
source: https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz
build-packages:
- libfreetype-dev
autotools-configure-parameters:
- --prefix=/usr
sdl2-net:
after: [ sdl2-ttf ]
plugin: autotools
source: https://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz
autotools-configure-parameters:
- --prefix=/usr
bbcsdl:
after: [sdl2-net]
plugin: make
source: https://github.com/rtrussell/BBCSDL.git
build-packages:
- nasm
stage-packages:
- libglu1-mesa
- libgl1-mesa-glx
- libgl1-mesa-dri
- libc6
override-build: |
ARCHITECTURE=$(dpkg --print-architecture)
if [ "${ARCHITECTURE}" = "amd64" ]; then
cd bin/linux
else
cd bin/raspi
sed -i 's;-L/usr/lib/;-L$(SNAPCRAFT_STAGE)/usr/lib/;' makefile
sed -i 's;-I ../../include;-I ../../include -I $(SNAPCRAFT_STAGE)/usr/include;' makefile
fi
make
mkdir $SNAPCRAFT_PART_INSTALL/bin
cp ./bbcsdl $SNAPCRAFT_PART_INSTALL/bin
cp ./libstb.so $SNAPCRAFT_PART_INSTALL/lib
cp -a ../../examples $SNAPCRAFT_PART_INSTALL/
apps:
bbcsdl:
command: bin/desktop-launch $SNAP/bin/bbcsdl -fullscreen
command-chain: ["snap/command-chain/alsa-launch"]
daemon: simple
environment:
LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$SNAP/usr/lib/arm-linux-gnueabihf/dri"
ALWAYS_USE_PULSEAUDIO: '1'
LIBGL_DRIVERS_PATH: "$SNAP/usr/lib/arm-linux-gnueabihf/dri"
HOME: "$SNAP_COMMON"
plugs:
- pulseaudio
- audio-playback
- audio-record
- hardware-observe
- joystick
- opengl
- process-control
- x11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment