adding all the updates to make ios build from the mono repo, and push…

… downstream

just tagging you all for visibility  will pepper a few comments in here and hit merge....

Diffs=
90e1d4cf7 renamed release script to releaase & removed unused scripts
418044ebf updates to renderer build defines
a1af986be adding all the updates to make ios build from the mono repo, and push downstream
This commit is contained in:
mjtalbot
2022-07-07 12:54:17 +00:00
parent 2f137326f8
commit 57086995d6
12 changed files with 351 additions and 282 deletions

View File

@@ -2,15 +2,61 @@ name: Create a Release
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
inputs:
major:
description: 'Major'
type: boolean
default: false
minor:
description: 'Minor'
type: boolean
default: false
jobs:
build-skia:
strategy:
matrix:
arch: ["x86" , "x64", "arm", "arm64", "iossim_arm64"]
runs-on: macos-12
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.ACTIONS_ROLE }}
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}
- name: Update Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '16'
- name: Installing pre-requisites
run: |
set -x
# Install some dependencies & premake5
brew install ninja
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-macosx.tar.gz
tar -xf premake-5.0.0-beta1-macosx.tar.gz
mkdir bin
cp premake5 bin/premake5
sudo chmod a+x premake5
sudo mv premake5 /usr/local/bin
- name: Build skia files
run: ./scripts/build.skia.sh -a ${{ matrix.arch }}
determine_version:
name: Determine the next build version
if: github.event.pull_request.merged == true
needs: build-skia
runs-on: ubuntu-latest
outputs:
version: ${{ steps.echo_version.outputs.version }}
@@ -25,27 +71,37 @@ jobs:
run: npm run release -- --ci --release-version | tail -n 1 > RELEASE_VERSION
working-directory: ./.github/release
env:
GITHUB_TOKEN: ${{ secrets.RIVE_REPO_PAT }}
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
- id: echo_version
run: echo "::set-output name=version::$(cat ./.github/release/RELEASE_VERSION)"
build_framework:
name: Create RiveRuntime.xcframework
if: github.event.pull_request.merged == true
runs-on: macos-12
needs: [determine_version]
outputs:
checksum: ${{steps.get_checksum.outputs.checksum}}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.RIVE_REPO_PAT }}
submodules: recursive
- name: Init submodule
run: git submodule update --init
- name: Configure Skia
run: sh ./scripts/configure.sh
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}
- name: Copy build files
run: ./scripts/copy.build.files.sh
- name: Installing pre-requisites
run: |
set -x
# Install some dependencies & premake5
brew install ninja
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-macosx.tar.gz
tar -xf premake-5.0.0-beta1-macosx.tar.gz
mkdir bin
cp premake5 bin/premake5
sudo chmod a+x premake5
sudo mv premake5 /usr/local/bin
- name: Build everything (using the cache, we should make an archive of course)
run: ./scripts/build.sh all
- name: Update Marketing versions
run: agvtool new-marketing-version ${{ needs.determine_version.outputs.version }}
- name: Upload versionFiles
@@ -88,12 +144,11 @@ jobs:
do_release:
name: Do the actual release
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: [determine_version, build_framework]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
@@ -145,11 +200,24 @@ jobs:
with:
name: RiveRuntime.xcframework.zip
path: archive/
- name: Bump version number, update changelog, push and tag
- if : ${{ inputs.major == true }}
name: Major Release - Bump version number, update changelog, push and tag
run: npm run release -- major --ci
working-directory: ./.github/release
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
- if : ${{inputs.major == false && inputs.minor == true}}
name: Minor release - Bump version number, update changelog, push and tag
run: npm run release -- minor --ci
working-directory: ./.github/release
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
- if : ${{inputs.major == false && inputs.minor == false}}
name: Build release - Bump version number, update changelog, push and tag
run: npm run release -- --ci
working-directory: ./.github/release
env:
GITHUB_TOKEN: ${{ secrets.RIVE_REPO_PAT }}
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
publish_cocoapods:
name: Publish framework to cocoapods

