Skip to content

Commit

Permalink
Github workflow: Fix linking error on macOS
Browse files Browse the repository at this point in the history
 Homebrew has multiple versions of python which occasionally step on
 each other. Add the overwrite flag in the install process to
 explicity oveverwrite old links.

 Additionally add a call to brew upgrade to handle issues where
 new packages require updating already installed ones.
  • Loading branch information
jhoyt4 committed Feb 14, 2024
1 parent 62ad21b commit 8f34a2a
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions .github/workflows/buildmaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,38 @@ jobs:
key: ${{ matrix.os }}-${{ matrix.cc }}-ccache-${{ github.sha }}
restore-keys: ${{ matrix.os }}-${{ matrix.cc }}-ccache

# macOS based github runners starting with macos-14 only run on the arm64
# architecture. To generate x86_64 based executable, the arch -x86_64
# command is needed before any brew commands, make, and install to run
# as x86_64 via Rosetta2.
- name: Check cross-compile environment (macOS)
# macOS runners on github use homebrew which can place executables in
# an assortment of places. Also, the runners can in various unsynced
# states that need update to resolve linking
- name: Update environment (macOS)
env:
ARCH: ${{ matrix.arch }}
PYTHONVERS: 3.12
run: |
SYSARCH=$(/usr/bin/uname -m)
PKGMGR_CMD='brew'
HB_PREFIX=$(${PKGMGR_CMD} --prefix)
echo "HB_PREFIX=$HB_PREFIX" >> $GITHUB_ENV
echo "PYTHONVERS=${PYTHONVERS}" >> $GITHUB_ENV
${PKGMGR_CMD} update
# brute force upgrade and unlink python versions
# we'll re-link the specified version later
INSTALLED_PYTHONS=$($PKGMGR_CMD list|grep 'python@')
for PYTH in $INSTALLED_PYTHONS; do
$PKGMGR_CMD upgrade $PYTH --force
${PKGMGR_CMD} unlink $PYTH
done
${PKGMGR_CMD} cleanup
${PKGMGR_CMD} upgrade --force
## Install specified python version
#${PKGMGR_CMD} install python@${PYTHONVERS} --force --overwrite
# macOS based github runners starting at macos-14 only run on arm64
# architectures. To generate x86_64 based executable, the arch
# -x86_64 command is needed before any brew commands, make, and
# install to run as x86_64 via Rosetta2.
if [ "$SYSARCH" = "$ARCH" ]; then
# this is a cross-compile
PKGMGR_CMD="arch -${ARCH} $PKGMGR_CMD"
Expand Down Expand Up @@ -100,22 +122,21 @@ jobs:
env:
OS_VERS: ${{ matrix.os }}
run: |
brew update
${PKGMGR_CMD} install pkg-config ccache qt5 nasm libsamplerate taglib\
lzo libcec libbluray libass libhdhomerun dav1d x264 x265 libvpx \
openssl sound-touch lame freetype libass libiconv libxml2 libzip \
XviD zlib pyenv-virtualenv python-lxml python-requests \
python-setuptools
${PKGMGR_CMD} link qt5 --force
${PKGMGR_CMD} install pkg-config ccache qt@5 nasm libsamplerate \
taglib lzo libcec libbluray libass libhdhomerun dav1d x264 x265 \
libvpx openssl sound-touch lame freetype libass libiconv libxml2 \
libzip XviD zlib pyenv-virtualenv python-lxml python-requests \
python-setuptools --force --overwrite
${PKGMGR_CMD} link qt@5 --force
${PKGMGR_CMD} link python@${PYTHONVERS} --force --overwrite
# macos-14 updated the linker and needs to be run in "classic" mode
case $OS_VERS in
macos-14)
macos-14 | macos-13)
LDFLAGS="-Wl,-ld_classic"
;;
esac
# homebrew uses different prefixes on x86_64 and arm64, find the
# correct one and setup the correct build variables
HB_PREFIX=$(${PKGMGR_CMD} --prefix)
C_INCLUDE_PATH=$HB_PREFIX/include:$C_INCLUDE_PATH
echo "C_INCLUDE_PATH=$C_INCLUDE_PATH" >> $GITHUB_ENV
CPLUS_INCLUDE_PATH=$HB_PREFIX/include:$CPLUS_INCLUDE_PATH
Expand Down Expand Up @@ -169,7 +190,7 @@ jobs:

- name: Install plugin dependencies (macOS)
run: ${PKGMGR_CMD} install minizip flac libvorbis libcdio python-pycurl
python-oauthlib
python-oauthlib --force --overwrite
if: runner.os == 'macOS'

- name: Configure plugins
Expand Down

0 comments on commit 8f34a2a

Please sign in to comment.