Files
RetroArch/samples/runloop/cloudsync_unload/build.sh
libretroadmin 90d78c23b0 cloud sync: the unload sync starts once the save RAM is on disk
With Cloud Sync in automatic mode, closing content asks for a sync.
When content is running, CMD_EVENT_UNLOAD_CORE now only marks it
(RARCH_FLAGS_CLOUD_SYNC_ON_DEINIT), and retroarch_main_deinit_finish
pushes it: by then the content's save RAM has been flushed and no
core owns the save file, so the sync uploads and hashes the save the
content left behind, and may update it from the server. With no
content running the sync is pushed at once, as before. On the way out
the task queue has already been drained, so a sync marked there is
dropped, as one pushed before the drain was cancelled.

samples/runloop/cloudsync_unload links the shipping retroarch.c with
task_push_cloud_sync wrapped, loads a core with save RAM, closes the
content from a frame loop and checks what the save file held when the
sync was asked for. It runs in the menu harness workflow.
2026-10-03 01:50:55 +02:00

63 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Builds the cloud sync unload harness.
#
# Like content_closing, this links the SHIPPING objects of a built
# RetroArch with only main() replaced, and one symbol wrapped:
# task_push_cloud_sync, so the harness sees each sync the frontend
# asks for, and what the save file holds at that moment, without a
# server. The core it loads (sram_core.so) is built here too.
#
# Requires a completed NON-Qt build, from the repo root:
#
# ./configure --disable-qt && make
# samples/runloop/cloudsync_unload/build.sh
#
# The compile and link lines are the project's own, taken from make -n.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
root=$(cd "$here/../../.." && pwd)
out=samples/runloop/cloudsync_unload
cd "$root"
if [ ! -f obj-unix/release/retroarch.o ]; then
echo "build RetroArch first: ./configure --disable-qt && make" >&2
exit 1
fi
cc_line=$(mktemp)
ld_line=$(mktemp)
trap 'rm -f "$cc_line" "$ld_line"' EXIT
touch retroarch.c
make -n 2>/dev/null | grep -E '\-o obj-unix/release/retroarch\.o' | head -1 > "$cc_line"
if [ ! -s "$cc_line" ]; then
echo "could not determine the compile command for retroarch.o" >&2
exit 1
fi
sed "s#-o obj-unix/release/retroarch\.o#-Dmain=rarch_harness_unused_main -o $out/retroarch_nomain.o#" \
"$cc_line" | sh
sed -e "s#-o obj-unix/release/retroarch\.o#-o $out/harness_main.o#" \
-e "s# retroarch\.c# $out/cloudsync_unload_test.c#" \
"$cc_line" | sh
rm -f retroarch
make -n 2>/dev/null | grep -E ' -o retroarch ' | tail -1 > "$ld_line"
if [ ! -s "$ld_line" ]; then
echo "could not determine the link command" >&2
exit 1
fi
sed -e "s#obj-unix/release/retroarch\.o#$out/retroarch_nomain.o $out/harness_main.o#" \
-e "s#-o retroarch #-o $out/cloudsync_unload_test -Wl,--wrap=task_push_cloud_sync #" \
"$ld_line" | sh
core_cc=$(sed 's/ .*//' "$cc_line")
$core_cc -O1 -g -shared -fPIC -Ilibretro-common/include \
-o $out/sram_core.so $out/sram_core.c
echo "built $out/cloudsync_unload_test and $out/sram_core.so"