View File

@@ -1,97 +0,0 @@
name: Build test pod
on: workflow_dispatch
jobs:
create_podspec_file:
name: Create RiveRuntime.podspec
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Read podspec.txt file
uses: pCYSl5EDgo/cat@master
id: podspec
with:
path: .github/workflows/podspec.txt
- name: Create *.podspec
run: |
cat > RiveRuntime.podspec <<-EOF
${{ steps.podspec.outputs.text }}
EOF
env:
GITHUB_AUTHOR: ${{ github.actor }}
RELEASE_VERSION: 0.0.1
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: RiveRuntime.podspec
path: RiveRuntime.podspec
build_framework:
name: Create RiveRuntime.xcframework
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.RIVE_REPO_PAT }}
submodules: recursive
- name: Init submodule
run: git submodule update --init
- id: build_iphoneos
name: Build release iphoneos framework
run: sh ./scripts/build_framework.sh -t iphoneos -c Release
- id: build_iphonesimulator
name: Build release iphonesimulator framework
run: sh ./scripts/build_framework.sh -t iphonesimulator -c Release
- id: merge_frameworks
if: steps.build_iphoneos.conclusion == 'success' && steps.build_iphonesimulator.conclusion == 'success'
name: Merge created frameworks
run: sh ./scripts/merge_framework.sh -c Release
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: RiveRuntime.xcframework
path: archive/RiveRuntime.xcframework
build_pod:
name: Update podspec repository
runs-on: macos-12
timeout-minutes: 10
needs: [create_podspec_file, build_framework]
steps:
- name: Checkout podspec repo
uses: actions/checkout@v2
with:
repository: rive-app/test-ios
token: ${{ secrets.RIVE_REPO_PAT }}
- name: Clean
run: |
rm -rf RiveRuntime.podspec
rm -rf RiveRuntime.xcframework
- name: Download framework artifact
uses: actions/download-artifact@v2
with:
name: RiveRuntime.xcframework
path: RiveRuntime.xcframework
- name: Download podspec artifact
uses: actions/download-artifact@v2
with:
name: RiveRuntime.podspec
- name: Lint pod
run: pod lib lint --allow-warnings
- name: Push pod to test-ios repo
run: |
git status
git config --local user.email 'hello@rive.app'
git config --local user.name ${{ github.actor }}
git add .
git commit -m "Update podspec repo tag:${{ env.RELEASE_VERSION }}"
git push
git tag v${{ env.RELEASE_VERSION }}
git push origin v${{ env.RELEASE_VERSION }}
env:
API_TOKEN_GITHUB: ${{ secrets.RIVE_REPO_PAT }}
RELEASE_VERSION: 0.0.1

View File

@@ -2,18 +2,74 @@ name: Run Rive tests
on:
push:
branches:
- main
jobs:
build-skia:
strategy:
matrix:
arch: ["x86" , "x64", "arm", "arm64", "iossim_arm64"]
runs-on: macos-12
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.ACTIONS_ROLE }}
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}
- name: Update Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '16'
- name: Installing pre-requisites
run: |
set -x
# Install some dependencies & premake5
brew install ninja
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-macosx.tar.gz
tar -xf premake-5.0.0-beta1-macosx.tar.gz
mkdir bin
cp premake5 bin/premake5
sudo chmod a+x premake5
sudo mv premake5 /usr/local/bin
- name: Build skia files
run: ./scripts/build.skia.sh -a ${{ matrix.arch }}
run_tests:
name: Run Rive tests
needs: build-skia
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.RIVE_REPO_PAT }}
submodules: recursive
- name: Get Skia Headers
run: sh ./scripts/configure.sh
token: ${{ secrets.PAT_GITHUB }}
submodules: true
- name: Installing pre-requisites
run: |
set -x
# Install some dependencies & premake5
brew install ninja
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-macosx.tar.gz
tar -xf premake-5.0.0-beta1-macosx.tar.gz
mkdir bin
cp premake5 bin/premake5
sudo chmod a+x premake5
sudo mv premake5 /usr/local/bin
- name: Build everything (using the cache, we should make an archive of course)
run: ./scripts/build.sh ios_sim debug
- name: Testing iOS app
run: sh ./scripts/test.sh
run: ./scripts/test.sh

