Skip to content

Instantly share code, notes, and snippets.

@Justme488
Forked from Sanaki/updatera
Created July 2, 2020 02:26
Show Gist options
  • Select an option

  • Save Justme488/e8890555bbf21fe99253121d634ad5e0 to your computer and use it in GitHub Desktop.

Select an option

Save Justme488/e8890555bbf21fe99253121d634ad5e0 to your computer and use it in GitHub Desktop.
Script for building retroarch and select cores
#!/usr/bin/env bash
# Known non-working (YMMV): Dosbox SVN CE (Dosbox Core is now preferred anyway), Emux (requires a special build recipe)
# Partial Reference: https://libretro.readthedocs.io/en/latest/development/retroarch/compilation/linux-and-bsd/
# FORCE when set to YES will build regardless of changes
# NOCLEAN when set to 1 will prevent make clean before each build. Do not use NOCLEAN on core recipes or cores won't pull changes. Due to this situation I recommend against building MAME as part of this script.
# EXIT_ON_ERROR determines if the build stops on errors
# SINGLE_CORE can be set to a core name to bypass building the entire recipe (core set)
# Cores to be built, exporting the libretro_cores env var will use that list instead. For most people, ~/.bashrc will suffice for this.
[[ -z "$libretro_cores" ]] && libretro_cores="2048 atari800 bluemsx citra desmume dolphin fbneo fceumm ffmpeg flycast gambatte gearsystem genesis_plus_gx gw hatari mednafen_lynx mednafen_ngp mednafen_pce_fast mednafen_psx_hw mednafen_saturn mednafen_supergrafx mednafen_vb mednafen_wswan melonds mesen mgba mupen64plus_next neocd opera picodrive pokemini ppsspp prboom prosystem quasi88 sameboy snes9x stella thepowdertoy vemulator vice_x128 virtualjaguar"
# Support users with modified XDG_CONFIG_HOME location
[[ -z "$XDG_CONFIG_HOME" ]] && XDG_CONFIG_HOME="$HOME/.config"
# Clone or update the libretro-super repo
mkdir -p ~/src
cd ~/src
git clone https://github.com/libretro/libretro-super.git --depth 1 2> >(grep -v 'already exists and is not an empty directory' >&2) || (cd libretro-super ; git pull)
cd libretro-super
# Build retroarch
FORCE=NO EXIT_ON_ERROR=1 ./libretro-buildbot-recipe.sh recipes/linux/retroarch-linux-x64
mkdir -p ~/bin
ln -sfT ~/src/libretro-super/retroarch/retroarch ~/bin/retroarch
# Generate custom recipe for cores
truncate -s 0 recipes/linux/custom-cores-x64
for core in $libretro_cores; do
sed -n "/^$core\s/p" recipes/linux/cores-linux-x64-generic >> recipes/linux/custom-cores-x64
done
ln -f recipes/linux/cores-linux-x64-generic.conf recipes/linux/custom-cores-x64.conf
# Build cores
FORCE=NO EXIT_ON_ERROR=0 ./libretro-buildbot-recipe.sh recipes/linux/custom-cores-x64
# Hardlink cores into default core directory used by retroarch (generating directories if needed, overwriting existing cores)
mkdir -p "$XDG_CONFIG_HOME"/retroarch/cores
ln -f ~/src/libretro-super/dist/unix/*.so "$XDG_CONFIG_HOME"/retroarch/cores/
# Clone/pull and symlink PPSSPP assets if requested. Clone size is ~14MiB.
# This doesn't pull submodules, because they're large and aren't needed for assets. If you want to build standalone as well, you'll need to pull those separately.
if [[ "$libretro_ppsspp_assets" -eq 1 ]]; then
cd ~/src
git clone https://github.com/hrydgard/ppsspp.git --depth 1 2> >(grep -v 'already exists and is not an empty directory' >&2) || (cd ppsspp ; git pull)
mkdir -p "$XDG_CONFIG_HOME"/retroarch/system
ln -sfT ~/src/ppsspp/assets "$XDG_CONFIG_HOME"/retroarch/system/PPSSPP
fi
# Clone/pull and symlink dolphin assets if requested. Clone size is ~40MiB.
if [[ "$libretro_dolphin_assets" -eq 1 ]]; then
cd ~/src
git clone https://github.com/dolphin-emu/dolphin.git --depth 1 2> >(grep -v 'already exists and is not an empty directory' >&2) || (cd dolphin ; git pull)
mkdir -p "$XDG_CONFIG_HOME"/retroarch/system/dolphin-emu
ln -sfT ~/src/dolphin/Data/Sys "$XDG_CONFIG_HOME"/retroarch/system/dolphin-emu/Sys
fi
# Symlink assets and other files into the default config directory
ln -sfT ~/src/libretro-super/retroarch/media/assets "$XDG_CONFIG_HOME"/retroarch/assets
ln -sfT ~/src/libretro-super/retroarch/media/autoconfig "$XDG_CONFIG_HOME"/retroarch/autoconfig
mkdir -p "$XDG_CONFIG_HOME"/retroarch/database
#ln -sfT ~/src/libretro-super/retroarch/media/libretrodb/cursors "$XDG_CONFIG_HOME"/retroarch/database/cursors
ln -sfT ~/src/libretro-super/retroarch/media/libretrodb/rdb "$XDG_CONFIG_HOME"/retroarch/database/rdb
ln -sfT ~/src/libretro-super/retroarch/media/overlays "$XDG_CONFIG_HOME"/retroarch/overlay
mkdir -p "$XDG_CONFIG_HOME"/retroarch/shaders
ln -sfT ~/src/libretro-super/retroarch/media/shaders_cg "$XDG_CONFIG_HOME"/retroarch/shaders/shaders_cg
ln -sfT ~/src/libretro-super/retroarch/media/shaders_glsl "$XDG_CONFIG_HOME"/retroarch/shaders/shaders_glsl
ln -sfT ~/src/libretro-super/retroarch/media/shaders_slang "$XDG_CONFIG_HOME"/retroarch/shaders/shaders_slang
# Symlink cheats without touching core-specific cheat files
mkdir -p "$XDG_CONFIG_HOME"/retroarch/cheats
for i in ~/src/libretro-super/retroarch/media/libretrodb/cht/*; do
ln -sfT "$i" "$XDG_CONFIG_HOME"/retroarch/cheats/"${i##*/}"
done
# Lock all cores added via this script (allows using online updater to "update all cores" without overwrite)
for i in ~/src/libretro-super/dist/unix/*.so; do
touch "$XDG_CONFIG_HOME"/retroarch/cores/"${i##*/}".lck
done
# Replace core info in default config with git core info
rm "$XDG_CONFIG_HOME"/retroarch/cores/*.info
cp ~/src/libretro-super/dist/info/*.info "$XDG_CONFIG_HOME"/retroarch/cores/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment