New misc/skia-url.sh script to simplify downloading the required Skia branch

This commit is contained in:
David Capello 2025-04-06 14:48:00 -03:00
parent bae8520580
commit 2c9eb2a801
5 changed files with 108 additions and 53 deletions

View File

@ -34,16 +34,14 @@ jobs:
shell: bash shell: bash
run: | run: |
if [[ "${{ runner.os }}" == "Windows" ]] ; then if [[ "${{ runner.os }}" == "Windows" ]] ; then
choco install wget -y --no-progress this_dir=$(cygpath "${{ github.workspace }}")
wget https://github.com/aseprite/skia/releases/download/m124-08a5439a6b/Skia-Windows-Release-x64.zip
unzip Skia-Windows-Release-x64.zip -d skia
elif [[ "${{ runner.os }}" == "macOS" ]] ; then
wget https://github.com/aseprite/skia/releases/download/m124-08a5439a6b/Skia-macOS-Release-arm64.zip
unzip Skia-macOS-Release-arm64.zip -d skia
else else
wget https://github.com/aseprite/skia/releases/download/m124-08a5439a6b/Skia-Linux-Release-x64.zip this_dir="${{ github.workspace }}"
unzip Skia-Linux-Release-x64.zip -d skia
fi fi
skia_url=$(source $this_dir/misc/skia-url.sh | xargs)
skia_file=$(basename $skia_url)
curl --ssl-revoke-best-effort -L -o "$skia_file" "$skia_url"
unzip "$skia_file" -d skia
- name: ccache - name: ccache
uses: hendrikmuhs/ccache-action@v1.2.17 uses: hendrikmuhs/ccache-action@v1.2.17
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}

View File

@ -57,28 +57,8 @@ if [ "$1" == "--norun" ] ; then
fi fi
# Platform. # Platform.
if [[ "$(uname)" =~ "MINGW32" ]] || [[ "$(uname)" =~ "MINGW64" ]] || [[ "$(uname)" =~ "MSYS_NT-10.0" ]] ; then if ! source "$pwd/misc/platform.sh" ; then
is_win=1 exit $?
cpu=x64
if ! cl.exe >/dev/null 2>/dev/null ; then
echo ""
echo "MSVC compiler (cl.exe) not found in PATH"
echo ""
echo " PATH=$PATH"
echo ""
exit 1
fi
elif [[ "$(uname)" == "Linux" ]] ; then
is_linux=1
cpu=x64
elif [[ "$(uname)" =~ "Darwin" ]] ; then
is_macos=1
if [[ $(uname -m) == "arm64" ]]; then
cpu=arm64
else
cpu=x64
fi
fi fi
# Check utilities. # Check utilities.
@ -348,10 +328,7 @@ else
elif git --git-dir="$source_dir/.git" branch --contains "$remote/main" | grep -q "^\* $branch_name\$" ; then elif git --git-dir="$source_dir/.git" branch --contains "$remote/main" | grep -q "^\* $branch_name\$" ; then
base_branch_name=main base_branch_name=main
else else
echo "" base_branch_name=$branch_name
echo "Error: Branch $branch_name looks like doesn't belong to main or beta"
echo ""
exit 1
fi fi
fi fi
@ -366,15 +343,9 @@ else
fi fi
# Required Skia for the base branch. # Required Skia for the base branch.
if [ "$base_branch_name" == "beta" ] ; then skia_tag=$(cat "$pwd/misc/skia-tag.txt" | xargs)
skia_tag=m124-08a5439a6b possible_skia_dir_name=skia-$(echo $skia_tag | cut -d "-" -f 1)
file_skia_dir=beta_skia_dir file_skia_dir="$base_branch_name"_skia_dir
possible_skia_dir_name=skia-m124
else
skia_tag=m102-861e4743af
file_skia_dir=main_skia_dir
possible_skia_dir_name=skia
fi
# Check Skia dependency. # Check Skia dependency.
if [ ! -f "$pwd/.build/$file_skia_dir" ] ; then if [ ! -f "$pwd/.build/$file_skia_dir" ] ; then
@ -422,6 +393,8 @@ if [ ! -d "$skia_library_dir" ] ; then
echo "" echo ""
if [ ! $auto ] ; then if [ ! $auto ] ; then
read -sN 1 -p "Download pre-compiled Skia automatically [Y/n]? " read -sN 1 -p "Download pre-compiled Skia automatically [Y/n]? "
# Convert the Enter key as the default option: an empty string
REPLY=$(echo $REPLY | xargs)
fi fi
if [[ $auto || "$REPLY" == "" || "$REPLY" == "y" || "$REPLY" == "Y" ]] ; then if [[ $auto || "$REPLY" == "" || "$REPLY" == "y" || "$REPLY" == "Y" ]] ; then
if [[ $is_win && "$build_type" == "Debug" ]] ; then if [[ $is_win && "$build_type" == "Debug" ]] ; then
@ -429,17 +402,10 @@ if [ ! -d "$skia_library_dir" ] ; then
else else
skia_build=Release skia_build=Release
fi fi
skia_url=$(bash misc/skia-url.sh $skia_build | xargs)
if [ $is_win ] ; then skia_file=$(basename $skia_url)
skia_file=Skia-Windows-$skia_build-$cpu.zip
elif [ $is_macos ] ; then
skia_file=Skia-macOS-$skia_build-$cpu.zip
else
skia_file=Skia-Linux-$skia_build-$cpu-libstdc++.zip
fi
skia_url=https://github.com/aseprite/skia/releases/download/$skia_tag/$skia_file
if [ ! -f "$skia_dir/$skia_file" ] ; then if [ ! -f "$skia_dir/$skia_file" ] ; then
curl -L -o "$skia_dir/$skia_file" "$skia_url" curl --ssl-revoke-best-effort -L -o "$skia_dir/$skia_file" "$skia_url"
fi fi
if [ ! -d "$skia_library_dir" ] ; then if [ ! -d "$skia_library_dir" ] ; then
unzip -n -d "$skia_dir" "$skia_dir/$skia_file" unzip -n -d "$skia_dir" "$skia_dir/$skia_file"