View File

@@ -1 +1 @@
94444dbd24884c250a3c00f19ece386ee5ac93e5
90e1d4cf7e5ec3d3286d2234c2fd1f1125e10efa

View File

@@ -11,22 +11,14 @@ Check out the repository, making sure to include the submodules. It is important
`git clone --recurse-submodules git@github.com:rive-app/rive-ios.git`
The package relies on skia, as well as rive-cpp in order to be built. To shorten the build cycle, we rely on compiled libraries for skia, rive & rive-skia-renderer.
The `./scripts/configure.sh` script will download or build appropriate libraries, be sure to run configure when making changes to our rive-cpp submodule.
The `./scripts/build.sh all` script will download or build appropriate libraries, be sure to run configure when making changes to our rive-cpp submodule.
### Uploading caches
If you are contributing and you have access to Rives' aws environment, make you sure install `aws-cli` and configure it with your credentials. If you run into permission issues here `aws sts get-caller-identity` can help make sure that your local developer environment is setup to talk to AWS correctly.
See https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
Note: on Mac, I just did 'brew install awscli'
Set the `RIVE_UPLOAD_IOS_ARCHIVE` env variable to `TRUE`
`RIVE_UPLOAD_IOS_ARCHIVE=TRUE ./scripts/configure.sh`
and it will upload caches when feasible. To force a rebuild, add `rebuild` as an argument...
`RIVE_UPLOAD_IOS_ARCHIVE=TRUE ./scripts/configure.sh rebuild`
Note: on a Mac with brew, you can simply run 'brew install awscli'
Note: the 'dependencies' directory is just a cache of what the configure.sh script downloads. It can be removed if you suspect is is out of date, and then just rerun the script (./scripts/configure.sh)

View File

@@ -625,7 +625,7 @@
dependencies/includes/skia/include/effects,
dependencies/includes/skia/include/gpu,
dependencies/includes/skia/include/config,
"dependencies/includes/rive-cpp/include",
dependencies/includes/rive/include,
dependencies/includes/renderer/include,
);
INFOPLIST_FILE = Source/Info.plist;
@@ -686,7 +686,7 @@
dependencies/includes/skia/include/effects,
dependencies/includes/skia/include/gpu,
dependencies/includes/skia/include/config,
"dependencies/includes/rive-cpp/include",
dependencies/includes/rive/include,
dependencies/includes/renderer/include,
);
INFOPLIST_FILE = Source/Info.plist;
@@ -733,7 +733,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
"HEADER_SEARCH_PATHS[arch=*]" = "submodules/rive-cpp/include";
"HEADER_SEARCH_PATHS[arch=*]" = "dependencies/includes/rive/include";
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@@ -754,7 +754,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
"HEADER_SEARCH_PATHS[arch=*]" = "submodules/rive-cpp/include";
"HEADER_SEARCH_PATHS[arch=*]" = "dependencies/includes/rive/include";
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",

128
scripts/build.rive.sh Executable file
View File

