Skip to content

Commit

Permalink
tvOS: when cache is deleted, force assets.zip re-extraction
Browse files Browse the repository at this point in the history
Also including a script to make building assets.zip easier, for people
building from source themselves
  • Loading branch information
warmenhoven committed Feb 19, 2024
1 parent 1af8a5f commit 8ce5b27
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 12 deletions.
13 changes: 1 addition & 12 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,7 @@ static void frontend_darwin_get_env(int *argc, char *argv[],
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], application_data, "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], application_data, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]));

#if TARGET_OS_IOS
{
int major, minor;
get_ios_version(&major, &minor);
if (major > 8)
strlcpy(g_defaults.path_buildbot_server_url,
"http://buildbot.libretro.com/nightly/apple/ios9/latest/",
sizeof(g_defaults.path_buildbot_server_url));
}
#endif

#if TARGET_OS_IOS
#if TARGET_OS_IPHONE
fill_pathname_join_special(assets_zip_path,
bundle_path_buf, "assets.zip", sizeof(assets_zip_path));
#else
Expand Down
63 changes: 63 additions & 0 deletions pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
objectVersion = 46;
objects = {

/* Begin PBXAggregateTarget section */
0795205D2B839A99000698BB /* Rebuild assets.zip */ = {
isa = PBXAggregateTarget;
buildConfigurationList = 079520602B839A99000698BB /* Build configuration list for PBXAggregateTarget "Rebuild assets.zip" */;
buildPhases = (
079520612B839AB0000698BB /* ShellScript */,
);
dependencies = (
);
name = "Rebuild assets.zip";
productName = "Rebuild assets.zip";
};
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
070A88432A4E7AA9003161C0 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 070A88422A4E7AA9003161C0 /* OpenAL.framework */; };
0714E7152983A5E500E6B45B /* libMoltenVK.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0714E7132983A5AC00E6B45B /* libMoltenVK.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -1360,6 +1374,7 @@
9204BE091D319EF300BD49DB /* RetroArchiOS */,
926C77D621FD1E6500103EDE /* RetroArchTV */,
9292D6E028F549D000E47A75 /* RetroArchWidgetExtensionExtension */,
0795205D2B839A99000698BB /* Rebuild assets.zip */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -1443,6 +1458,26 @@
shellScript = "cd \"$SRCBASE\"\nif [ -f \".git_version.h\" ] ; then\n cp .git_version.h \"${DERIVED_FILE_DIR}\"/git_version.h\nelse\n echo '#define GIT_VERSION ' $(git rev-parse --short HEAD) > \"${DERIVED_FILE_DIR}\"/git_version.h\nfi\n";
showEnvVarsInLog = 0;
};
079520612B839AB0000698BB /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
"$(SRCROOT)/assets.zip",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "$SRCROOT/rebuild-assets.sh -o\n";
showEnvVarsInLog = 0;
};
9204BE271D319EF300BD49DB /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -1581,6 +1616,25 @@
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
0732B0982B83D5CD00CA82CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = "Rebuild assets.zip";
};
name = Debug;
};
0732B0992B83D5CD00CA82CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
PRODUCT_NAME = "Rebuild assets.zip";
};
name = Release;
};
9204BE291D319EF300BD49DB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -2304,6 +2358,15 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
079520602B839A99000698BB /* Build configuration list for PBXAggregateTarget "Rebuild assets.zip" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0732B0982B83D5CD00CA82CD /* Debug */,
0732B0992B83D5CD00CA82CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9204BE281D319EF300BD49DB /* Build configuration list for PBXNativeTarget "RetroArchiOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
117 changes: 117 additions & 0 deletions pkg/apple/rebuild-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

WD=$(realpath $(dirname $0))

include_cheats=""
include_overlays=""
include_shaders=""
assets_zip="$WD/assets.zip"

args=`getopt achmos $*`
set -- $args
while :; do
case "$1" in
-a)
include_cheats=1
include_overlays=1
include_shaders=1
shift
;;
-c)
include_cheats=1
shift
;;
-h)
echo "$(basename $0) -- Rebuild assets.zip"
echo "Meant to be used when building RetroArch yourself. The buildbot does not use this."
echo
echo " -c Include cheats"
echo " -o Include overlays"
echo " -s Include shaders"
echo " -a Include cheats, overlays, and shaders"
echo " -m Build for macOS (places in OSX directory"
exit 0
;;
-m)
assets_zip="$WD/OSX/assets.zip"
shift
;;
-o)
include_overlays=1
shift
;;
-s)
include_shaders=1
shift
;;
--)
shift
break
;;
esac
done

function fetch_zip()
{
echo "Fetching $1..."
curl -s -o tmp.zip "https://git.libretro.com/api/v4/projects/libretro-assets%2F$1/jobs/artifacts/master/download?job=libretro-package-any"
echo " Unzipping..."
unzip -q tmp.zip
rm -f tmp.zip
}

pushd "$WD" &>/dev/null

rm -rf .media
fetch_zip retroarch-assets
fetch_zip retroarch-joypad-autoconfig
fetch_zip libretro-database
fetch_zip libretro-super
if [ -n "$include_overlays" ] ; then
fetch_zip common-overlays
fi
if [ -n "$include_shaders" ] ; then
fetch_zip glsl-shaders
fetch_zip slang-shaders
fi

pushd .media &>/dev/null

echo "Packaging assets"
mkdir assets ; mv retroarch-assets/{COPYING,glui,menu_widgets,ozone,pkg,rgui,sounds,xmb} assets ; rm -rf retroarch-assets
rm -rf assets/pkg/wiiu

echo "Packaging autoconfig"
mv retroarch-joypad-autoconfig autoconfig
rm -rf autoconfig/{android,dinput,linuxraw,parport,qnx,sdl2,udev,x,xinput}

if [ -n "$include_cheats" ] ; then
echo "Packaging cheats"
mv libretro-database/cht cht
fi
echo "Packaging database"
mkdir database ; mv libretro-database/{cursors,rdb} database ; rm -rf libretro-database

echo "Packaging info"
mv libretro-super/info info ; rmdir libretro-super

if [ -n "$include_overlays" ] ; then
echo "Packaging overlays"
mv common-overlays overlays
rm -rf overlays/{ctr,wii}
fi

if [ -n "$include_shaders" ] ; then
echo "Packaging shaders"
mkdir shaders ; mv glsl-shaders shaders/shaders_glsl ; mv slang-shaders shaders/shaders_slang
fi

rm -f ../assets.zip
echo "Zipping final assets bundle..."
zip -qr ../assets.zip *

popd &>/dev/null

rm -rf .media

echo "Done!"
4 changes: 4 additions & 0 deletions ui/drivers/cocoa/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,10 @@ bool cocoa_get_metrics(
char *str = strdup(backup.UTF8String);
conf = config_file_new_from_string(str, path_get(RARCH_PATH_CONFIG));
free(str);
/* If we are falling back to the NSUserDefaults backup of the config file,
* it's likely because the OS has deleted all of our cache, including our
* extracted assets. This will cause re-extraction */
config_set_int(conf, "bundle_assets_extract_last_version", 0);
}
return conf;
}
Expand Down

0 comments on commit 8ce5b27

Please sign in to comment.