38
misc/platform.sh Executable file
View File

@ -0,0 +1,38 @@
#! /usr/bin/env bash
#
# Sets some environment variables to known the current platform.
# Usage:
#
# ./misc/platform.sh [--nocl]
#
# --nocl: For Windows only, it doesn't check the existence of cl.exe compiler in the PATH
#
uname="$(uname)"
if [[ "$uname" =~ "MINGW32" ]] || [[ "$uname" =~ "MINGW64" ]] || [[ "$uname" =~ "MSYS_NT-10.0" ]] ; then
is_win=1
cpu=x64
if [[ "$1" != "--nocl" ]] && ! cl.exe >/dev/null 2>/dev/null ; then
echo ""
echo "MSVC compiler (cl.exe) not found in PATH"
echo ""
echo " PATH=$PATH"
echo ""
exit 1
fi
elif [[ "$uname" == "Linux" ]] ; then
is_linux=1
cpu=$(arch | xargs)
if [[ "$cpu" == "x86_64" ]] ; then
cpu=x64
fi
elif [[ "$uname" =~ "Darwin" ]] ; then
is_macos=1
if [[ $(uname -m) == "arm64" ]]; then
cpu=arm64
else
cpu=x64
fi
fi

1
misc/skia-tag.txt Normal file
View File

@ -0,0 +1 @@
m124-08a5439a6b

52
misc/skia-url.sh Executable file
View File

@ -0,0 +1,52 @@
#! /usr/bin/env bash
#
# Prints the URL to download the Skia version for the given parameters.
# Usage:
#
# ./.skia-url.sh [release|debug] [windows|macos|linux] [x86|x64|arm64]
#
# The first version will print the URL for the release version of the
# current platform.
#
script_dir=$(dirname "${BASH_SOURCE[0]}")
skia_tag=$(cat "$script_dir/skia-tag.txt" | xargs)
skia_build=Release
source "$script_dir/platform.sh" --nocl
while [[ "$1" != "" ]] ; do
arg=$(echo $1 | tr '[:upper:]' '[:lower:]')
if [[ "$arg" == "x64" ]] ; then
cpu=x64
elif [[ "$arg" == "x86" ]] ; then
cpu=x86
elif [[ "$arg" == "arm64" ]] ; then
cpu=arm64
elif [[ "$arg" == "win" || "$arg" == "windows" ]] ; then
is_win=1
is_macos=
is_linux=
elif [[ "$arg" == "macos" || "$arg" == "macosx" || "$arg" == "osx" ]] ; then
is_win=
is_macos=1
is_linux=
elif [[ "$arg" == "linux" || "$arg" == "unix" ]] ; then
is_win=
is_macos=
is_linux=1
elif [[ "$arg" == "debug" ]] ; then
skia_build=Debug
fi
shift
done
if [ $is_win ] ; then
skia_file=Skia-Windows-$skia_build-$cpu.zip
elif [ $is_macos ] ; then
skia_file=Skia-macOS-$skia_build-$cpu.zip
else
skia_file=Skia-Linux-$skia_build-$cpu.zip
fi
echo https://github.com/aseprite/skia/releases/download/$skia_tag/$skia_file