@@ -0,0 +1,128 @@
#!/bin/bash
set -ex
# split in two so build.skia can be done by multiple workers.
# assumes all skia's have been built
path=`readlink -f "${BASH_SOURCE:-$0}"`
DEV_SCRIPT_DIR=`dirname $path`
if git remote -v | grep ios;
then
export RIVE_RUNTIME_DIR="$DEV_SCRIPT_DIR/../submodules/rive-cpp"
else
export RIVE_RUNTIME_DIR="$DEV_SCRIPT_DIR/../../runtime"
fi
make_dependency_directories(){
rm -fr $DEV_SCRIPT_DIR/../dependencies
mkdir -p $DEV_SCRIPT_DIR/../dependencies
mkdir -p $DEV_SCRIPT_DIR/../dependencies/debug
mkdir -p $DEV_SCRIPT_DIR/../dependencies/release
mkdir -p $DEV_SCRIPT_DIR/../dependencies/includes
mkdir -p $DEV_SCRIPT_DIR/../dependencies/includes/skia
mkdir -p $DEV_SCRIPT_DIR/../dependencies/includes/renderer
mkdir -p $DEV_SCRIPT_DIR/../dependencies/includes/rive
}
build_renderer() {
# NOTE: we do not currently use debug, so lets not build debug
pushd $RIVE_RUNTIME_DIR/skia/renderer
./build.sh -p ios clean
./build.sh -p ios $1
popd
cp -r $RIVE_RUNTIME_DIR/build/ios/bin/$1/librive.a $DEV_SCRIPT_DIR/../dependencies/$1/librive.a
cp -r $RIVE_RUNTIME_DIR/skia/renderer/build/ios/bin/$1/librive_skia_renderer.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_skia_renderer.a
cp -r $RIVE_RUNTIME_DIR/skia/renderer/include $DEV_SCRIPT_DIR/../dependencies/includes/renderer
cp -r $RIVE_RUNTIME_DIR/include $DEV_SCRIPT_DIR/../dependencies/includes/rive
}
build_renderer_sim() {
# NOTE: we do not currently use debug, so lets not build debug
pushd $RIVE_RUNTIME_DIR/skia/renderer
./build.sh -p ios_sim clean
./build.sh -p ios_sim $1
popd
cp -r $RIVE_RUNTIME_DIR/build/ios_sim/bin/$1/librive.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_sim.a
cp -r $RIVE_RUNTIME_DIR/skia/renderer/build/ios_sim/bin/$1/librive_skia_renderer.a $DEV_SCRIPT_DIR/../dependencies/$1/librive_skia_renderer_sim.a
cp -r $RIVE_RUNTIME_DIR/skia/renderer/include $DEV_SCRIPT_DIR/../dependencies/includes/renderer
cp -r $RIVE_RUNTIME_DIR/include $DEV_SCRIPT_DIR/../dependencies/includes/rive
}
finalize_skia() {
# COMBINE SKIA
# make fat library, note that the ios64 library is already fat with arm64 and arm64e so we don't specify arch there.
pwd
pushd $RIVE_RUNTIME_DIR/skia/dependencies/skia
xcrun -sdk iphoneos lipo -create -arch armv7 out/arm/libskia.a out/arm64/libskia.a -output out/libskia_ios.a
xcrun -sdk iphoneos lipo -create -arch x86_64 out/x64/libskia.a -arch i386 out/x86/libskia.a out/iossim_arm64/libskia.a -output out/libskia_ios_sim.a
popd
# copy skia outputs from ld'in skia!
cp -r $RIVE_RUNTIME_DIR/skia/dependencies/skia/out/libskia_ios.a $DEV_SCRIPT_DIR/../dependencies
cp -r $RIVE_RUNTIME_DIR/skia/dependencies/skia/out/libskia_ios_sim.a $DEV_SCRIPT_DIR/../dependencies
# note we purposefully put the skia include folder into dependencies/includes/skia, skia includes headers from include/core/name.h
cp -r $RIVE_RUNTIME_DIR/skia/dependencies/skia/include $DEV_SCRIPT_DIR/../dependencies/includes/skia
}
usage () {
echo "USAGE: $0 <all|ios|ios_sim> <debug|release>"
exit 1
}
if (( $# < 1 ))
then
usage
fi
case $1 in
all)
make_dependency_directories
finalize_skia
build_renderer debug
build_renderer release
build_renderer_sim debug
build_renderer_sim release
;;
ios)
if (( $# < 2 ))
then
usage
fi
case $2 in
release | debug)
make_dependency_directories
finalize_skia
build_renderer $2
;;
*)
usage
;;
esac
;;
ios_sim)
if (( $# < 2 ))
then
usage
fi
case $2 in
release | debug)
make_dependency_directories
finalize_skia
build_renderer_sim $2
;;
*)
usage
;;
esac
;;
*)
usage
;;
esac

