Skip to content

Commit

Permalink
Various fixes for MacOS Mojave 10.14 (#3)
Browse files Browse the repository at this point in the history
Summary:
I cloned this repo for the first time today and ran into a few problems building on MacOS Mojave 10.14.

Here's a small number of standalone fixes to the `build_helper.sh` script.
Pull Request resolved: #3

Reviewed By: lnicco

Differential Revision: D15212179

Pulled By: udippant

fbshipit-source-id: 86b5619954851654cc756d0b238c89896d7b42d1
  • Loading branch information
jsquyres authored and facebook-github-bot committed May 8, 2019
1 parent c6d2fcc commit ad3d7d7
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions build_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ Usage ${0##*/} [-h|?] [-p PATH] [-i INSTALL_PREFIX]
EOF
}

while getopts ":hp:" arg; do
while getopts ":hp:i:" arg; do
case $arg in
p)
BUILD_DIR="${OPTARG}"
;;
i)
INSTALL_PREFIX="${OPTARG}"
;;
h | *) # Display help.
usage
exit 0
Expand Down Expand Up @@ -61,6 +64,18 @@ else
MVFST_INSTALL_DIR=$INSTALL_PREFIX
fi

# Default to parallel build width of 4.
# If we have "nproc", use that to get a better value.
# If not, then intentionally go a bit conservative and
# just use the default of 4 (e.g., some desktop/laptop OSs
# have a tendency to freeze if we actually use all cores).
set +x
nproc=4
if [ -z "$(hash nproc 2>&1)" ]; then
nproc=$(nproc)
fi
set -x

function install_dependencies_linux() {
sudo apt-get install \
g++ \
Expand Down Expand Up @@ -127,15 +142,28 @@ function setup_folly() {
exit 1
fi
fi

if [ "$Platform" = "Mac" ]; then
# Homebrew installs OpenSSL in a non-default location on MacOS >= Mojave
# 10.14 because MacOS has its own SSL implementation. If we find the
# typical Homebrew OpenSSL dir, load OPENSSL_ROOT_DIR so that cmake
# will find the Homebrew version.
dir=/usr/local/opt/openssl
if [ -d $dir ]; then
export OPENSSL_ROOT_DIR=$dir
fi
fi

echo -e "${COLOR_GREEN}Building Folly ${COLOR_OFF}"
mkdir -p "$FOLLY_BUILD_DIR"
cd "$FOLLY_BUILD_DIR" || exit
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH="$FOLLY_INSTALL_DIR" \
-DCMAKE_INSTALL_PREFIX="$FOLLY_INSTALL_DIR" \
..
make -j "$(nproc)"
make -j "$nproc"
make install
echo -e "${COLOR_GREEN}Folly is installed ${COLOR_OFF}"
cd "$BWD" || exit
}

Expand All @@ -159,6 +187,6 @@ cmake -DCMAKE_PREFIX_PATH="$FOLLY_INSTALL_DIR" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTS=On \
../..
make -j "$(nproc)"
make -j "$nproc"
echo -e "${COLOR_GREEN}MVFST build is complete. To run unit test: \
cd _build/build && make test ${COLOR_OFF}"

0 comments on commit ad3d7d7

Please sign in to comment.