Build on Linux: compile locally, link/sign on the iPhone; FFmpeg audio decoders; SDK stub patching
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
8e6f8a86a4
commit
66f4e7e3ea
1 changed files with 700 additions and 48 deletions
42
build.sh
42
build.sh
|
|
@ -23,19 +23,43 @@ mkdir -p "$APPEX" "$OUT/obj"
|
|||
OPT=(-O -wmo)
|
||||
[ "$CONFIG" = debug ] && OPT=(-Onone -g)
|
||||
|
||||
common=(-target "$TARGET" -sdk "$SDK" -swift-version 5 "${OPT[@]}"
|
||||
-use-ld=lld -Xlinker -dead_strip
|
||||
-Xcc -Wno-unused-command-line-argument)
|
||||
RES=${RES:-$HOME/.local/opt/swift-ios-res} # toolchain resources minus the Linux-only module maps
|
||||
common=(-target "$TARGET" -sdk "$SDK" -resource-dir "$RES" -swift-version 5 "${OPT[@]}" -Xcc -Wno-unused-command-line-argument)
|
||||
# Links on the phone; when the repacked SDK's stubs lack symbols, look them up on the device, patch, retry.
|
||||
link() {
|
||||
local log=$OUT/link.log
|
||||
if tools/phone-ld "$@" 2> "$log"; then return 0; fi
|
||||
if grep -q 'symbol(s) not found' "$log"; then
|
||||
echo " resolving missing SDK symbols on the device…"
|
||||
tools/resolve-undefined "$log"
|
||||
tools/phone-ld "$@" && return 0
|
||||
fi
|
||||
cat "$log" >&2
|
||||
return 1
|
||||
}
|
||||
LD=link
|
||||
"$SWIFT/clang" -target "$TARGET" -isysroot "$SDK" -O2 -c Native/compat.c -o "$OUT/obj/compat.o"
|
||||
|
||||
# FFmpeg for the extra formats, when Native/build-ffmpeg.sh has been run.
|
||||
ff=()
|
||||
fflibs=()
|
||||
if [ -f Native/ffmpeg/lib/libavformat.a ]; then
|
||||
"$SWIFT/clang" -target "$TARGET" -isysroot "$SDK" -O2 -INative/ffmpeg/include -c Native/ffdecode.c -o "$OUT/obj/ffdecode.o"
|
||||
ff=(-D MULBERRY_FFMPEG -import-objc-header Native/ffdecode.h)
|
||||
fflibs=("$OUT/obj/ffdecode.o" Native/ffmpeg/lib/libavformat.a Native/ffmpeg/lib/libavcodec.a
|
||||
Native/ffmpeg/lib/libswresample.a Native/ffmpeg/lib/libavutil.a -lz -lbz2 -liconv
|
||||
-framework AudioToolbox -framework CoreFoundation -framework CoreMedia -framework CoreVideo -framework Security -framework VideoToolbox)
|
||||
fi
|
||||
|
||||
echo "== app"
|
||||
"$SWIFT/swiftc" "${common[@]}" -module-name Mulberry \
|
||||
$(find App Shared -name '*.swift' | sort) \
|
||||
-o "$APP/Mulberry"
|
||||
"$SWIFT/swiftc" "${common[@]}" "${ff[@]}" -module-name Mulberry -c -wmo -num-threads 0 \
|
||||
$(find App Shared -name '*.swift' | sort) -o "$OUT/obj/Mulberry.o"
|
||||
$LD -dead_strip -o "$APP/Mulberry" "$OUT/obj/Mulberry.o" "$OUT/obj/compat.o" "${fflibs[@]}"
|
||||
|
||||
echo "== widget extension"
|
||||
"$SWIFT/swiftc" "${common[@]}" -module-name MulberryWidgets -application-extension \
|
||||
$(find Widget Shared -name '*.swift' | sort) \
|
||||
-o "$APPEX/MulberryWidgets"
|
||||
"$SWIFT/swiftc" "${common[@]}" -module-name MulberryWidgets -application-extension -c -wmo -num-threads 0 \
|
||||
$(find Widget Shared -name '*.swift' | sort) -o "$OUT/obj/MulberryWidgets.o"
|
||||
$LD -dead_strip -application-extension -o "$APPEX/MulberryWidgets" "$OUT/obj/MulberryWidgets.o" "$OUT/obj/compat.o"
|
||||
|
||||
echo "== bundle"
|
||||
sed -e "s/@VERSION@/$VERSION/" -e "s/@BUILD@/$BUILD/" Resources/Info.plist > "$APP/Info.plist"
|
||||
|
|
|
|||
Loading…
Reference in a new issue