Skip to content

Commit a09d1ca

Browse files
committed
release: apply updates from SDL3 repo
- test Android elf alignment for x86_64/aarch64 - disable test cmake support of frameworks inside xcframework [ci skip]
1 parent 3837b42 commit a09d1ca

File tree

3 files changed

+185
-3
lines changed

3 files changed

+185
-3
lines changed

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ jobs:
260260
# -B build_darwin
261261
# cmake --build build_darwin --config Release --verbose
262262
#
263+
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
264+
# -DTEST_SHARED=TRUE \
265+
# -DTEST_STATIC=FALSE \
266+
# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/macos-arm64_x86_64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/macos-arm64_x86_64" \
267+
# -DCMAKE_SYSTEM_NAME=Darwin \
268+
# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
269+
# -B build_darwin2
270+
# cmake --build build_darwin2 --config Release --verbose
271+
#
263272
# - name: 'CMake (configure + build) iOS'
264273
# run: |
265274
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
@@ -271,6 +280,15 @@ jobs:
271280
# -Werror=dev \
272281
# -B build_ios
273282
# cmake --build build_ios --config Release --verbose
283+
#
284+
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
285+
# -DTEST_SHARED=TRUE \
286+
# -DTEST_STATIC=FALSE \
287+
# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/ios-arm64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/ios-arm64" \
288+
# -DCMAKE_SYSTEM_NAME=iOS \
289+
# -DCMAKE_OSX_ARCHITECTURES="arm64" \
290+
# -B build_ios2
291+
# cmake --build build_ios2 --config Release --verbose
274292
# - name: 'CMake (configure + build) tvOS'
275293
# run: |
276294
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
@@ -282,6 +300,15 @@ jobs:
282300
# -Werror=dev \
283301
# -B build_tvos
284302
# cmake --build build_tvos --config Release --verbose
303+
#
304+
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
305+
# -DTEST_SHARED=TRUE \
306+
# -DTEST_STATIC=FALSE \
307+
# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/tvos-arm64;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/tvos-arm64" \
308+
# -DCMAKE_SYSTEM_NAME=tvOS \
309+
# -DCMAKE_OSX_ARCHITECTURES="arm64" \
310+
# -B build_tvos2
311+
# cmake --build build_tvos2 --config Release --verbose
285312
# - name: 'CMake (configure + build) iOS simulator'
286313
# run: |
287314
# sysroot=$(xcodebuild -version -sdk iphonesimulator Path)
@@ -296,6 +323,16 @@ jobs:
296323
# -Werror=dev \
297324
# -B build_ios_simulator
298325
# cmake --build build_ios_simulator --config Release --verbose
326+
#
327+
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
328+
# -DTEST_SHARED=TRUE \
329+
# -DTEST_STATIC=FALSE \
330+
# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/ios-arm64_x86_64-simulator;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/ios-arm64_x86_64-simulator" \
331+
# -DCMAKE_SYSTEM_NAME=iOS \
332+
# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
333+
# -DCMAKE_OSX_SYSROOT="${sysroot}" \
334+
# -B build_ios_simulator2
335+
# cmake --build build_ios_simulator2 --config Release --verbose
299336
# - name: 'CMake (configure + build) tvOS simulator'
300337
# run: |
301338
# sysroot=$(xcodebuild -version -sdk appletvsimulator Path)
@@ -310,6 +347,16 @@ jobs:
310347
# -Werror=dev \
311348
# -B build_tvos_simulator
312349
# cmake --build build_tvos_simulator --config Release --verbose
350+
#
351+
# cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
352+
# -DTEST_SHARED=TRUE \
353+
# -DTEST_STATIC=FALSE \
354+
# -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }}/SDL3_net.xcframework/tvos-arm64_x86_64-simulator;${{ steps.deps-mount.outputs.path }}/SDL3.xcframework/tvos-arm64_x86_64-simulator" \
355+
# -DCMAKE_SYSTEM_NAME=tvOS \
356+
# -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
357+
# -DCMAKE_OSX_SYSROOT="${sysroot}" \
358+
# -B build_tvos_simulator2
359+
# cmake --build build_tvos_simulator2 --config Release --verbose
313360
msvc:
314361
needs: [src]
315362
runs-on: windows-2025
@@ -622,6 +669,7 @@ jobs:
622669
with:
623670
sparse-checkout: 'build-scripts/build-release.py'
624671
- name: 'Setup Android NDK'
672+
id: setup-ndk
625673
uses: nttld/setup-ndk@v1
626674
with:
627675
local-cache: false
@@ -653,6 +701,8 @@ jobs:
653701
run: |
654702
python build-scripts/build-release.py \
655703
--actions download android \
704+
--android-api 21 \
705+
--android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
656706
--commit ${{ inputs.commit }} \
657707
--root "${{ steps.tar.outputs.path }}" \
658708
--github \
@@ -718,6 +768,11 @@ jobs:
718768
run: |
719769
sudo apt-get update -y
720770
sudo apt-get install -y ninja-build
771+
- name: 'Verify alignment of libSDL3_net.so (arm64-v8a/x86_64)'
772+
run: |
773+
set -e
774+
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/arm64-v8a/libSDL3_net.so
775+
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/x86_64/libSDL3_net.so
721776
- name: 'CMake (configure + build) x86, x64, arm32, arm64'
722777
run: |
723778
android_abis="x86 x86_64 armeabi-v7a arm64-v8a"

