Skip to content

Commit

Permalink
Rive Renderer fixes on iOS/debug
Browse files Browse the repository at this point in the history
Remove a couple assertions that will never be 100% gone with floating point precision. The code that handles when these conditions are true is sound.

Don't link the release librive_pls_renderer.a into debug builds. Many classes have debug-only fields, so the debug and release binares are not compatible. Instead, strip the debug build.

Diffs=
2c2ea4492 Rive Renderer fixes on iOS/debug (#5995)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Sep 15, 2023
1 parent 469ed77 commit b1cba70
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
236d788ea3cf8f184a026a1b69c14af60003169c
2c2ea44922f91b784ec16549ce1cda0346438fd0
2 changes: 1 addition & 1 deletion .rive_renderer
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37532d9b2ca672b36968aff9435b413d846f6d23
4bc1e5c1d5af8327b4d5afc8f53afd6d0a7a7d45
39 changes: 21 additions & 18 deletions scripts/build.rive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,38 @@ build_skia_renderer_macosx() {
build_pls_renderer() {
pushd $RIVE_PLS_DIR/out
premake5 --scripts=$RIVE_RUNTIME_DIR/build --file=premake5_pls_renderer.lua --universal-release --no-rive-decoders --os=ios gmake2
make config=release clean
make config=release -j12 rive_pls_renderer
make config=$1 clean
make config=$1 -j12 rive_pls_renderer
popd

cp -r $RIVE_PLS_DIR/out/iphoneos_release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/debug/librive_pls_renderer.a
cp -r $RIVE_PLS_DIR/out/iphoneos_release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/release/librive_pls_renderer.a
cp -r $RIVE_PLS_DIR/out/iphoneos_$1/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer.a
$DEV_SCRIPT_DIR/strip_static_lib.sh $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer.a

cp -r $RIVE_PLS_DIR/include $DEV_SCRIPT_DIR/../dependencies/includes/pls
}

build_pls_renderer_sim() {
pushd $RIVE_PLS_DIR/out
premake5 --scripts=$RIVE_RUNTIME_DIR/build --file=premake5_pls_renderer.lua --universal-release --no-rive-decoders --os=ios --variant=simulator gmake2
make config=release clean
make config=release -j12 rive_pls_renderer
make config=$1 clean
make config=$1 -j12 rive_pls_renderer
popd

cp -r $RIVE_PLS_DIR/out/iphonesimulator_release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/debug/librive_pls_renderer_sim.a
cp -r $RIVE_PLS_DIR/out/iphonesimulator_release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/release/librive_pls_renderer_sim.a
cp -r $RIVE_PLS_DIR/out/iphonesimulator_$1/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer_sim.a
$DEV_SCRIPT_DIR/strip_static_lib_fat.sh $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer_sim.a arm64 x86_64

cp -r $RIVE_PLS_DIR/include $DEV_SCRIPT_DIR/../dependencies/includes/pls
}

build_pls_renderer_macosx() {
pushd $RIVE_PLS_DIR/out
premake5 --scripts=$RIVE_RUNTIME_DIR/build --file=premake5_pls_renderer.lua --universal-release --no-rive-decoders --os=macosx gmake2
make config=release clean
make config=release -j12 rive_pls_renderer
make config=$1 clean
make config=$1 -j12 rive_pls_renderer
popd

cp -r $RIVE_PLS_DIR/out/release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/debug/librive_pls_renderer_macos.a
cp -r $RIVE_PLS_DIR/out/release/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/release/librive_pls_renderer_macos.a
cp -r $RIVE_PLS_DIR/out/$1/librive_pls_renderer.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer_macos.a
$DEV_SCRIPT_DIR/strip_static_lib_fat.sh $DEV_SCRIPT_DIR/../dependencies/$1/librive_pls_renderer_macos.a arm64 x86_64

cp -r $RIVE_PLS_DIR/include $DEV_SCRIPT_DIR/../dependencies/includes/pls
}
Expand Down Expand Up @@ -159,9 +159,12 @@ all)
build_skia_renderer_sim release
build_skia_renderer_macosx debug
build_skia_renderer_macosx release
build_pls_renderer
build_pls_renderer_sim
build_pls_renderer_macosx
build_pls_renderer debug
build_pls_renderer release
build_pls_renderer_sim debug
build_pls_renderer_sim release
build_pls_renderer_macosx debug
build_pls_renderer_macosx release
;;
macosx)
if (($# < 2)); then
Expand All @@ -172,7 +175,7 @@ macosx)
make_dependency_directories
finalize_skia
build_skia_renderer_macosx $2
build_pls_renderer_macosx
build_pls_renderer_macosx $2
;;
*)
usage
Expand All @@ -188,7 +191,7 @@ ios)
make_dependency_directories
finalize_skia
build_skia_renderer $2
build_pls_renderer
build_pls_renderer $2
;;
*)
usage
Expand All @@ -204,7 +207,7 @@ ios_sim)
make_dependency_directories
finalize_skia
build_skia_renderer_sim $2
build_pls_renderer_sim
build_pls_renderer_sim $2
;;
*)
usage
Expand Down
41 changes: 41 additions & 0 deletions scripts/strip_static_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# usage: strip_static_lib.sh file.a
# Borrowed from:
# https://stackoverflow.com/questions/49630984/strip-remove-debug-symbols-and-archive-names-from-a-static-library
set -e

if [ -z "$1" ]; then
echo "usage: strip_static_lib.sh file.a"
exit 1
fi

path=$(readlink -f "${BASH_SOURCE:-$0}")
SCRIPT_DIR=$(dirname $path)
TMP_DIR="$SCRIPT_DIR/strip_static_lib_tmp"

if [ -d $TMP_DIR ]; then
rm -rf $TMP_DIR
fi

BASENAME=${1##*/}
LIB=$(realpath $1)

mkdir $TMP_DIR
cp $LIB $TMP_DIR
pushd $TMP_DIR

ar xv $BASENAME
rm -f $BASENAME
i=1000
for p in *.o ; do
strip -Sx $p -o ${i}.o
rm $p
((i++))
done

ar crus $BASENAME *.o
mv $BASENAME $LIB

popd
rm -rf $TMP_DIR
exit 0
32 changes: 32 additions & 0 deletions scripts/strip_static_lib_fat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

path=$(readlink -f "${BASH_SOURCE:-$0}")
SCRIPT_DIR=$(dirname $path)
TMP_DIR="$SCRIPT_DIR/strip_static_lib_fat_tmp"

BASENAME=${1##*/}
LIB=$(realpath $1)
shift

if [ -d $TMP_DIR ]; then
rm -rf $TMP_DIR
fi

mkdir $TMP_DIR
cp $LIB $TMP_DIR
pushd $TMP_DIR

# Extract and strip each architecture.
for ARCH in "$@"
do
lipo $BASENAME -thin $ARCH -output ${BASENAME}_${ARCH}.a
$SCRIPT_DIR/strip_static_lib.sh ${BASENAME}_${ARCH}.a
done

# Repack the stripped libs.
lipo -create ${BASENAME}_*.a -output $LIB

popd
rm -rf $TMP_DIR
exit 0

0 comments on commit b1cba70

Please sign in to comment.