Skip to content

Commit ad3d7d7

Browse files
jsquyresfacebook-github-bot
authored andcommitted
Various fixes for MacOS Mojave 10.14 (#3)
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
1 parent c6d2fcc commit ad3d7d7

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

build_helper.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ Usage ${0##*/} [-h|?] [-p PATH] [-i INSTALL_PREFIX]
2424
EOF
2525
}
2626

27-
while getopts ":hp:" arg; do
27+
while getopts ":hp:i:" arg; do
2828
case $arg in
2929
p)
3030
BUILD_DIR="${OPTARG}"
3131
;;
32+
i)
33+
INSTALL_PREFIX="${OPTARG}"
34+
;;
3235
h | *) # Display help.
3336
usage
3437
exit 0
@@ -61,6 +64,18 @@ else
6164
MVFST_INSTALL_DIR=$INSTALL_PREFIX
6265
fi
6366

67+
# Default to parallel build width of 4.
68+
# If we have "nproc", use that to get a better value.
69+
# If not, then intentionally go a bit conservative and
70+
# just use the default of 4 (e.g., some desktop/laptop OSs
71+
# have a tendency to freeze if we actually use all cores).
72+
set +x
73+
nproc=4
74+
if [ -z "$(hash nproc 2>&1)" ]; then
75+
nproc=$(nproc)
76+
fi
77+
set -x
78+
6479
function install_dependencies_linux() {
6580
sudo apt-get install \
6681
g++ \
@@ -127,15 +142,28 @@ function setup_folly() {
127142
exit 1
128143
fi
129144
fi
145+
146+
if [ "$Platform" = "Mac" ]; then
147+
# Homebrew installs OpenSSL in a non-default location on MacOS >= Mojave
148+
# 10.14 because MacOS has its own SSL implementation. If we find the
149+
# typical Homebrew OpenSSL dir, load OPENSSL_ROOT_DIR so that cmake
150+
# will find the Homebrew version.
151+
dir=/usr/local/opt/openssl
152+
if [ -d $dir ]; then
153+
export OPENSSL_ROOT_DIR=$dir
154+
fi
155+
fi
156+
130157
echo -e "${COLOR_GREEN}Building Folly ${COLOR_OFF}"
131158
mkdir -p "$FOLLY_BUILD_DIR"
132159
cd "$FOLLY_BUILD_DIR" || exit
133160
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
134161
-DCMAKE_PREFIX_PATH="$FOLLY_INSTALL_DIR" \
135162
-DCMAKE_INSTALL_PREFIX="$FOLLY_INSTALL_DIR" \
136163
..
137-
make -j "$(nproc)"
164+
make -j "$nproc"
138165
make install
166+
echo -e "${COLOR_GREEN}Folly is installed ${COLOR_OFF}"
139167
cd "$BWD" || exit
140168
}
141169

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

0 commit comments

Comments
 (0)