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  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)
diff --git a/.rive_head b/.rive_head index 592c7e0..eaeb7d1 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -f2ecb824beea0dadfe7077accacb5cd246cac669 +a9f8a1c5d351a72b4537a6b8a27962d130f0a97c
diff --git a/build.sh b/build.sh index f6430b7..9ffdd89 100755 --- a/build.sh +++ b/build.sh
@@ -71,6 +71,14 @@ 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 ;;
diff --git a/build/premake5.lua b/build/premake5.lua index 9dc168a..ee0f2fb 100644 --- a/build/premake5.lua +++ b/build/premake5.lua
@@ -47,14 +47,25 @@ '-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 @@ '-fno-rtti' } end + filter {'system:ios', 'options:variant=system'} do buildoptions { @@ -72,6 +84,7 @@ (os.getenv('IOS_SYSROOT') or '') } end + filter {'system:ios', 'options:variant=emulator'} do buildoptions { @@ -98,11 +111,13 @@ 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 @@ 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' }
diff --git a/skia/dependencies/cache_helper.sh b/skia/dependencies/cache_helper.sh index 6688f54..8455d76 100755 --- a/skia/dependencies/cache_helper.sh +++ b/skia/dependencies/cache_helper.sh
@@ -1,5 +1,6 @@ #!/bin/bash +# make sure we stop if we encounter an error set -e # required envs
diff --git a/skia/dependencies/make_skia_ios.sh b/skia/dependencies/make_skia_ios.sh index 91a9d78..d4f8012 100755 --- a/skia/dependencies/make_skia_ios.sh +++ b/skia/dependencies/make_skia_ios.sh
@@ -8,26 +8,28 @@ 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 @@ 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 @@ ] \ 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 @@ 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 @@ 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
diff --git a/skia/dependencies/make_skia_macos.sh b/skia/dependencies/make_skia_macos.sh index 20f04da..5303a99 100755 --- a/skia/dependencies/make_skia_macos.sh +++ b/skia/dependencies/make_skia_macos.sh
@@ -10,54 +10,63 @@ 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 @@ ;; 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 @@ exit 1 esac - ninja -C out/$FOLDER + ninja -C $FOLDER cd .. } @@ -111,9 +118,9 @@ 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 .. \ No newline at end of file
diff --git a/skia/renderer/build.sh b/skia/renderer/build.sh index 82b8021..42df59c 100755 --- a/skia/renderer/build.sh +++ b/skia/renderer/build.sh
@@ -80,6 +80,14 @@ 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 ;;
diff --git a/skia/renderer/build/premake5.lua b/skia/renderer/build/premake5.lua index 2f5184f..51c3c33 100644 --- a/skia/renderer/build/premake5.lua +++ b/skia/renderer/build/premake5.lua
@@ -48,6 +48,15 @@ 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 @@ 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' }