Skip to content

Commit 4f9e6cf

Browse files
Alejandro PérezAlejandro Pérez
authored andcommitted
Make iOS packaging reproducible
1 parent c7fe1c1 commit 4f9e6cf

3 files changed

Lines changed: 114 additions & 2 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
PLUME_DIR="$ROOT/thirdparty/plume"
6+
PATCH_FILE="$ROOT/tools/patches/plume-ios-sdl-vulkan.patch"
7+
8+
if [[ ! -d "$PLUME_DIR/.git" && ! -f "$PLUME_DIR/.git" ]]; then
9+
printf 'Missing Plume submodule. Run: git submodule update --init --recursive\n' >&2
10+
exit 1
11+
fi
12+
13+
if git -C "$PLUME_DIR" apply --check "$PATCH_FILE" >/dev/null 2>&1; then
14+
git -C "$PLUME_DIR" apply "$PATCH_FILE"
15+
printf 'Applied Plume iOS patch.\n'
16+
else
17+
if git -C "$PLUME_DIR" apply --reverse --check "$PATCH_FILE" >/dev/null 2>&1; then
18+
printf 'Plume iOS patch already applied.\n'
19+
else
20+
printf 'Plume iOS patch cannot be applied cleanly. Check thirdparty/plume for local changes.\n' >&2
21+
exit 1
22+
fi
23+
fi

tools/package_ios_ipa.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ IPA_DIR="$ROOT/out/ipa"
77
PAYLOAD_DIR="$IPA_DIR/Payload"
88
APP_PATH="$BUILD_DIR/Unleashed Recompiled.app"
99
IPA_PATH="$IPA_DIR/UnleashedRecompiled.ipa"
10+
DEFAULT_SIGNING_IDENTITY="Apple Development: aroblesalago@gmail.com (MK28YRUCCG)"
11+
12+
"$ROOT/tools/apply_ios_submodule_patches.sh"
1013

1114
missing=0
1215
for file in \
@@ -20,6 +23,7 @@ for file in \
2023
done
2124

2225
if [[ "$missing" -ne 0 ]]; then
26+
printf '\nAdd these files from your own compatible Sonic Unleashed Xbox 360 dump before building an IPA.\n' >&2
2327
exit 1
2428
fi
2529

@@ -35,11 +39,24 @@ rm -rf "$IPA_DIR"
3539
mkdir -p "$PAYLOAD_DIR"
3640
cp -R "$APP_PATH" "$PAYLOAD_DIR/"
3741

38-
if [[ -n "${MOBILEPROVISION:-}" ]]; then
39-
cp "$MOBILEPROVISION" "$PAYLOAD_DIR/Unleashed Recompiled.app/embedded.mobileprovision"
42+
if [[ -z "${CODESIGN_IDENTITY:-}" ]] && security find-identity -v -p codesigning | grep -q "$DEFAULT_SIGNING_IDENTITY"; then
43+
CODESIGN_IDENTITY="$DEFAULT_SIGNING_IDENTITY"
44+
fi
45+
46+
if [[ -n "${MOBILEPROVISION:-}" && ! -f "${MOBILEPROVISION:-}" ]]; then
47+
printf 'Provisioning profile not found: %s\n' "$MOBILEPROVISION" >&2
48+
exit 1
4049
fi
4150

