# HG changeset patch # User Augie Fackler # Date 1668440429 18000 # Node ID 24f7a481d284d645fd1f34d76b595001cc512f1c # Parent a5a4f9e12c9faf350343a0adb530987db7e030b7 shell: cache openssl prefix from homebrew Turns out homebrew costs about 800ms to figure this out, experimentally. :( diff --git a/.shell.d/99.openssl.sh b/.shell.d/99.openssl.sh --- a/.shell.d/99.openssl.sh +++ b/.shell.d/99.openssl.sh @@ -1,5 +1,14 @@ if hash brew 2>/dev/null ; then - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib - export DEP_OPENSSL_INCLUDE=`brew --prefix openssl`/include + BREW_SSL_PREFIX_CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/durin42-zsh/brew-openssl-prefix" + if [ -e "$BREW_SSL_PREFIX_CACHE_FILE" ] ; then + BREW_OPENSSL_PREFIX="$(cat $BREW_SSL_PREFIX_CACHE_FILE)" + fi + if [ -z "$BREW_OPENSSL_PREFIX" -o ! -d "$BREW_OPENSSL_PREFIX" ] ; then + BREW_OPENSSL_PREFIX="$(brew --prefix openssl)" + mkdir -p "$(dirname $BREW_SSL_PREFIX_CACHE_FILE)" + echo "$BREW_OPENSSL_PREFIX" > "$BREW_SSL_PREFIX_CACHE_FILE" + fi + export OPENSSL_INCLUDE_DIR="${BREW_OPENSSL_PREFIX}/include" + export OPENSSL_LIB_DIR="${BREW_OPENSSL_PREFIX}/lib" + export DEP_OPENSSL_INCLUDE="${BREW_OPENSSL_PREFIX}/include" fi