build-scripts/build-release.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ def create_android_archives(self, android_api: int, android_home: Path, android_
10281028
# NDK 21e does not support -ffile-prefix-map
10291029
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
10301030
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
1031+
"-DANDROID_USE_LEGACY_TOOLCHAIN=0",
10311032
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
10321033
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
10331034
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
@@ -1126,8 +1127,7 @@ def download_dependencies(self):
11261127
for dep, depinfo in self.release_info.get("dependencies", {}).items():
11271128
startswith = depinfo["startswith"]
11281129
dep_repo = depinfo["repo"]
1129-
# FIXME: dropped "--exclude-pre-releases"
1130-
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
1130+
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--exclude-pre-releases", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
11311131
dep_data = json.loads(dep_string_data)
11321132
dep_tag = dep_data["tagName"]
11331133
dep_version = dep_data["name"]
@@ -1517,7 +1517,7 @@ def main(argv=None) -> int:
15171517
if args.android_home is None or not Path(args.android_home).is_dir():
15181518
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
15191519
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
1520-
parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
1520+
parser.error("Invalid $ANDROID_NDK_HOME or --android-ndk-home: must be a directory containing the Android NDK")
15211521
if args.android_api is None:
15221522
with section_printer.group("Detect Android APIS"):
15231523
args.android_api = releaser._detect_android_api(android_home=args.android_home)
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
progname="${0##*/}"
3+
progname="${progname%.sh}"
4+
5+
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk]
6+
7+
cleanup_trap() {
8+
if [ -n "${tmp}" -a -d "${tmp}" ]; then
9+
rm -rf ${tmp}
10+
fi
11+
exit $1
12+
}
13+
14+
usage() {
15+
echo "Host side script to check the ELF alignment of shared libraries."
16+
echo "Shared libraries are reported ALIGNED when their ELF regions are"
17+
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
18+
echo
19+
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
20+
}
21+
22+
if [ ${#} -ne 1 ]; then
23+
usage
24+
exit
25+
fi
26+
27+
case ${1} in
28+
--help | -h | -\?)
29+
usage
30+
exit
31+
;;
32+
33+
*)
34+
dir="${1}"
35+
;;
36+
esac
37+
38+
if ! [ -f "${dir}" -o -d "${dir}" ]; then
39+
echo "Invalid file: ${dir}" >&2
40+
exit 1
41+
fi
42+
43+
if [[ "${dir}" == *.apk ]]; then
44+
trap 'cleanup_trap' EXIT
45+
46+
echo
47+
echo "Recursively analyzing $dir"
48+
echo
49+
50+
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
51+
echo "=== APK zip-alignment ==="
52+
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
53+
echo "========================="
54+
else
55+
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
56+
echo " You can install the latest build-tools by running the below command"
57+
echo " and updating your \$PATH:"
58+
echo
59+
echo " sdkmanager \"build-tools;35.0.0-rc3\""
60+
fi
61+
62+
dir_filename=$(basename "${dir}")
63+
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
64+
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
65+
dir="${tmp}"
66+
fi
67+
68+
if [[ "${dir}" == *.apex ]]; then
69+
trap 'cleanup_trap' EXIT
70+
71+
echo
72+
echo "Recursively analyzing $dir"
73+
echo
74+
75+
dir_filename=$(basename "${dir}")
76+
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
77+
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
78+
dir="${tmp}"
79+
fi
80+
81+
RED="\e[31m"
82+
GREEN="\e[32m"
83+
ENDCOLOR="\e[0m"
84+
85+
unaligned_libs=()
86+
unaligned_critical_libs=()
87+
88+
echo
89+
echo "=== ELF alignment ==="
90+
91+
matches="$(find "${dir}" -type f)"
92+
IFS=$'\n'
93+
for match in $matches; do
94+
# We could recursively call this script or rewrite it to though.
95+
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
96+
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
97+
98+
[[ $(file "${match}") == *"ELF"* ]] || continue
99+
100+
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
101+
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
102+
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
103+
else
104+
unaligned_libs+=("${match}")
105+
# Check if this is a critical architecture (arm64-v8a or x86_64)
106+
if [[ "${match}" == *"arm64-v8a"* ]] || [[ "${match}" == *"x86_64"* ]]; then
107+
unaligned_critical_libs+=("${match}")
108+
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
109+
else
110+
echo -e "${match}: UNALIGNED ($res)"
111+
fi
112+
fi
113+
done
114+
115+
if [ ${#unaligned_libs[@]} -gt 0 ]; then
116+
echo -e "Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
117+
fi
118+
echo "====================="
119+
120+
# Exit with appropriate code: 1 if critical unaligned libs found, 0 otherwise
121+
if [ ${#unaligned_critical_libs[@]} -gt 0 ]; then
122+
echo -e "${RED}Found ${#unaligned_critical_libs[@]} critical unaligned libs.${ENDCOLOR}"
123+
exit 1
124+
else
125+
echo -e "${GREEN}ELF Verification Successful${ENDCOLOR}"
126+
exit 0
127+
fi

0 commit comments

Comments
 (0)