4251
if [[ -n "${CODESIGN_IDENTITY:-}" ]]; then
52+
if [[ -z "${MOBILEPROVISION:-}" ]]; then
53+
printf 'CODESIGN_IDENTITY is set, but MOBILEPROVISION is not. Producing an unsigned IPA for sideloading tools that sign on import.\n' >&2
54+
else
55+
cp "$MOBILEPROVISION" "$PAYLOAD_DIR/Unleashed Recompiled.app/embedded.mobileprovision"
56+
fi
57+
fi
58+
59+
if [[ -n "${CODESIGN_IDENTITY:-}" && -n "${MOBILEPROVISION:-}" ]]; then
4360
codesign --force --sign "$CODESIGN_IDENTITY" \
4461
${ENTITLEMENTS:+--entitlements "$ENTITLEMENTS"} \
4562
"$PAYLOAD_DIR/Unleashed Recompiled.app"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 6a7645a..bf336b9 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -8,10 +8,16 @@ if(APPLE)
6+
endif()
7+
8+
string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} "Linux" IS_LINUX)
9+
+string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} "iOS" IS_IOS)
10+
+if(IS_LINUX OR IS_IOS)
11+
+ set(IS_SDL_VULKAN_PLATFORM ON)
12+
+else()
13+
+ set(IS_SDL_VULKAN_PLATFORM OFF)
14+
+endif()
15+
16+
# Project options
17+
include(CMakeDependentOption)
18+
-cmake_dependent_option(SDL_VULKAN_ENABLED "Enable SDL Vulkan integration" OFF IS_LINUX OFF)
19+
+cmake_dependent_option(SDL_VULKAN_ENABLED "Enable SDL Vulkan integration" OFF IS_SDL_VULKAN_PLATFORM OFF)
20+
cmake_dependent_option(D3D12_AGILITY_SDK_ENABLED "Enable D3D12 Agility SDK" OFF WIN32 OFF)
21+
option(PLUME_BUILD_EXAMPLES "Build example applications" OFF)
22+
23+
diff --git a/plume_vulkan.cpp b/plume_vulkan.cpp
24+
index 9103ca8..02c3591 100644
25+
--- a/plume_vulkan.cpp
26+
+++ b/plume_vulkan.cpp
27+
@@ -2112,6 +2112,12 @@ namespace plume {
28+
fprintf(stderr, "vkCreateXlibSurfaceKHR failed with error code 0x%X.\n", res);
29+
return;
30+
}
31+
+# elif defined(__APPLE__) && defined(SDL_VULKAN_ENABLED)
32+
+ VulkanInterface *renderInterface = commandQueue->device->renderInterface;
33+
+ if (!SDL_Vulkan_CreateSurface(renderWindow, renderInterface->instance, &surface)) {
34+
+ fprintf(stderr, "SDL_Vulkan_CreateSurface failed: %s.\n", SDL_GetError());
35+
+ return;
36+
+ }
37+
# elif defined(__APPLE__)
38+
assert(renderWindow.window != 0);
39+
assert(renderWindow.view != 0);
40+
@@ -2443,7 +2449,7 @@ namespace plume {
41+
// The attributes width and height members do not include the border.
42+
dstWidth = attributes.width;
43+
dstHeight = attributes.height;
44+
-# elif defined(__APPLE__)
45+
+# elif defined(__APPLE__) && !defined(SDL_VULKAN_ENABLED)
46+
CocoaWindowAttributes attributes;
47+
windowWrapper->getWindowAttributes(&attributes);
48+
dstWidth = attributes.width;
49+
diff --git a/plume_vulkan.h b/plume_vulkan.h
50+
index 73022bb..9d89adf 100644
51+
--- a/plume_vulkan.h
52+
+++ b/plume_vulkan.h
53+
@@ -22,8 +22,10 @@
54+
#define VK_USE_PLATFORM_XLIB_KHR
55+
#elif defined(__APPLE__)
56+
#define VK_USE_PLATFORM_METAL_EXT
57+
+#ifndef SDL_VULKAN_ENABLED
58+
#include "plume_apple.h"
59+
#endif
60+
+#endif
61+
62+
// For VK_KHR_portability_subset
63+
#define VK_ENABLE_BETA_EXTENSIONS
64+
@@ -226,7 +228,7 @@ namespace plume {
65+
VulkanCommandQueue *commandQueue = nullptr;
66+
VkSurfaceKHR surface = VK_NULL_HANDLE;
67+
RenderWindow renderWindow = {};
68+
-#if defined(__APPLE__)
69+
+#if defined(__APPLE__) && !defined(SDL_VULKAN_ENABLED)
70+
std::unique_ptr<CocoaWindow> windowWrapper;
71+
#endif
72+
uint32_t textureCount = 0;

0 commit comments

Comments
 (0)