Update paths and build instructions for macOS builds
This commit is contained in:
parent
5304acbcd7
commit
e5bab4e725
@ -15,13 +15,10 @@ function copy_openssl_and_remove_dylibs() {
|
||||
OPENSSL_HOME="${1}"
|
||||
ARCH=$2
|
||||
OPENSSL_HOME_COPY="${3}/${ARCH}"
|
||||
if [ -d "${OPENSSL_HOME}" ]; then
|
||||
echo "*** Copying openssl libraries for static linking"
|
||||
cp -RL "${OPENSSL_HOME}" "${OPENSSL_HOME_COPY}"
|
||||
rm -f "${OPENSSL_HOME_COPY}"/lib/*.dylib
|
||||
else
|
||||
echo "*** WARNING: could not find openssl libraries at ${OPENSSL_HOME}; this build will almost certainly fail"
|
||||
fi
|
||||
|
||||
echo "*** Copying openssl libraries for static linking"
|
||||
cp -RL "${OPENSSL_HOME}" "${OPENSSL_HOME_COPY}"
|
||||
rm -f "${OPENSSL_HOME_COPY}"/lib/*.dylib
|
||||
}
|
||||
|
||||
if [ "$(dirname ${0})" != "." ]; then
|
||||
@ -81,6 +78,13 @@ if [[ "${all_linux}" -lt 3 ]]; then
|
||||
echo "*** WARNING: was not able to build for all linux arches; see above for errors"
|
||||
fi
|
||||
|
||||
# To build for macOS, you must be running this script from a Mac. The script requires that openssl@1.1
|
||||
# be installed via Homebrew.
|
||||
#
|
||||
# To build Redis binaries for both arm64e and x86_64, you'll need to run this script from an arm64e
|
||||
# Mac with _two_ parallel installations of Homebrew (see
|
||||
# https://stackoverflow.com/questions/64951024/how-can-i-run-two-isolated-installations-of-homebrew),
|
||||
# and install openssl@1.1 with each.
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
|
||||
tar zxf "${REDIS_TARBALL}"
|
||||
@ -88,28 +92,37 @@ if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
|
||||
# temporary directory for openssl libraries for static linking.
|
||||
# assumes standard Homebrew openssl install:
|
||||
# - arm64e at /opt/homebrew/opt/openssl
|
||||
# - x86_64 at /usr/local/opt/openssl
|
||||
# - arm64e at /opt/homebrew/opt/openssl@1.1
|
||||
# - x86_64 at /usr/local/opt/openssl@1.1
|
||||
OPENSSL_TEMP=$(mktemp -d /tmp/embedded-redis-darwin-openssl.XXXXX)
|
||||
|
||||
# build for arm64 on apple silicon
|
||||
if arch -arm64e true 2>/dev/null; then
|
||||
copy_openssl_and_remove_dylibs /opt/homebrew/opt/openssl arm64e "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-arm64e (apple silicon)"
|
||||
make clean
|
||||
arch -arm64e make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/arm64e"
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-arm64"
|
||||
if [ -d /opt/homebrew/opt/openssl@1.1 ]; then
|
||||
copy_openssl_and_remove_dylibs /opt/homebrew/opt/openssl@1.1 arm64e "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-arm64e (apple silicon)"
|
||||
make distclean
|
||||
arch -arm64e make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/arm64e"
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-arm64"
|
||||
else
|
||||
echo "*** WARNING: openssl@1.1 not found for darwin-arm64e; skipping build"
|
||||
fi
|
||||
else
|
||||
echo "*** WARNING: could not build for darwin-arm64e; you probably want to do this on an apple silicon device"
|
||||
fi
|
||||
|
||||
# build for x86_64 if we're on apple silicon or a recent macos on x86_64
|
||||
if arch -x86_64 true 2>/dev/null; then
|
||||
copy_openssl_and_remove_dylibs /usr/local/opt/openssl x86_64 "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-x86_64"
|
||||
make clean
|
||||
arch -x86_64 make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/x86_64"
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-x86_64"
|
||||
if [ -d /usr/local/opt/openssl@1.1 ]; then
|
||||
copy_openssl_and_remove_dylibs /usr/local/opt/openssl@1.1 x86_64 "${OPENSSL_TEMP}"
|
||||
echo "*** Building redis version ${REDIS_VERSION} for darwin-x86_64"
|
||||
make distclean
|
||||
arch -x86_64 make -j3 BUILD_TLS=yes OPENSSL_PREFIX="$OPENSSL_TEMP/x86_64"
|
||||
# x86_64 and amd64 are effectively synonymous; we use amd64 here to match the naming scheme used by Docker builds
|
||||
mv src/redis-server "../redis-server-${REDIS_VERSION}-darwin-amd64"
|
||||
else
|
||||
echo "*** WARNING: openssl@1.1 not found for darwin-x86_64; skipping build"
|
||||
fi
|
||||
else
|
||||
echo "*** WARNING: you are on a version of macos that lacks /usr/bin/arch, you probably do not want this"
|
||||
exit 1
|
||||
|
||||
@ -30,7 +30,7 @@ public class RedisExecProvider {
|
||||
executables.put(OsArchitecture.UNIX_x86_64, "redis-server-" + redisVersion + "-linux-amd64");
|
||||
executables.put(OsArchitecture.UNIX_arm64, "redis-server-" + redisVersion + "-linux-arm64");
|
||||
|
||||
executables.put(OsArchitecture.MAC_OS_X_x86_64, "redis-server-" + redisVersion + "-darwin-x86_64");
|
||||
executables.put(OsArchitecture.MAC_OS_X_x86_64, "redis-server-" + redisVersion + "-darwin-amd64");
|
||||
executables.put(OsArchitecture.MAC_OS_X_arm64, "redis-server-" + redisVersion + "-darwin-arm64");
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ public class RedisServerTest {
|
||||
.override(OS.UNIX, Architecture.x86, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-386").getFile())
|
||||
.override(OS.UNIX, Architecture.x86_64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-amd64").getFile())
|
||||
.override(OS.UNIX, Architecture.arm64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-linux-arm64").getFile())
|
||||
.override(OS.MAC_OS_X, Architecture.x86_64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-darwin-x86_64").getFile())
|
||||
.override(OS.MAC_OS_X, Architecture.x86_64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-darwin-amd64").getFile())
|
||||
.override(OS.MAC_OS_X, Architecture.arm64, Resources.getResource("redis-server-" + RedisExecProvider.redisVersion + "-darwin-arm64").getFile());
|
||||
|
||||
redisServer = new RedisServerBuilder()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user