MacOS build dependencies #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MacOS build dependencies | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 3 * * 0' # run at 3 AM UTC every Sunday | |
repository_dispatch: | |
types: [mac_deps] | |
jobs: | |
build: | |
runs-on: ${{ matrix.runner || 'macos-12' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
binary_compatibility: | |
- "darwin_16.x86_64" # macOS 10.12, the earliest version supported by QT 5.13 | |
- "darwin_17.x86_64" # macOS 10.13, the earliest version supported by QT 5.15 | |
- "darwin_18.x86_64" # macOS 10.14, the earliest version supported by QT 6.4 | |
#- "darwin_20.arm64" # macOS 11, the earliest ARM64 version; temporarily no upstream binary packages | |
- "darwin_21.arm64" # macOS 12, the earliest ARM64 version we have MacPorts binary packages for | |
include: | |
# this list is meant to be synchronized with mac_release.yml | |
- common_pkgs: | |
- brotli 1.1.0_0 | |
- dbus 1.14.10_1 | |
- double-conversion 3.3.0_0 | |
- freetype 2.13.2_0 | |
- gettext-runtime 0.22.5_0 | |
- giflib 4.2.3_1 | |
- glib2 2.78.4_1+x11 | |
- graphite2 1.3.14_0 | |
- harfbuzz 8.5.0_0 | |
- icu 74.2_0 | |
- jasper 4.2.4_0 | |
- lcms2 2.16_0 | |
- lerc 4.0.0_1 | |
- lz4 1.10.0_0 | |
- libdeflate 1.20_0 | |
- libedit 20240517-3.1_0 | |
- libffi 3.4.6_1 | |
- libiconv 1.17_0 | |
- libjpeg-turbo 3.0.3_0 | |
- libmng 2.0.3_1 | |
- libpng 1.6.43_0 | |
- ncurses 6.5_0 | |
- openssl3 3.3.1_1 | |
- pcre 8.45_0 | |
- pcre2 10.44_0 | |
- python39 3.9.19_0+lto+optimizations | |
- tcl 8.6.14_0+corefoundation+threads | |
- tiff 4.6.0_0 | |
- webp 1.4.0_0 | |
- xz 5.4.7_0 | |
- zlib 1.3.1_0 | |
- zstd 1.5.6_0 | |
host_pkgs: | |
- ccache 4.10.2_0+doc | |
- hiredis 1.2.0_0 | |
- binary_compatibility: darwin_21.arm64 | |
pkgs: | |
- qt5-qtbase 5.15.12_1+openssl | |
- qt5-qtdeclarative 5.15.12_0 | |
- qt5-qtimageformats 5.15.12_0 | |
- qt5-qtscript 5.15.12_0 | |
- qt5-qtsvg 5.15.12_0 | |
- qt5-qttools 5.15.12_0 | |
- libb2 0.98.1_1 | |
- md4c 0.4.8_0 | |
- qt6-qtbase 6.4.3_6+openssl | |
- qt6-qtdeclarative 6.4.3_0 | |
- qt6-qtimageformats 6.4.3_0 | |
- qt6-qtsvg 6.4.3_1 | |
- qt6-qttools 6.4.3_1 | |
- qt6-qt5compat 6.4.3_2 | |
runner: macos-14 | |
runner_binary_compatibility: darwin_23.arm64 | |
- binary_compatibility: darwin_18.x86_64 | |
pkgs: | |
- libb2 0.98.1_1 | |
- md4c 0.4.8_0 | |
- qt6-qtbase 6.4.3_6+openssl | |
- qt6-qtdeclarative 6.4.3_0 | |
- qt6-qtimageformats 6.4.3_0 | |
- qt6-qtsvg 6.4.3_1 | |
- qt6-qttools 6.4.3_1 | |
- qt6-qt5compat 6.4.3_2 | |
qmake_flags: "" | |
runner_binary_compatibility: darwin_21.x86_64 | |
- binary_compatibility: darwin_17.x86_64 | |
pkgs: | |
- qt5-qtbase 5.15.12_1+openssl | |
- qt5-qtdeclarative 5.15.12_0 | |
- qt5-qtimageformats 5.15.12_0 | |
- qt5-qtscript 5.15.12_0 | |
- qt5-qtsvg 5.15.12_0 | |
- qt5-qttools 5.15.12_0 | |
qmake_flags: "" | |
runner_binary_compatibility: darwin_21.x86_64 | |
- binary_compatibility: darwin_16.x86_64 | |
cflags: -arch x86_64 | |
add_variants: "" | |
dmg_postfix: "-macos10.12" | |
pkgs: | |
- legacy-support 1.2.4_0 | |
- qt513-qtbase 5.13.2_10+openssl | |
- qt513-qtdeclarative 5.13.2_0 | |
- qt513-qtimageformats 5.13.2_3 | |
- qt513-qtscript 5.13.2_0 | |
- qt513-qtsvg 5.13.2_0 | |
- qt513-qttools 5.13.2_0 | |
qmake_flags: "" | |
runner_binary_compatibility: darwin_21.x86_64 | |
steps: | |
- name: Restore distfiles packages cache | |
id: cache-distfiles | |
uses: actions/cache/restore@v4 | |
with: | |
path: distfiles | |
key: distfiles-${{ matrix.binary_compatibility }}--${{ github.sha }} | |
restore-keys: distfiles-${{ matrix.binary_compatibility }}-- | |
- name: Fetch distfiles | |
run: | | |
mkdir -p distfiles | |
fetch_binpkg() { | |
local _compat="$1"; shift | |
while [ -n "$1" ]; do | |
local _name="$1" | |
local _postfix="$2" | |
local _url="https://packages.macports.org/$_name/$_name-$_postfix.$_compat.tbz2" | |
shift 2 | |
case " $*" in *" $_name "*_) echo "$_name: Skipping as an override follows" 1>&2; continue ;; esac | |
_file="distfiles/$(basename "$_url")" | |
if [ ! -e "$_file" ]; then | |
echo "Fetching $_url" 1>&2 | |
if ! curl -fsL -o "$_file" "$_url"; then | |
echo "Fetching $_url failed, skipping" 1>&2 | |
rm -f "$_file" | |
printf '%s @%s\n' "$_name" "$_postfix" | |
fi | |
fi | |
done | |
} | |
_distfiles_count="$(ls distfiles | wc -l)" | |
_any="no" | |
fetch_all() { | |
fetch_binpkg ${{ matrix.runner_binary_compatibility }} ${{ join(matrix.host_pkgs, ' ') }} | |
fetch_binpkg ${{ matrix.binary_compatibility }} ${{ join(matrix.common_pkgs, ' ') }} ${{ join(matrix.pkgs, ' ') }} | |
} | |
_missing="$(fetch_all)" | |
[ "$(ls distfiles | wc -l)" -eq "$_distfiles_count" ] || _any=yes | |
tee -a $GITHUB_ENV <<EOF_ENV | |
UPDATE_DISTFILES_CACHE=$_any | |
MISSING_PACKAGES<<EOF_VAR | |
${_missing} | |
EOF_VAR | |
EOF_ENV | |
- name: Install MacPorts | |
if: env.MISSING_PACKAGES != '' | |
run: | | |
wget https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci | |
source ./macports-ci install | |
case ${{ matrix.binary_compatibility }} in | |
darwin_16.*) echo "macosx_deployment_target 10.12" ;; | |
darwin_17.*) echo "macosx_deployment_target 10.13" ;; | |
darwin_18.*) echo "macosx_deployment_target 10.14" ;; | |
darwin_19.*) echo "macosx_deployment_target 10.15" ;; | |
darwin_20.*) echo "macosx_deployment_target 11.0" ;; | |
darwin_21.*) echo "macosx_deployment_target 11.0" ;; | |
esac | sudo tee -a /opt/local/etc/macports/macports.conf | |
- name: Install missing packages except Qt | |
if: env.MISSING_PACKAGES != '' | |
run: | | |
set -x | |
prettify() { sed 's/^---> /::group::&/'; } | |
case "$MISSING_PACKAGES" in *ccache*) | |
sudo port -Nkv install ccache | prettify | |
esac | |
# Try to install what's possible to install from binary packages | |
OUR_PYTHON="$(echo "${{join(matrix.common_pkgs, fromJSON('"\n"')) }}" | awk '/^python3/ { print $1 }')" | |
case "$MISSING_PACKAGES" in *"$OUR_PYTHON"*) | |
echo "::group::Installing $OUR_PYTHON" | |
sudo port -Nkv install "$OUR_PYTHON" | prettify | |
sudo port -Nkv install python_select python3_select | prettify | |
sudo port select --set python "$OUR_PYTHON" | |
sudo port select --set python3 "$OUR_PYTHON" | |
echo "::endgroup::" | |
;; | |
esac | |
case "$MISSING_PACKAGES" in *gettext-runtime*) | |
echo "::group::Installing gettext-runtime" | |
sudo port -Nkv install gettext-runtime | prettify | |
echo "::endgroup::" | |
;; | |
esac | |
case "$MISSING_PACKAGES" in *glib2*) | |
echo "::group::Installing glib2" | |
sudo port -Nkv install glib2 | prettify # our and cairo's dependency, +x11 is the default | |
echo "::endgroup::" | |
;; | |
esac | |
case "$MISSING_PACKAGES" in *harfbuzz*) | |
echo "::group::Installing harfbuzz dependencies" | |
sudo port -Nk install python310 | prettify # fontconfig seems to need it badly | |
sudo port -Nkv install cairo -x11 | prettify # skip x11 dependencies | |
echo "::endgroup::" | |
;; | |
esac | |
_the_rest="$(echo "$MISSING_PACKAGES" | grep -v '^qt5-')" | |
[ -z "$_the_rest" ] || { | |
echo "::group::Installing $_the_rest" | |
sudo port -Nkv install $_the_rest | prettify | |
echo "::endgroup::" | |
} | |
- name: Install missing Qt packages except qt5-qttools | |
if: env.MISSING_PACKAGES != '' | |
run: | | |
set -x | |
prettify() { sed 's/^---> /::group::&/'; } | |
_the_rest="$(echo "$MISSING_PACKAGES" | grep '^qt5-' | grep -v '^qt5-qttools' || true)" | |
[ -z "$_the_rest" ] || sudo port -Nkv install $_the_rest | prettify | |
- name: Install missing qt5-qttools | |
if: env.MISSING_PACKAGES != '' | |
run: | | |
set -x | |
prettify() { sed 's/^---> /::group::&/'; } | |
case "$MISSING_PACKAGES" in *qt5-qttools*) | |
sudo port -Nkv install qt5-qttools | prettify | |
;; | |
esac | |
- name: Prepare distfiles cache | |
if: always() && env.MISSING_PACKAGES != '' | |
run: | | |
set -x | |
# Save any new wanted distfiles | |
_any="" | |
while read -r _package _version; do | |
_package_path="/opt/local/var/macports/software/$_package/$_package-${_version#@}" | |
ls -l "${_package_path%/*}/" || true | |
for _fullname in $(ls $_package_path.*.tbz2 2>/dev/null || true); do | |
_any=1 | |
if ! echo '${{ matrix.host_pkgs }}' | grep -q "$_package"; then | |
if [ ${{ matrix.binary_compatibility }} != ${{ matrix.runner_binary_compatibility }} ]; then | |
case "$_fullname" in *.${{ matrix.runner_binary_compatibility }}*) | |
_newname="${_fullname%.${{ matrix.runner_binary_compatibility }}.tbz2}.${{ matrix.binary_compatibility }}.tbz2" | |
if [ ! -f "$_newname" ]; then | |
echo "::warning::Package $_fullname is named after runner architecture, renaming to ${_newname##*/}" | |
cp "$_fullname" distfiles/"${_newname##*/}" | |
continue | |
fi | |
;; | |
esac | |
fi | |
fi | |
cp "$_fullname" distfiles/ | |
done | |
done <<EOF | |
$MISSING_PACKAGES | |
EOF | |
[ -z "$_any" ] || echo "UPDATE_DISTFILES_CACHE=yes" >> $GITHUB_ENV | |
- name: Save distfiles cache | |
if: always() && env.UPDATE_DISTFILES_CACHE == 'yes' | |
uses: actions/cache/save@v4 | |
with: | |
path: distfiles | |
key: ${{ steps.cache-distfiles.outputs.cache-primary-key }}-${{ env.CACHE_TIMESTAMP }} |