15
scripts/build.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -e
path=`readlink -f "${BASH_SOURCE:-$0}"`
DEV_SCRIPT_DIR=`dirname $path`
# hmm this'll be problematic, our caches overwrite each other, not a problem for the remotes
$DEV_SCRIPT_DIR/build.skia.sh -a x86
$DEV_SCRIPT_DIR/build.skia.sh -a x86
$DEV_SCRIPT_DIR/build.skia.sh -a x64
$DEV_SCRIPT_DIR/build.skia.sh -a arm
$DEV_SCRIPT_DIR/build.skia.sh -a arm64
$DEV_SCRIPT_DIR/build.skia.sh -a iossim_arm64
$DEV_SCRIPT_DIR/build.rive.sh $@

50
scripts/build.skia.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
set -ex
ARCH_X86=x86
ARCH_X64=x64
ARCH_ARM=arm
ARCH_ARM64=arm64
ARCH_SIM_ARM64=iossim_arm64
usage() {
printf "Usage: %s -a arch\n" "$0"
printf "\t-a Specify an architecture (i.e. '%s', '%s', '%s', '%s', '%s')\n" $ARCH_X86 $ARCH_X64 $ARCH_ARM $ARCH_ARM64 $ARCH_SIM_ARM64
exit 1 # Exit script after printing help
}
while getopts "a:cd" opt; do
case "$opt" in
a) ARCH_NAME="$OPTARG" ;;
\?) usage ;; # Print usage in case parameter is non-existent
esac
done
if [ -z "$ARCH_NAME" ]; then
echo "No architecture specified"
usage
fi
path=`readlink -f "${BASH_SOURCE:-$0}"`
DEV_SCRIPT_DIR=`dirname $path`
export SKIA_REPO="https://github.com/rive-app/skia"
export SKIA_BRANCH="rive"
export COMPILE_TARGET="ios_$EXPECTED_NDK_VERSION_$ARCH_NAME"
export CACHE_NAME="rive_skia_ios"
export MAKE_SKIA_FILE="make_skia_ios.sh"
export SKIA_DIR_NAME="skia"
# we can have multiple at the same time...
export ARCHIVE_CONTENTS_NAME="archive_contents_$ARCH_NAME"
if git remote -v | grep ios;
then
export RIVE_RUNTIME_DIR="$DEV_SCRIPT_DIR/../submodules/rive-cpp"
else
export RIVE_RUNTIME_DIR="$DEV_SCRIPT_DIR/../../runtime"
fi
# Build skia
pushd "$RIVE_RUNTIME_DIR"/skia/dependencies
./make_skia_ios.sh $ARCH_NAME
popd

View File

@@ -1,40 +0,0 @@
#!/bin/bash
set -e
pushd submodules/rive-cpp
pushd skia/dependencies
./make_skia.sh
popd
pushd skia/renderer
./build.sh -p ios clean
./build.sh -p ios debug
./build.sh -p ios release
popd
popd
rm -fr dependencies
mkdir dependencies
mkdir dependencies/debug
mkdir dependencies/release
mkdir dependencies/includes
mkdir dependencies/includes/skia
mkdir dependencies/includes/renderer
mkdir dependencies/includes/rive-cpp
cp -r submodules/rive-cpp/build/ios/bin/debug/librive.a dependencies/debug/librive.a
cp -r submodules/rive-cpp/build/ios/bin/release/librive.a dependencies/release/librive.a
cp -r submodules/rive-cpp/build/ios_sim/bin/debug/librive.a dependencies/debug/librive_sim.a
cp -r submodules/rive-cpp/build/ios_sim/bin/release/librive.a dependencies/release/librive_sim.a
cp -r submodules/rive-cpp/skia/renderer/build/ios/bin/debug/librive_skia_renderer.a dependencies/debug/librive_skia_renderer.a
cp -r submodules/rive-cpp/skia/renderer/build/ios/bin/release/librive_skia_renderer.a dependencies/release/librive_skia_renderer.a
cp -r submodules/rive-cpp/skia/renderer/build/ios_sim/bin/debug/librive_skia_renderer.a dependencies/debug/librive_skia_renderer_sim.a
cp -r submodules/rive-cpp/skia/renderer/build/ios_sim/bin/release/librive_skia_renderer.a dependencies/release/librive_skia_renderer_sim.a
cp -r submodules/rive-cpp/skia/dependencies/skia_rive_optimized/out/libskia_ios.a dependencies
cp -r submodules/rive-cpp/skia/dependencies/skia_rive_optimized/out/libskia_ios_sim.a dependencies
# note we purposefully put the skia include folder into dependencies/includes/skia, skia includes headers from include/core/name.h
cp -r submodules/rive-cpp/skia/dependencies/skia_rive_optimized/include dependencies/includes/skia
cp -r submodules/rive-cpp/skia/renderer/include dependencies/includes/renderer
cp -r submodules/rive-cpp/include dependencies/includes/rive-cpp

