Macos take2

draft because i need to get a todo list together.

Adds macos as a target for our ios runtime! Also adds a macos target for our example (which is a different app completely, very minimalistic right now).

<img width="331" alt="CleanShot 2023-05-17 at 20 32 45@2x" src="https://github.com/rive-app/rive/assets/1216025/7a6cadce-9763-41a3-b1a0-6d067dfc3eca">

macos, macos rosetta, macos (designed for ipad), and ios  all co existing in peace, from the same runtime project

![CleanShot 2023-05-17 at 18 32 04@2x](https://github.com/rive-app/rive/assets/1216025/eead319d-a16b-4098-a7db-d5f033b1ef8f)

todo:
- [x] update build scripts to build supporting macos (gotta do this)
- [x] run formatter
- [x] test out builds in forked version of ios? (gotta do this)
- [ ] one more stab at catalyst? (i think we can try that later...)
- [ ] do we need a more comprehensive example setup for macos (I think we can do this later & try to pull zach's examples in)
- [ ] I think we should restructure the ios project, but i think we can do that after this as well (i just think the folder structure/project structure can do with some work, now that we add macos (and should make room for tvos as well)
- [x] probably got tests to fix
- [ ] there's probably a bunch of looking at errors in the debugger and figuring those out, but i would hope that we can deploy with some warnings here too.

catalyst problem:

we get this error:
and the problem is basically that we can target a specific library for macos, but we need one for macos and one for macos catalyst. they share the same architecture, so i dont think we can lipo them into one file...

we could change the compiled binaries before creating the frameworks I guess though? .. maybe something to try..

`/Users/maxwelltalbot/development/rive/rive/packages/runtime_ios/dependencies/debug/librive_skia_renderer_macos.a(cg_factory.o), building for Mac Catalyst, but linking in object file built for macOS, file '/Users/maxwelltalbot/development/rive/rive/packages/runtime_ios/dependencies/debug/librive_skia_renderer_macos.a' for architecture arm64` basically

Diffs=
a9f8a1c5d Macos take2 (#5258)
This commit is contained in:
mjtalbot
2023-05-24 11:14:25 +00:00
parent 2121cdcbc1
commit 73fac9a837
8 changed files with 91 additions and 37 deletions

View File

@@ -1 +1 @@
f2ecb824beea0dadfe7077accacb5cd246cac669
a9f8a1c5d351a72b4537a6b8a27962d130f0a97c

View File

@@ -71,6 +71,14 @@ else
ARCH=${strarr[1]}
build "--os=android --arch=${ARCH}"
;;
macosx)
echo "Building for macos"
export MACOS_SYSROOT=$(xcrun --sdk macosx --show-sdk-path)
build "--os=macosx --variant=runtime"
if [ "$OPTION" = "clean" ]; then
exit
fi
;;
*)
build
;;

View File

@@ -47,14 +47,25 @@ do
'-Wimplicit-float-conversion'
}
end
filter {'system:macosx', 'options:variant=runtime'}
do
buildoptions {
'-Wimplicit-float-conversion -fembed-bitcode -arch arm64 -arch x86_64 -isysroot ' ..
(os.getenv('MACOS_SYSROOT') or '')
}
end
filter {'system:macosx', 'configurations:release'}
do
buildoptions {'-flto=full'}
end
filter {'system:ios'}
do
buildoptions {'-flto=full'}
end
filter 'system:windows'
do
architecture 'x64'
@@ -65,6 +76,7 @@ do
'-fno-rtti'
}
end
filter {'system:ios', 'options:variant=system'}
do
buildoptions {
@@ -72,6 +84,7 @@ do
(os.getenv('IOS_SYSROOT') or '')
}
end
filter {'system:ios', 'options:variant=emulator'}
do
buildoptions {
@@ -98,11 +111,13 @@ do
targetdir '%{cfg.system}/x64/bin/%{cfg.buildcfg}'
objdir '%{cfg.system}/x64/obj/%{cfg.buildcfg}'
end
filter {'system:android', 'options:arch=arm'}
do
targetdir '%{cfg.system}/arm/bin/%{cfg.buildcfg}'
objdir '%{cfg.system}/arm/obj/%{cfg.buildcfg}'
end
filter {'system:android', 'options:arch=arm64'}
do
targetdir '%{cfg.system}/arm64/bin/%{cfg.buildcfg}'
@@ -134,7 +149,8 @@ newoption {
description = 'Choose a particular variant to build',
allowed = {
{'system', 'Builds the static library for the provided system'},
{'emulator', 'Builds for an emulator/simulator for the provided system'}
{'emulator', 'Builds for an emulator/simulator for the provided system'},
{'runtime', 'Build the static library specifically targeting our runtimes'}
},
default = 'system'
}

View File

@@ -1,5 +1,6 @@
#!/bin/bash
# make sure we stop if we encounter an error
set -e
# required envs

View File

@@ -8,26 +8,28 @@ source ./cache_helper.sh
build_skia_ios(){
cd $SKIA_DIR_NAME
BASE=out/ios
case $1 in
arm64)
ARCH=arm64
FOLDER=arm64
FOLDER=$BASE/arm64
;;
arm)
ARCH=arm
FOLDER=arm
FOLDER=$BASE/arm
;;
x86)
ARCH=x86
FOLDER=x86
FOLDER=$BASE/x86
;;
x64)
ARCH=x64
FOLDER=x64
FOLDER=$BASE/x64
;;
iossim_arm64)
ARCH=arm64
FOLDER=iossim_arm64
FOLDER=$BASE/iossim_arm64
EXTRA_CFLAGS=", \"--target=arm64-apple-ios12.0.0-simulator\""
EXTRA_LDLAGS="\"--target=arm64-apple-ios12.0.0-simulator\""
;;
@@ -35,9 +37,10 @@ build_skia_ios(){
echo "Do not know build configuration for $1"
exit 1
esac
# use Rive optimized/stripped Skia for iOS static libs.
bin/gn gen out/$FOLDER --type=static_library --args=" \
bin/gn gen $FOLDER --type=static_library --args=" \
target_os=\"ios\" \
target_cpu=\"$ARCH\" \
extra_cflags=[ \
@@ -61,7 +64,7 @@ build_skia_ios(){
] \
is_official_build=true \
skia_use_freetype=true \
skia_use_freetype=false \
skia_use_metal=true \
skia_use_zlib=true \
skia_enable_gpu=true \
@@ -93,9 +96,10 @@ build_skia_ios(){
skia_enable_spirv_validation=false \
skia_enable_pdf=false \
skia_enable_skottie=false \
skia_enable_tools=false \
$OVERRIDES
"
ninja -C out/$FOLDER
ninja -C $FOLDER
cd ..
}
@@ -108,7 +112,7 @@ else
getSkia
build_skia_ios $1
# hmm not the appiest with this guy
OUTPUT_CACHE=out/$FOLDER upload_cache
OUTPUT_CACHE=$FOLDER upload_cache
fi
fi

