Android builds
TODO:
- [x] update recorder to use the cache helper as well.
- [x] make sure tests are using cache on 2nd rerun
Diffs=
99b96518a remove echo & disable releases on android brielfy as i test that out in more detail
44b81e5f4 move recorder into using the cache helper
765625f99 RIVE_RUNTIME_DIR over LIBRIVE and RIVE_CPP_DIR
703afce41 repo, not dir, take 2
649e0fbd8 make sure we call the new get skia and do not use optimize
687c8e94b skia 2..
1aff4877b adding android tests & building android remotely
diff --git a/.rive_head b/.rive_head
index 067c25c..24f2dd3 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-6bafbf16778f2e31500808f603dcd57b8bd244ba
+99b96518a27fd47f231ba4bb17148ac2099e14d1
diff --git a/skia/dependencies/cache_helper.sh b/skia/dependencies/cache_helper.sh
new file mode 100755
index 0000000..1295ae4
--- /dev/null
+++ b/skia/dependencies/cache_helper.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+set -e
+
+# required envs
+RIVE_RUNTIME_DIR="${RIVE_RUNTIME_DIR:=../..}"
+SKIA_DIR_NAME="${SKIA_DIR_NAME:=skia}"
+SKIA_REPO=${SKIA_REPO:-https://github.com/rive-app/skia}
+SKIA_BRANCH=${SKIA_BRANCH:-rive}
+COMPILE_TARGET="${COMPILE_TARGET:-$(uname -s)_$(uname -m)}"
+CACHE_NAME="${CACHE_NAME:=skia}"
+OUTPUT_CACHE="${OUTPUT_CACHE:=out}"
+MAKE_SKIA_FILE="${MAKE_SKIA_FILE:=make_skia_android.sh}"
+
+# lets just make sure this exists, or fail
+if [[ ! -d $RIVE_RUNTIME_DIR ]]
+then
+ echo "Cannot find $RIVE_RUNTIME_DIR, bad setup"
+ exit 1
+fi
+
+# determeined envs
+SKIA_DEPENDENCIES_DIR="$RIVE_RUNTIME_DIR/skia/dependencies"
+SKIA_DIR="$SKIA_DEPENDENCIES_DIR/$SKIA_DIR_NAME"
+
+SKIA_COMMIT_HASH="$(git ls-remote $SKIA_REPO $SKIA_BRANCH | awk '{print $1}')"
+
+ARCHIVE_CONTENTS_NAME=archive_contents
+ARCHIVE_CONTENTS_PATH="$SKIA_DIR/$ARCHIVE_CONTENTS_NAME"
+echo $ARCHIVE_CONTENTS_PATH
+
+ARCHIVE_CONTENTS="missing"
+if test -f "$ARCHIVE_CONTENTS_PATH"; then
+ ARCHIVE_CONTENTS="$(cat $ARCHIVE_CONTENTS_PATH)"
+fi
+
+# TODO: could add OS_RELEASE in if portability is a problem
+# TODO: hmm how do we know the make skia script.. i guess its an arg? a back arg?
+if [[ $OSTYPE == 'darwin'* ]]; then
+ # md5 -r == md5sum
+ CONFIGURE_VERSION=$(md5 -r cache_helper.sh|awk '{print $1}')
+ MAKE_SKIA_HASH=$(md5 -r $SKIA_DEPENDENCIES_DIR/$MAKE_SKIA_FILE|awk '{print $1}')
+ BUILD_HASH=$(md5 -r -s "$SKIA_COMMIT_HASH $MAKE_SKIA_HASH $CONFIGURE_VERSION" | awk '{print $1}')
+else
+ CONFIGURE_VERSION=$(md5sum cache_helper.sh|awk '{print $1}')
+ MAKE_SKIA_HASH=$(md5sum $SKIA_DEPENDENCIES_DIR/$MAKE_SKIA_FILE|awk '{print $1}')
+ BUILD_HASH=$(echo "$SKIA_COMMIT_HASH $MAKE_SKIA_HASH $CONFIGURE_VERSION" | md5sum | awk '{print $1}')
+fi
+
+echo "Created hash: $BUILD_HASH from skia_commit=$SKIA_COMMIT_HASH make_skia_script=$MAKE_SKIA_HASH configure_script=$CONFIGURE_VERSION"
+
+EXPECTED_ARCHIVE_CONTENTS="$BUILD_HASH"_"$COMPILE_TARGET"
+
+ARCHIVE_FILE_NAME="$CACHE_NAME"_"$EXPECTED_ARCHIVE_CONTENTS.tar.gz"
+ARCHIVE_URL="https://cdn.2dimensions.com/archives/$ARCHIVE_FILE_NAME"
+ARCHIVE_PATH="$SKIA_DIR/$ARCHIVE_FILE_NAME"
+
+pull_cache() {
+ echo "Grabbing cached build from $ARCHIVE_URL"
+ mkdir -p $SKIA_DIR
+ curl --output $SKIA_DIR/$ARCHIVE_FILE_NAME $ARCHIVE_URL
+ pushd $SKIA_DIR
+ tar -xf $ARCHIVE_FILE_NAME out include archive_contents third_party
+}
+
+is_build_cached_remotely() {
+ echo "Checking for cache build $ARCHIVE_URL"
+ if curl --output /dev/null --head --silent --fail $ARCHIVE_URL
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
+upload_cache() {
+ pushd $SKIA_DEPENDENCIES_DIR
+ echo $EXPECTED_ARCHIVE_CONTENTS > $SKIA_DIR_NAME/$ARCHIVE_CONTENTS_NAME
+ # not really sure about this third party biz
+ # also we are caching on a per architecture path here, but out could contain more :thinking:
+ tar -C $SKIA_DIR_NAME -cf $SKIA_DIR_NAME/$ARCHIVE_FILE_NAME $OUTPUT_CACHE $ARCHIVE_CONTENTS_NAME include third_party/libpng third_party/externals/libpng
+ popd
+ # # if we're configured to upload the archive back into our cache, lets do it!
+ echo "Uploading to s3://2d-public/archives/$ARCHIVE_FILE_NAME"
+ ls $ARCHIVE_PATH
+ aws s3 cp $ARCHIVE_PATH s3://2d-public/archives/$ARCHIVE_FILE_NAME
+}
+
+
+
+is_build_cached_locally() {
+ if [ "$EXPECTED_ARCHIVE_CONTENTS" == "$ARCHIVE_CONTENTS" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
\ No newline at end of file
diff --git a/skia/dependencies/get_skia2.sh b/skia/dependencies/get_skia2.sh
new file mode 100755
index 0000000..3172789
--- /dev/null
+++ b/skia/dependencies/get_skia2.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+set -e
+
+# Requires depot_tools and git:
+# https://skia.org/user/download
+# Build notes:
+# https://skia.org/user/build
+# GLFW requires CMake
+
+SKIA_REPO="${SKIA_REPO:-https://github.com/rive-app/skia}"
+SKIA_BRANCH="${SKIA_BRANCH:-rive}"
+
+# note: we have imports in recorder that rely on this being "skia"
+# either: change that in recorder, or check out skia into a subfolder
+# both have consequences.
+SKIA_DIR_NAME="${SKIA_DIR_NAME:-skia}"
+
+_skiaExists() {
+ if test -d $SKIA_DIR_NAME/.git; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+_skiaHasExpectedRemote() {
+ if test -d $SKIA_DIR_NAME/.git; then
+ pushd $SKIA_DIR_NAME
+ if git remote -v |grep "$SKIA_REPO"; then
+ popd
+ return 0
+ else
+ popd
+ echo "Skia it is using the wrong remote."
+ return 1
+ fi
+ else
+ echo "Skia is expected to be a git repo"
+ return 1
+ fi
+}
+
+_updateSkia() {
+ pushd $SKIA_DIR_NAME
+ git fetch && git pull
+ popd
+}
+
+_cloneSkia() {
+ echo "Cloning Skia [$SKIA_REPO : $SKIA_BRANCH] into $SKIA_DIR_NAME."
+ git clone $SKIA_REPO $SKIA_DIR_NAME
+}
+
+_removeSkia(){
+ echo "Removing skia folder."
+ rm -rf $SKIA_DIR_NAME
+}
+
+getSkia () {
+ # -----------------------------
+ # Get Skia:
+ # -----------------------------
+ if _skiaExists; then
+ if _skiaHasExpectedRemote; then
+ _updateSkia
+ else
+ _removeSkia
+ _cloneSkia
+ fi
+ else
+ _removeSkia
+ _cloneSkia
+ fi
+
+ pushd $SKIA_DIR_NAME
+
+ echo "Checking out branch $SKIA_BRANCH"
+ git checkout $SKIA_BRANCH
+ python tools/git-sync-deps
+
+ popd
+}
\ No newline at end of file
diff --git a/skia/dependencies/make_skia_android.sh b/skia/dependencies/make_skia_android.sh
new file mode 100755
index 0000000..e5ca2f3
--- /dev/null
+++ b/skia/dependencies/make_skia_android.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+set -ex
+
+source ./get_skia2.sh
+source ./cache_helper.sh
+
+ARCH=$1
+CONFIG=$2
+
+build_skia_android() {
+ cd $SKIA_DIR_NAME
+
+ if [ "$ARCH" != "x86" ] &&
+ [ "$ARCH" != "x64" ] &&
+ [ "$ARCH" != "arm" ] &&
+ [ "$ARCH" != "arm64" ]; then
+ printf "Invalid architecture: '%s'. Choose one between 'x86', \
+ 'x64', \
+ 'arm', \
+ or 'arm64'" "$ARCH"
+ exit 1
+ fi
+
+ BUILD_FLAGS=
+ EXTRA_CFLAGS=
+ if [ "$CONFIG" = "debug" ]; then
+ BUILD_FLAGS="is_official_build=false is_debug=true skia_enable_tools=false"
+ else # release
+ BUILD_FLAGS="is_official_build=true is_debug=false"
+ EXTRA_CFLAGS="\
+ \"-fno-rtti\", \
+ \"-flto=full\", \
+ \"-fembed-bitcode\", \
+ \"-DRIVE_OPTIMIZED\", \
+ \"-DSK_DISABLE_SKPICTURE\", \
+ \"-DSK_DISABLE_TEXT\", \
+ \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \
+ \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \
+ \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \
+ \"-DSK_DISABLE_AAA\", \
+ \"-DSK_DISABLE_EFFECT_DESERIALIZATION\" \
+ "
+ fi
+
+ # Useful for debugging:
+ # bin/gn args --list out/${ARCH}
+
+ bin/gn gen out/"${CONFIG}"/"${ARCH}" --args=" \
+ ndk=\"${NDK_PATH}\" \
+ target_cpu=\"${ARCH}\" \
+ extra_cflags=[ \
+ ${EXTRA_CFLAGS} \
+ ] \
+ \
+ ${BUILD_FLAGS} \
+
+ skia_gl_standard=\"gles\"
+ skia_use_zlib=true \
+ skia_use_egl=true \
+ skia_use_gl=true \
+ skia_enable_gpu=true \
+ skia_use_libpng_decode=true \
+ skia_use_libpng_encode=true \
+
+ skia_use_angle=false \
+ skia_use_dng_sdk=false \
+
+ skia_use_expat=false \
+ skia_use_fontconfig=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=true \
+ skia_use_libwebp_encode=false \
+ skia_use_libwebp_decode=false \
+ skia_use_lua=false \
+ skia_use_piex=false \
+ skia_use_vulkan=false \
+
+ skia_use_system_zlib=false \
+ skia_enable_fontmgr_empty=false \
+ skia_enable_spirv_validation=false \
+ skia_enable_pdf=false \
+ skia_enable_skottie=false \
+ "
+
+ ninja -C out/"${CONFIG}"/"${ARCH}"
+ cd ..
+}
+
+if is_build_cached_locally; then
+ echo "Build is cached, nothing to do."
+else
+ if is_build_cached_remotely; then
+ pull_cache
+ else
+ getSkia
+ build_skia_android
+ # hmm not the appiest with this guy
+ OUTPUT_CACHE=out/release/$ARCH upload_cache
+ fi
+fi
\ No newline at end of file
diff --git a/skia/dependencies/make_skia_recorder.sh b/skia/dependencies/make_skia_recorder.sh
index 9f14a9a..0cd348b 100755
--- a/skia/dependencies/make_skia_recorder.sh
+++ b/skia/dependencies/make_skia_recorder.sh
@@ -1,82 +1,71 @@
#!/bin/bash
set -ex
-SKIA_REPO=https://github.com/rive-app/skia
-SKIA_BRANCH=rive
-SKIA_DIR=${SKIA_DIR:-skia}
+source ./get_skia2.sh
+source ./cache_helper.sh
-# -----------------------------
-# Get & Build Skia
-# -----------------------------
-if test -d $SKIA_DIR/.git; then
- echo "Skia Recorder is a .git repo"
+build_skia_recorder() {
+ cd $SKIA_DIR_NAME
+
+ bin/gn gen out/static --args=" \
+ is_official_build=true \
+ extra_cflags=[
+ \"-fno-rtti\",\
+ \"-DSK_DISABLE_SKPICTURE\",\
+ \"-DSK_DISABLE_TEXT\",\
+ \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\",\
+ \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\",\
+ \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\",\
+ \"-DSK_DISABLE_AAA\",\
+ \"-DSK_DISABLE_EFFECT_DESERIALIZATION\"\
+ ] \
+ rive_use_picture=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_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=true \
+ skia_use_libwebp_encode=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=false \
+ skia_use_gl=true \
+ skia_use_zlib=true \
+ skia_use_system_zlib=false \
+ skia_enable_gpu=true \
+ skia_enable_fontmgr_empty=true \
+ skia_enable_spirv_validation=false \
+ skia_enable_pdf=false \
+ skia_use_libpng_encode = true \
+ skia_use_libpng_decode = true \
+ skia_enable_skottie = false \
+ skia_enable_tools = false \
+ skia_enable_skgpu_v1 = true \
+ skia_enable_skgpu_v2 = false \
+ "
+ ninja -C out/static
+
+ cd ..
+}
+
+if is_build_cached_locally; then
+ echo "Build is cached, nothing to do."
else
- echo "Skia Recorder is not a .git repo, probably a cache, cleaning it out"
- rm -rf $SKIA_DIR
-fi
-
-if [ ! -d $SKIA_DIR ]; then
- echo "Cloning Skia recorder."
- git clone -j8 $SKIA_REPO $SKIA_DIR
- cd $SKIA_DIR
- git checkout $SKIA_BRANCH
-else
- echo "Already have Skia recorder, update it."
- cd $SKIA_DIR
- git checkout $SKIA_BRANCH
- git fetch
- git pull
-fi
-
-python tools/git-sync-deps
-
-bin/gn gen out/static --args=" \
- is_official_build=true \
- extra_cflags=[
- \"-fno-rtti\",\
- \"-DSK_DISABLE_SKPICTURE\",\
- \"-DSK_DISABLE_TEXT\",\
- \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\",\
- \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\",\
- \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\",\
- \"-DSK_DISABLE_AAA\",\
- \"-DSK_DISABLE_EFFECT_DESERIALIZATION\"\
- ] \
- rive_use_picture=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_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=true \
- skia_use_libwebp_encode=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=false \
- skia_use_gl=true \
- skia_use_zlib=true \
- skia_use_system_zlib=false \
- skia_enable_gpu=true \
- skia_enable_fontmgr_empty=true \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_use_libpng_encode = true \
- skia_use_libpng_decode = true \
- skia_enable_skottie = false \
- skia_enable_tools = false \
- skia_enable_skgpu_v1 = true \
- skia_enable_skgpu_v2 = false \
- "
-ninja -C out/static
-du -hs out/static/libskia.a
-
-cd ..
+ if is_build_cached_remotely; then
+ pull_cache
+ else
+ getSkia
+ build_skia_recorder
+ OUTPUT_CACHE=out upload_cache
+ fi
+fi
\ No newline at end of file
diff --git a/skia/renderer/build.sh b/skia/renderer/build.sh
index 90232c2..147a6da 100755
--- a/skia/renderer/build.sh
+++ b/skia/renderer/build.sh
@@ -37,7 +37,7 @@
help
else
build() {
- echo "Building Rive for platform=$platform option=$OPTION"
+ echo "Building Rive Renderer for platform=$platform option=$OPTION"
PREMAKE="premake5 gmake2 $1"
eval "$PREMAKE"
if [ "$OPTION" = "clean" ]; then
@@ -76,4 +76,4 @@
esac
fi
-popd &>/dev/null
+popd &>/dev/null
\ No newline at end of file
diff --git a/skia/renderer/build/premake5.lua b/skia/renderer/build/premake5.lua
index ac90f28..c1f7051 100644
--- a/skia/renderer/build/premake5.lua
+++ b/skia/renderer/build/premake5.lua
@@ -61,27 +61,27 @@
-- Is there a way to pass 'arch' as a variable here?
filter { "system:android" }
- includedirs {"../../dependencies/skia_rive_optimized"}
+ includedirs {"../../dependencies/".. SKIA_DIR}
filter { "system:android", "options:arch=x86" }
targetdir "%{cfg.system}/x86/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/x86/obj/%{cfg.buildcfg}"
- libdirs {"../../dependencies/skia_rive_optimized/out/x86"}
+ libdirs {"../../dependencies/" .. SKIA_DIR.. "/out/x86"}
filter { "system:android", "options:arch=x64" }
targetdir "%{cfg.system}/x64/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/x64/obj/%{cfg.buildcfg}"
- libdirs {"../../dependencies/skia_rive_optimized/out/x64"}
+ libdirs {"../../dependencies/" .. SKIA_DIR.. "/out/x64"}
filter { "system:android", "options:arch=arm" }
targetdir "%{cfg.system}/arm/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/arm/obj/%{cfg.buildcfg}"
- libdirs {"../../dependencies/skia_rive_optimized/out/arm"}
+ libdirs {"../../dependencies/" .. SKIA_DIR.. "/out/arm"}
filter { "system:android", "options:arch=arm64" }
targetdir "%{cfg.system}/arm64/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/arm64/obj/%{cfg.buildcfg}"
- libdirs {"../../dependencies/skia_rive_optimized/out/arm64"}
+ libdirs {"../../dependencies/" .. SKIA_DIR.. "/out/arm64"}
filter "configurations:debug"
defines {"DEBUG"}
@@ -113,4 +113,4 @@
{ "arm64" }
}
-}
+}
\ No newline at end of file