View File

@@ -1,103 +0,0 @@
#!/bin/bash
set -e
# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --
then
echo >&2 "cannot $1: you have unstaged changes."
git diff-files --name-status -r --ignore-submodules -- >&2
err=1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
then
echo >&2 "cannot $1: your index contains uncommitted changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
if [ $err = 1 ]
then
echo >&2 "Please commit or stash them."
echo "FALSE"
else
echo "TRUE"
fi
}
# get rive-cpp commit hash, as key for pre built archives.
pushd submodules/rive-cpp
RIVE_CPP_CLEAN="$(require_clean_work_tree "get dependencies for $COMMIT_HASH")"
COMMIT_HASH=$(git rev-parse HEAD)
popd
COMMIT_HASH_FILE=dependencies/rive-cpp-commit-hash
CACHED_COMMIT_HASH=$(cat $COMMIT_HASH_FILE) || true
TAR_FILE_NAME="i386_x86_64_arm64_armv7.tar.gz"
KEY="$COMMIT_HASH/$TAR_FILE_NAME"
ARCHIVE_URL="https://cdn.2dimensions.com/archives/$KEY"
mkdir -p dependencies
mkdir -p cache
build() {
./scripts/build_dependencies.sh
}
cached_build() {
echo "Running cached build, checking $ARCHIVE_URL"
if curl --output /dev/null --head --silent --fail $ARCHIVE_URL && [ "$1" != "rebuild" ]
then
echo "$ARCHIVE_URL exists, downloading..."
curl --output cache/$TAR_FILE_NAME $ARCHIVE_URL
rm -rf dependencies/*
tar -xf cache/$TAR_FILE_NAME -C dependencies/
else
echo "$ARCHIVE_URL does not exist, building locally..."
build
echo $COMMIT_HASH > $COMMIT_HASH_FILE
# cd into dependencies and add everything to the archive cache/i386_x86_64_arm64_armv7.tar.gz
tar -C dependencies -cf cache/$TAR_FILE_NAME .
# if we're configured to upload the archive back into our cache, lets do it!
if [ "$RIVE_UPLOAD_IOS_ARCHIVE" == "TRUE" ]
then
echo "Configured to upload caches, uploading!"
aws s3 cp cache/$TAR_FILE_NAME s3://2d-public/archives/$KEY
fi
fi
}
update_dependencies () {
if [ "$RIVE_CPP_CLEAN" == "TRUE" ]
then
cached_build $1
else
echo "Rive-cpp has changes, cannot use cached builds"
build
fi
}
check_dependencies () {
if [ "$COMMIT_HASH" == "$CACHED_COMMIT_HASH" ] && [ "$RIVE_CPP_CLEAN" == "TRUE" ] && [ "$1" != "rebuild" ]
then
echo "Cache is up to date & rive_cpp is clean. no need to do anything"
else
update_dependencies $1
fi
}
check_dependencies $1