View File

@@ -10,54 +10,63 @@ build_skia_macos(){
cd $SKIA_DIR_NAME
local SHARED_EXTRA_CFLAGS="\
\"-fno-rtti\", \
\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \
\"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \
\"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \
\"-DSK_DISABLE_AAA\", \
\"-DSK_DISABLE_EFFECT_DESERIALIZATION\" \
\"-fno-rtti\", \
\"-fembed-bitcode\", \
\"-flto=full\", \
\"-DSK_DISABLE_SKPICTURE\", \
\"-DSK_DISABLE_TEXT\", \
\"-DRIVE_OPTIMIZED\", \
\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \
\"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \
\"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \
\"-DSK_DISABLE_AAA\", \
\"-DSK_DISABLE_EFFECT_DESERIALIZATION\" \
"
local SHARED_ARGS="\
is_official_build=true \
skia_use_gl=true \
skia_use_freetype=false \
skia_use_metal=true \
skia_use_zlib=true \
skia_enable_gpu=true \
skia_enable_fontmgr_empty=false \
skia_use_libpng_encode=true \
skia_use_libpng_decode=true \
skia_enable_skgpu_v1=true \
skia_skip_codesign=true \
skia_use_angle=false \
skia_use_dng_sdk=false \
skia_use_egl=false \
skia_use_expat=false \
skia_use_fontconfig=false \
skia_use_freetype=false \
skia_use_system_freetype2=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
skia_use_libjpeg_turbo_decode=false \
skia_use_libjpeg_turbo_decode=true \
skia_use_libwebp_encode=false \
skia_use_libwebp_decode=false \
skia_use_libwebp_decode=true \
skia_use_system_libwebp=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_metal=true \
skia_use_angle=false \
skia_use_gl=false \
skia_use_system_zlib=false \
skia_enable_fontmgr_empty=false \
skia_enable_spirv_validation=false \
skia_enable_pdf=false \
skia_enable_skottie=false \
skia_enable_tools=false \
"
BASE=out/macosx
case $1 in
arm64)
ARCH=arm64
FOLDER=arm64
FOLDER=$BASE/arm64
# use Rive optimized/stripped Skia for macOS static libs.
bin/gn gen out/$FOLDER --type=static_library --args=" \
bin/gn gen $FOLDER --type=static_library --args=" \
target_os=\"mac\" \
target_cpu=\"arm64\" \
extra_cflags=[ \
@@ -68,15 +77,13 @@ build_skia_macos(){
;;
x64)
ARCH=x64
FOLDER=x64
FOLDER=$BASE/x64
bin/gn gen out/$FOLDER --type=static_library --args=" \
bin/gn gen $FOLDER --type=static_library --args=" \
target_os=\"mac\" \
target_cpu=\"x64\" \
extra_cflags=[ \
\"--target=x86_64-apple-macos10.12\", \
\"-fno-rtti\", \
\"-fno-rtti\", \
${SHARED_EXTRA_CFLAGS}
] \
extra_asmflags = [ \
@@ -99,7 +106,7 @@ build_skia_macos(){
exit 1
esac
ninja -C out/$FOLDER
ninja -C $FOLDER
cd ..
}
@@ -111,9 +118,9 @@ else
else
getSkia
build_skia_macos $1
# hmm not the appiest with this guy
OUTPUT_CACHE=out/$FOLDER upload_cache
# hmm not the happiest with this guy
OUTPUT_CACHE=$FOLDER upload_cache
fi
fi
cd ..
cd ..

View File

@@ -80,6 +80,14 @@ else
ARCH=${strarr[1]}
build "--os=android --arch=${ARCH}"
;;
macosx)
echo "Building for macos"
export MACOS_SYSROOT=$(xcrun --sdk macosx --show-sdk-path)
build "--os=macosx --variant=runtime"
if [ "$OPTION" = "clean" ]; then
exit
fi
;;
*)
build
;;

View File

@@ -48,6 +48,15 @@ do
links {'Cocoa.framework', 'rive', 'skia'}
end
filter {'system:macosx', 'options:variant=runtime'}
do
links {}
buildoptions {
'-fembed-bitcode -arch arm64 -arch x86_64 -isysroot ' ..
(os.getenv('MACOS_SYSROOT') or '')
}
end
filter {'system:linux or windows'}
do
includedirs {SKIA_DIR}
@@ -158,7 +167,8 @@ newoption {
description = 'Choose a particular variant to build',
allowed = {
{'system', 'Builds the static library for the provided system'},
{'emulator', 'Builds for an emulator/simulator for the provided system'}
{'emulator', 'Builds for an emulator/simulator for the provided system'},
{'runtime', 'Build the static library specifically targeting our runtimes'}
},
default = 'system'
}