Skip to content

Instantly share code, notes, and snippets.

@sukanka
Last active May 3, 2025 08:32
Show Gist options
  • Save sukanka/3659661c70210f60d7703202fdd3e974 to your computer and use it in GitHub Desktop.
Save sukanka/3659661c70210f60d7703202fdd3e974 to your computer and use it in GitHub Desktop.
PKGBUILD for citron
# Maintainer: username227 <gfrank227 [at] gmail [dot] com>
_pkgname=Citron
_xbyak_tag=7.24.2
pkgname=${_pkgname,,}-git
pkgver=0.6.1.canary.refresh.r53
pkgrel=1
pkgdesc="Nintendo Switch emulator forked from yuzu"
arch=(x86_64)
url=https://git.citron-emu.org/citron/emu
license=(GPL-3.0-or-later)
provides=('citron')
conflicts=('citron')
depends=('boost-libs' 'hicolor-icon-theme' 'sdl2' 'qt6-base' 'qt6-webengine' 'fmt' 'opus' 'lz4'
'openssl' 'zstd' 'cubeb' 'enet' 'discord-rpc' 'cpp-httplib' 'dynarmic' 'mbedtls2' 'ffmpeg'
)
makedepends=('llvm' 'git' 'glslang' 'cmake' 'ninja' 'perl' 'clang'
'qt6-tools' 'qt6-multimedia' 'libxkbcommon-x11' 'libzip' 'libfdk-aac' 'libinih'
'vulkan-memory-allocator' 'vulkan-utility-libraries' 'vulkan-headers' 'spirv-headers'
'boost' 'nlohmann-json' 'robin-map' 'cpp-jwt' 'gamemode' 'python' 'renderdoc'
# 'xbyak'
# with xbyak we get the runtime err:
# terminate called after throwing an instance of 'Xbyak::Error' what(): bad size of register
# for documentation
# 'doxygen' 'python-jinja' 'python-jsonschema' 'graphviz'
# for testing
# 'catch2'
)
optdepends=('qt6-wayland: for Wayland support')
source=(
Citron::git+${url}.git
git+https://github.com/yuzu-mirror/sirit.git#commit=ab75463
git+https://github.com/herumi/xbyak.git#tag=v${_xbyak_tag:-7.22}
# citron use xbyak v6.68 by default, but v7.22 is okay
git+https://github.com/brofield/simpleini.git#commit=6048871ea9
"https://github.com/lat9nq/tzdb_to_nx/releases/download/221202/221202.zip"
)
noextract=('221202.zip')
b2sums=('SKIP'
'91e4cd03d67c930b6d751ca19cf6fbaaba86084412bd13b172186387ea27b461457a3e19bc0af315c807839e64f91c865298678af748e2d6e07df2abc85430ed'
'c3cd6fdac08d04ff996a082d51b87c98a46a0c07b17cf1c9e794c4fbb284860e6355c7c4d7b41a66293d8181ec17a18dac772fac384a324b6e7e144540430ac5'
'fae42bb13f180ab991f6bfc8a45ea3df08ced1d77db77f54cf5a222f93ea468bd6fc0d36d65f9f3739e9813d77dbae31931948dc9afa28e884c53b8128c13c94'
'7bd0ff5ca80cf560344ae7edbfeb7c9466c096dc499a7348276cff5d30aa07464f7e2ea391ca9cedac0e21ba6f563169a8b38f2df729a230a0acfb1125ea1b66')
pkgver() {
cd "$srcdir/$_pkgname"
git describe --long --abbrev=7 --tags | sed 's/\([^-]*\)-g.*/r\1/;s/-/./g;s/^v//g'
}
prepare() {
local submods=(
sirit
simpleini
xbyak
)
for pro in ${submods[@]}; do
if [ -d $srcdir/$_pkgname/externals/${pro} ]; then
cp -rf ${srcdir}/${pro}/* $srcdir/$_pkgname/externals/${pro}
else
cp -rf ${srcdir}/${pro} $srcdir/$_pkgname/externals/${pro}
fi
done
cd $srcdir/$_pkgname
sed -i CMakeLists.txt \
-e '/-DBOOST_ASIO_DISABLE_CONCEPTS/d' \
-e 's/1.4.313/1.4.309/g' \
-e '/target_compile_options/d' \
-e '/add_subdirectory(externals)/d' \
-e 's|^add\_subdirectory(src)|add_subdirectory(externals)\n add_subdirectory(src)#|g'
sed -i src/CMakeLists.txt \
-e 's|-Werror=shadow$|-Wno-error=shadow|g' \
-e 's|-Werror=unused$|-Wno-error=unused|g' \
-e 's|include_directories(.|include_directories(. /usr/include/mbedtls2|g' \
-e '/include_directories/a link_directories(/usr/lib/mbedtls2)'
sed -i src/${_pkgname,,}_cmd/CMakeLists.txt \
-e "/target_include_directories(${_pkgname,,}-cmd/a target_link_libraries(${_pkgname,,}-cmd PRIVATE mbedtls mbedcrypto)"
sed -i src/${_pkgname,,}/CMakeLists.txt \
-e "/target_sources(${_pkgname,,}/i target_link_libraries(${_pkgname,,} PRIVATE mbedtls mbedcrypto)"
sed -i src/video_core/host_shaders/CMakeLists.txt \
-e 's/--quiet //g' \
-e 's#${SPIRV_HEADER_FILE} ${SOURCE_FILE}#${SPIRV_HEADER_FILE} ${SOURCE_FILE} 2>/dev/null#g'
sed -i -e 's| (%2)||' src/${_pkgname,,}/aboutdialog.ui
sed -i -e 's|io_service|io_context|g' src/input_common/drivers/udp_client.cpp src/tests/input_common/calibration_configuration_job.cpp
sed -i -e 's|u64|std::uint64_t|g' src/${_pkgname,,}/discord_impl.h
sed -i -e "s|https://github.com/lat9nq/tzdb_to_nx/releases/download/\${NX_TZDB_VERSION}|file://${srcdir}|g" externals/nx_tzdb/CMakeLists.txt
perl -0777 -i.original -pe 's/(\s*target_compile_options\(video_core PRIVATE\s*-Wno-sign-conversion)/$1\n -msse4.1/igs' src/video_core/CMakeLists.txt
# see dynarmic 6.7.0 changelog
sed -i src/core/arm/dynarmic/arm_dynarmic_{32,64}.cpp \
-e '/fastmem_pointer/s/nullptr/std::nullopt/g' \
-e 's|page_table->fastmem_arena;|(page_table->fastmem_arena != nullptr) ? std::optional<uintptr_t>{reinterpret_cast<uintptr_t>(page_table->fastmem_arena)} : std::nullopt;|g'
# this line causes crash, introduced in commit 54173384271
sed -i externals/xbyak/xbyak/xbyak.h \
-e '/if (!(type & T_ALLOW_DIFF_SIZE) && r1.isREG() && r2.isREG() && r1.getBit() != r2.getBit()) XBYAK_THROW(ERR_BAD_SIZE_OF_REGISTER)/d'
# system mbedtls
sed -i externals/CMakeLists.txt \
-e '/add_subdirectory(mbedtls)/c pkg_check_modules(MbedTLS REQUIRED IMPORTED_TARGET GLOBAL mbedtls mbedcrypto)' \
-e '/target_include_directories(mbedtls/d' \
-e '/^ *target_compile_options(mbedcrypto/,/)/ { s/^/#/ }'
# boost 1.88
sed -i src/core/debugger/debugger.cpp \
-e 's|#include *<boost/process/async_pipe.hpp>|#include <boost/process/v1/async_pipe.hpp>|g' \
-e 's/\bboost::process::async_pipe\b/boost::process::v1::async_pipe/g'
# no member named 'use_nce' in 'Settings::Values', so we just use false to replace this in a || expression
sed -i src/citron/configuration/configure_system.cpp \
-e 's|setting->Id() == Settings::values.use_nce.Id()|false|g'
}
build() {
export CC=clang
export CXX=clang++
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/lib/mbedtls2/pkgconfig
local cmake_args=(
-GNinja
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DTITLE_BAR_FORMAT_IDLE="$_pkgname $pkgver"
-DTITLE_BAR_FORMAT_RUNNING="$_pkgname $pkgver | {3}"
-DCMAKE_INSTALL_PREFIX=/usr
-DCMAKE_BUILD_TYPE=Release
-DCITRON_ENABLE_COMPATIBILITY_REPORTING=OFF
-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=OFF
-DCITRON_USE_QT_WEB_ENGINE=ON
-DUSE_DISCORD_PRESENCE=ON
-DENABLE_QT_TRANSLATION=ON
-DCITRON_USE_BUNDLED_FFMPEG=OFF
-DCITRON_USE_BUNDLED_QT=OFF
-DCITRON_USE_EXTERNAL_SDL2=OFF
-DCITRON_CHECK_SUBMODULES=OFF
-DCITRON_USE_EXTERNAL_VULKAN_HEADERS=OFF
-DCITRON_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES=OFF
-DCITRON_USE_FASTER_LD=OFF
-DCITRON_USE_PRECOMPILED_HEADERS=OFF
-DCITRON_USE_QT_MULTIMEDIA=ON
# download timezone data from our zip file.
-DCITRON_DOWNLOAD_TIME_ZONE_DATA=ON
-DCITRON_TESTS=OFF
-DSIRIT_USE_SYSTEM_SPIRV_HEADERS=ON
-DUSE_SYSTEM_QT=ON
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
)
install -d build
cmake -S ${_pkgname} -B build "${cmake_args[@]}"
ninja -C build
}
package() {
install -Dm644 $srcdir/${_pkgname}/dist/72-${_pkgname,,}-input.rules -t ${pkgdir}/usr/lib/udev/rules.d/
DESTDIR="$pkgdir/" ninja -C $srcdir/build install
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment