Skip to content

Commit afb365c

Browse files
authored
ci: optimize install_homebrew_deps by coalescing installs (#4975)
There seems to be a couple seconds overhead for each "brew install". Refactor install_homebrew_deps.bash to first assemble the list of all packages to install, and then do a single `brew install` for the whole list. Also remove mention of packages that are pre-installed on the Mac GHA runners or that we don't need. In the process, by using the `OIIO_BREW_INSTALL_PACKAGES` variable and only setting it if empty, we now have the ability to fully override the list of packages that brew will install on a per-job basis. Signed-off-by: Larry Gritz <[email protected]>
1 parent ae04b6e commit afb365c

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/build-scripts/install_homebrew_deps.bash

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if [[ `which brew` == "" ]] ; then
1919
exit 1
2020
fi
2121

22+
set -ex
2223

2324
if [[ "${DO_BREW_UPDATE:=0}" != "0" ]] ; then
2425
brew update >/dev/null
@@ -27,42 +28,38 @@ echo ""
2728
echo "Before my brew installs:"
2829
brew list --versions
2930

30-
# All cases except for clang-format target, we need the dependencies.
31-
brew install --display-times -q gcc ccache cmake ninja || true
32-
brew link --overwrite gcc
33-
brew install --display-times -q python@${PYTHON_VERSION} || true
34-
brew unlink [email protected] || true
35-
brew unlink [email protected] || true
36-
brew unlink [email protected] || true
37-
brew link --overwrite --force python@${PYTHON_VERSION} || true
38-
#brew upgrade --display-times -q cmake || true
39-
#brew install --display-times -q libtiff
40-
brew install --display-times -q imath openexr opencolorio
41-
#brew install --display-times -q libpng giflib webp
42-
brew install --display-times -q jpeg-turbo openjpeg libultrahdr
43-
brew install --display-times -q freetype libraw dcmtk pybind11 numpy || true
44-
brew install --display-times -q ffmpeg libheif ptex || true
45-
brew install --display-times -q tbb || true
46-
brew install --display-times -q openvdb || true
47-
brew install --display-times -q robin-map || true
48-
if [[ "${USE_OPENCV}" != "0" ]] && [[ "${INSTALL_OPENCV:=1}" != "0" ]] ; then
49-
brew install --display-times -q opencv || true
50-
fi
51-
if [[ "${USE_QT:=1}" != "0" ]] && [[ "${INSTALL_QT:=1}" != "0" ]] ; then
52-
brew install --display-times -q qt${QT_VERSION}
53-
fi
54-
if [[ "${USE_LLVM:=0}" != "0" ]] || [[ "${LLVMBREWVER}" != "" ]]; then
55-
brew install --display-times -q llvm${LLVMBREWVER}
56-
export PATH=/usr/local/opt/llvm/bin:$PATH
31+
if [[ "$OIIO_BREW_INSTALL_PACKAGES" == "" ]] ; then
32+
OIIO_BREW_INSTALL_PACKAGES=" \
33+
ccache \
34+
dcmtk \
35+
ffmpeg \
36+
imath \
37+
libheif \
38+
libraw \
39+
libultrahdr \
40+
numpy \
41+
opencolorio \
42+
openexr \
43+
openjpeg \
44+
openvdb \
45+
ptex \
46+
pybind11 \
47+
robin-map \
48+
tbb \
49+
"
50+
if [[ "${USE_OPENCV}" != "0" ]] && [[ "${INSTALL_OPENCV:=1}" != "0" ]] ; then
51+
OIIO_BREW_INSTALL_PACKAGES+=" opencv"
52+
fi
53+
if [[ "${USE_QT:=1}" != "0" ]] && [[ "${INSTALL_QT:=1}" != "0" ]] ; then
54+
OIIO_BREW_INSTALL_PACKAGES+=" qt${QT_VERSION}"
55+
fi
5756
fi
57+
brew install --display-times -q $OIIO_BREW_INSTALL_PACKAGES $OIIO_BREW_EXTRA_INSTALL_PACKAGES || true
5858

5959
echo ""
6060
echo "After brew installs:"
6161
brew list --versions
6262

63-
# Needed on some systems
64-
pip${PYTHON_VERSION} install numpy
65-
6663
# Set up paths. These will only affect the caller if this script is
6764
# run with 'source' rather than in a separate shell.
6865
export PATH=/usr/local/opt/qt5/bin:$PATH

0 commit comments

Comments
 (0)