mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-28 18:06:09 +02:00
mega big fix for shaders
This commit is contained in:
+40
-14
@@ -170,27 +170,53 @@ make_ico() { # $1 = output .ico path
|
||||
# --------------------------------------------------------------- macOS
|
||||
# ShaderFX's librashader bridge. Only the CONVERT action needs it, so a build
|
||||
# without it still runs presets that were converted elsewhere.
|
||||
# SHADERFX_BRIDGE points at a prebuilt library; otherwise cargo builds it.
|
||||
# SHADERFX_BRIDGE_<PLAT> or dist/native/<plat>/ points at a prebuilt library;
|
||||
# otherwise cargo builds it, host platform only.
|
||||
shader_bridge_host_plat() {
|
||||
case "$(uname -s)-$(uname -m)" in
|
||||
Darwin-*) printf 'mac' ;;
|
||||
Linux-x86_64) printf 'linux-x64' ;;
|
||||
Linux-aarch64|Linux-arm64) printf 'linux-arm64' ;;
|
||||
*) printf '' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
bundle_shader_bridge() {
|
||||
local dest="$1" name="$2"
|
||||
local src="${SHADERFX_BRIDGE:-}"
|
||||
local dest="$1" name="$2" plat="$3"
|
||||
local crate="$ROOT/tools/shaderfx-bridge"
|
||||
if [ -z "$src" ] && [ -f "$crate/target/release/$name" ]; then
|
||||
src="$crate/target/release/$name"
|
||||
local src="" var
|
||||
[ -n "$plat" ] || fail "bundle_shader_bridge: no platform key for $name"
|
||||
|
||||
var="SHADERFX_BRIDGE_$(printf '%s' "$plat" | tr 'a-z-' 'A-Z_')"
|
||||
eval "src=\${$var:-}"
|
||||
|
||||
if [ -z "$src" ] && [ -f "$DIST/native/$plat/$name" ]; then
|
||||
src="$DIST/native/$plat/$name"
|
||||
fi
|
||||
if [ -z "$src" ] && command -v cargo >/dev/null 2>&1; then
|
||||
say "building the ShaderFX bridge with cargo"
|
||||
if (cd "$crate" && cargo build --release >/dev/null 2>&1); then
|
||||
if [ -z "$src" ] && [ -n "${SHADERFX_BRIDGE:-}" ]; then
|
||||
src="$SHADERFX_BRIDGE"
|
||||
fi
|
||||
if [ -z "$src" ] && [ "$plat" = "$(shader_bridge_host_plat)" ]; then
|
||||
if [ -f "$crate/target/release/$name" ]; then
|
||||
src="$crate/target/release/$name"
|
||||
elif command -v cargo >/dev/null 2>&1; then
|
||||
say "building the ShaderFX bridge with cargo"
|
||||
if (cd "$crate" && cargo build --release >/dev/null 2>&1); then
|
||||
src="$crate/target/release/$name"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$src" ] && [ -f "$src" ]; then
|
||||
mkdir -p "$dest"
|
||||
cp "$src" "$dest/$name"
|
||||
say "bundled $name for SHADER FX preset conversion"
|
||||
else
|
||||
warn "$name not found: this build can run converted presets but not CONVERT new ones (set SHADERFX_BRIDGE or install cargo)"
|
||||
say "bundled $name for SHADER FX preset conversion ($plat)"
|
||||
return 0
|
||||
fi
|
||||
if [ "${SHADERFX_BRIDGE_REQUIRED:-}" = "1" ]; then
|
||||
fail "$name ($plat) not found: set $var or stage it at dist/native/$plat/$name"
|
||||
fi
|
||||
warn "$name not found: this build can run converted presets but not CONVERT new ones (set $var or install cargo)"
|
||||
}
|
||||
|
||||
build_mac() {
|
||||
@@ -205,7 +231,7 @@ build_mac() {
|
||||
# drop any bundled placeholder .love and fuse ours in
|
||||
find "$out_app/Contents/Resources" -maxdepth 1 -name '*.love' -delete
|
||||
cp "$LOVE_FILE" "$out_app/Contents/Resources/game.love"
|
||||
bundle_shader_bridge "$out_app/Contents/MacOS" "liblibrashader_bridge.dylib"
|
||||
bundle_shader_bridge "$out_app/Contents/MacOS" "liblibrashader_bridge.dylib" mac
|
||||
|
||||
local plist="$out_app/Contents/Info.plist"
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleName $APP_NAME" "$plist" 2>/dev/null \
|
||||
@@ -322,7 +348,7 @@ build_win() {
|
||||
warn "gen1tls.dll not found: Windows zip will not support wss:// (set GEN1TLS_DLL or build native/tls_dial)"
|
||||
fi
|
||||
|
||||
bundle_shader_bridge "$out_dir" "librashader_bridge.dll"
|
||||
bundle_shader_bridge "$out_dir" "librashader_bridge.dll" win-x64
|
||||
|
||||
# The exe's icon lives in love.exe's PE resources, so it must be patched
|
||||
# BEFORE the .love is appended: peresed rewrites the whole file and would
|
||||
@@ -419,7 +445,7 @@ build_linux() {
|
||||
unsquashfs -q -no-xattrs -o "$sfs_offset" -d "$appdir" "$love_appimage" >/dev/null
|
||||
|
||||
cp "$LOVE_FILE" "$appdir/game.love"
|
||||
bundle_shader_bridge "$appdir" "liblibrashader_bridge.so"
|
||||
bundle_shader_bridge "$appdir" "liblibrashader_bridge.so" linux-x64
|
||||
|
||||
# Replace LÖVE's own desktop entry rather than keeping it: it says
|
||||
# Name=LÖVE / Icon=love, which is what appimaged, app menus and file
|
||||
|
||||
@@ -86,7 +86,25 @@ text = re.sub(
|
||||
pathlib.Path(dst).write_text(text, encoding="utf-8")
|
||||
PY
|
||||
|
||||
cp "$ROOT/flatpak/$APP_ID.yml" "$CACHE/$APP_ID.yml"
|
||||
BRIDGE_LIB="liblibrashader_bridge.so"
|
||||
BRIDGE_SRC="${SHADERFX_BRIDGE_LINUX_X64:-}"
|
||||
if [ -z "$BRIDGE_SRC" ] && [ -f "$ROOT/dist/native/linux-x64/$BRIDGE_LIB" ]; then
|
||||
BRIDGE_SRC="$ROOT/dist/native/linux-x64/$BRIDGE_LIB"
|
||||
fi
|
||||
if [ -z "$BRIDGE_SRC" ] && [ -f "$ROOT/tools/shaderfx-bridge/target/release/$BRIDGE_LIB" ]; then
|
||||
BRIDGE_SRC="$ROOT/tools/shaderfx-bridge/target/release/$BRIDGE_LIB"
|
||||
fi
|
||||
rm -f "$CACHE/$BRIDGE_LIB"
|
||||
if [ -n "$BRIDGE_SRC" ] && [ -f "$BRIDGE_SRC" ]; then
|
||||
cp "$BRIDGE_SRC" "$CACHE/$BRIDGE_LIB"
|
||||
cp "$ROOT/flatpak/$APP_ID.yml" "$CACHE/$APP_ID.yml"
|
||||
say "staged $BRIDGE_LIB for SHADER FX preset conversion"
|
||||
elif [ "${SHADERFX_BRIDGE_REQUIRED:-}" = "1" ]; then
|
||||
fail "$BRIDGE_LIB not found: set SHADERFX_BRIDGE_LINUX_X64 or stage it at dist/native/linux-x64/$BRIDGE_LIB"
|
||||
else
|
||||
warn "$BRIDGE_LIB not found: this bundle can run converted presets but not CONVERT new ones"
|
||||
sed '/# BRIDGE-BEGIN/,/# BRIDGE-END/d' "$ROOT/flatpak/$APP_ID.yml" > "$CACHE/$APP_ID.yml"
|
||||
fi
|
||||
|
||||
say "installing Freedesktop runtime (no-op if present)"
|
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo || true
|
||||
@@ -116,5 +134,10 @@ if command -v sha256sum >/dev/null 2>&1; then
|
||||
else
|
||||
printf '%s %s\n' "$(shasum -a 256 "$OUT" | awk '{print $1}')" "$(basename "$OUT")" > "$OUT.sha256"
|
||||
fi
|
||||
if [ -f "$CACHE/$BRIDGE_LIB" ]; then
|
||||
[ -f "$BUILD_DIR/files/share/gen1recomp/$BRIDGE_LIB" ] \
|
||||
|| fail "$BRIDGE_LIB was staged but is missing from the built /app/share/gen1recomp"
|
||||
say "verified $BRIDGE_LIB in the Flatpak"
|
||||
fi
|
||||
say "Flatpak build: $OUT ($(du -h "$OUT" | cut -f1))"
|
||||
say "sha256: $(cut -d' ' -f1 "$OUT.sha256")"
|
||||
|
||||
@@ -100,6 +100,21 @@ then
|
||||
fi
|
||||
cp "$GAME_LOVE" "$IN_DIR/game.love"
|
||||
|
||||
BRIDGE_LIB="liblibrashader_bridge.so"
|
||||
BRIDGE_SRC="${SHADERFX_BRIDGE_LINUX_ARM64:-}"
|
||||
if [ -z "$BRIDGE_SRC" ] && [ -f "$ROOT/dist/native/linux-arm64/$BRIDGE_LIB" ]; then
|
||||
BRIDGE_SRC="$ROOT/dist/native/linux-arm64/$BRIDGE_LIB"
|
||||
fi
|
||||
rm -f "$IN_DIR/$BRIDGE_LIB"
|
||||
if [ -n "$BRIDGE_SRC" ] && [ -f "$BRIDGE_SRC" ]; then
|
||||
cp "$BRIDGE_SRC" "$IN_DIR/$BRIDGE_LIB"
|
||||
say "staged $BRIDGE_LIB for SHADER FX preset conversion"
|
||||
elif [ "${SHADERFX_BRIDGE_REQUIRED:-}" = "1" ]; then
|
||||
fail "$BRIDGE_LIB not found: set SHADERFX_BRIDGE_LINUX_ARM64 or stage it at dist/native/linux-arm64/$BRIDGE_LIB"
|
||||
else
|
||||
warn "$BRIDGE_LIB not found: this build can run converted presets but not CONVERT new ones"
|
||||
fi
|
||||
|
||||
# --------------------------------------------------------------- downloads
|
||||
# Fetched on the host and checksum-pinned here so the container never needs
|
||||
# network access and every input is verified in exactly one place.
|
||||
|
||||
@@ -327,6 +327,14 @@ bundle_needed "$APPDIR/lib/liblove-$LOVE_VERSION.so"
|
||||
say "bundled $(ls "$APPDIR/lib" | wc -l) libraries: $(ls "$APPDIR/lib" | tr '\n' ' ')"
|
||||
|
||||
# ------------------------------------------------- host dependency contract
|
||||
SHADER_BRIDGE=()
|
||||
if [ -f "$IN/liblibrashader_bridge.so" ]; then
|
||||
cp "$IN/liblibrashader_bridge.so" "$APPDIR/liblibrashader_bridge.so"
|
||||
chmod 0755 "$APPDIR/liblibrashader_bridge.so"
|
||||
SHADER_BRIDGE=("$APPDIR/liblibrashader_bridge.so")
|
||||
say "bundled liblibrashader_bridge.so for SHADER FX preset conversion"
|
||||
fi
|
||||
|
||||
# The portability promise, stated as an assertion instead of a paragraph in a
|
||||
# README: these are the ONLY sonames the shipped objects may require from the
|
||||
# host. Everything driver-, session- or audio-related has to be reached
|
||||
@@ -339,7 +347,7 @@ say "bundled $(ls "$APPDIR/lib" | wc -l) libraries: $(ls "$APPDIR/lib" | tr '\n'
|
||||
HOST_ALLOWED_RE='^(ld-linux-aarch64\.so\.1|libc\.so\.6|libm\.so\.6|libdl\.so\.2|libpthread\.so\.0|librt\.so\.1|libstdc\+\+\.so\.6|libgcc_s\.so\.1|libatomic\.so\.1|libfreetype\.so\.6|libpng[0-9]*\.so\.[0-9]+|libz\.so\.1|libbrotli(dec|common)\.so\.1)$'
|
||||
|
||||
unexpected=""
|
||||
for object in "$APPDIR/bin/love" "$APPDIR"/lib/*.so*; do
|
||||
for object in "$APPDIR/bin/love" "$APPDIR"/lib/*.so* ${SHADER_BRIDGE[@]+"${SHADER_BRIDGE[@]}"}; do
|
||||
while read -r soname; do
|
||||
[ -n "$soname" ] || continue
|
||||
# Satisfied from inside the AppDir, so not a host requirement at all.
|
||||
|
||||
@@ -20,6 +20,23 @@ for required in AppRun bin/love game.love lib/liblove-11.5.so; do
|
||||
|| { echo "::error::AppImage is missing $required"; exit 1; }
|
||||
done
|
||||
|
||||
bridge="squashfs-root/liblibrashader_bridge.so"
|
||||
if [ "${SHADERFX_BRIDGE_REQUIRED:-}" = "1" ] && [ ! -e "$bridge" ]; then
|
||||
echo "::error::AppImage is missing liblibrashader_bridge.so"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Discovered, not enumerated: bin/love and lib/*.so* miss anything native at
|
||||
# the AppDir root, which is where ShaderFX's bridge sits and where the next
|
||||
# root-level library would land too.
|
||||
scan=()
|
||||
while IFS= read -r f; do
|
||||
scan+=("$f")
|
||||
done < <(find squashfs-root -type f -exec sh -c \
|
||||
'head -c4 "$1" | od -An -tx1 | tr -d " \n" | grep -q "^7f454c46$"' _ {} \; -print | sort)
|
||||
[ "${#scan[@]}" -gt 0 ] || { echo "::error::found no ELF objects in the AppDir"; exit 1; }
|
||||
echo "scanning ${#scan[@]} ELF objects: ${scan[*]#squashfs-root/}"
|
||||
|
||||
# Every bundled object must resolve once AppRun's LD_LIBRARY_PATH is
|
||||
# applied; an unresolved soname here is a user-visible launch crash.
|
||||
#
|
||||
@@ -28,14 +45,14 @@ done
|
||||
# hard-links libpulse/libasound/libX11/libwayland, so it only ever
|
||||
# started on a full desktop -- a bare runner is what exposed it.
|
||||
missing="$(LD_LIBRARY_PATH="$PWD/squashfs-root/lib" \
|
||||
ldd squashfs-root/bin/love squashfs-root/lib/*.so* 2>/dev/null \
|
||||
ldd "${scan[@]}" 2>/dev/null \
|
||||
| grep 'not found' || true)"
|
||||
[ -z "$missing" ] || { echo "::error::unresolved deps:"; echo "$missing"; exit 1; }
|
||||
|
||||
# Nothing may hard-link a driver, session or audio-stack library:
|
||||
# those must be reached through dlopen so the AppImage runs on a box
|
||||
# with only ALSA, only Wayland, or only KMSDRM.
|
||||
linked="$(for f in squashfs-root/bin/love squashfs-root/lib/*.so*; do
|
||||
linked="$(for f in "${scan[@]}"; do
|
||||
objdump -p "$f" 2>/dev/null | awk '/NEEDED/{print $2}'
|
||||
done | sort -u | grep -E '^lib(pulse|asound|X11|wayland|GL|EGL|drm|gbm|xcb|cairo|sndio|dbus)' || true)"
|
||||
[ -z "$linked" ] \
|
||||
@@ -45,7 +62,7 @@ done | sort -u | grep -E '^lib(pulse|asound|X11|wayland|GL|EGL|drm|gbm|xcb|cairo
|
||||
# the builder to a newer base, the glibc floor silently rises and
|
||||
# every user on an older distro gets "GLIBC_2.xx not found" -- catch
|
||||
# it here instead of in a release.
|
||||
floor="$(objdump -T squashfs-root/bin/love squashfs-root/lib/*.so* 2>/dev/null \
|
||||
floor="$(objdump -T "${scan[@]}" 2>/dev/null \
|
||||
| grep -o 'GLIBC_[0-9.]*' | sort -V | tail -1)"
|
||||
echo "highest required glibc symbol version: $floor"
|
||||
[ -n "$floor" ] \
|
||||
@@ -54,4 +71,12 @@ highest="$(printf '%s\n' "$floor" "GLIBC_2.31" | sort -V | tail -1)"
|
||||
[ "$highest" = "GLIBC_2.31" ] \
|
||||
|| { echo "::error::AppImage requires $floor, above the bullseye 2.31 floor"; exit 1; }
|
||||
|
||||
# The floor grep proves symbol versions; an actual dlopen additionally proves
|
||||
# relocations and constructors. Native arch only, so it is skipped elsewhere.
|
||||
if [ -e "$bridge" ] && [ "$(uname -m)" = "aarch64" ] && command -v python3 >/dev/null 2>&1; then
|
||||
python3 -c "import ctypes,sys; ctypes.CDLL(sys.argv[1])" "$PWD/$bridge" \
|
||||
|| { echo "::error::liblibrashader_bridge.so failed to dlopen"; exit 1; }
|
||||
echo "librashader bridge dlopens cleanly"
|
||||
fi
|
||||
|
||||
echo "AppImage verified: $image"
|
||||
|
||||
@@ -118,6 +118,7 @@ run_tier "T0 Yellow title OBP eye remap" python3 tests/title_pikachu_obp_test.py
|
||||
run_tier "T0 Crystal manifest + specials coverage" "$LUA" tests/crystal_import_test.lua
|
||||
run_tier "T0 switch CI workflow content gate" "$LUA" tests/switch_ci_workflows_test.lua
|
||||
run_tier "T0 switch transfer docs gate" "$LUA" tests/switch_transfer_docs_test.lua
|
||||
run_tier "T0 ShaderFX bridge packaging gate" "$LUA" tests/shaderfx_bridge_packaging_test.lua
|
||||
# NX Blue/Yellow asset overlay: ROM-free, must run on every checkout so a
|
||||
# Sound.lua / overlay regression is not gated only on switch-changes paths.
|
||||
run_tier "T0 NX asset overlay fallback" "$LUA" tests/engine/assets_version_fallback_test.lua
|
||||
|
||||
Reference in New Issue
Block a user