aboutsummaryrefslogtreecommitdiffhomepage
path: root/macosx
diff options
context:
space:
mode:
authorGravatar Alex Chernyakhovsky <achernya@google.com>2022-07-11 21:21:33 -0400
committerGravatar Alex Chernyakhovsky <achernya@mit.edu>2022-08-03 13:52:18 -1000
commit4cd2da52025375106edf0d2b53259b79d77b3234 (patch)
tree22e83f73ec3afee2e31e0742cc0078cfec5aa0a8 /macosx
parent6154bc04d9efabeefa286ab26fc2ffdcdb18a777 (diff)
Switch macOS multi-arch to x86_64+arm64
The previous CI attemtped to use Homebrew for builds, but unfortunately Homebrew has dropped support for universal packages aka multiarch (fat) binaries. This means that in order to build an arm64 + x86_64 package, macports has to be used instead of homebrew. Unlike Homebrew, MacPorts is not installed by default on the GitHub Actions runners, so we need to install it ourselves. This means managing our own instance of the cache, which itself produces challenges as the `gtar` binary run by the action doesn't have enough permissions to restore the MacPorts checkout. So we have to shim gtar with a sudo wrapper. With this commit, we produce a Mosh package that works on macOS 11.0 and newer, on both arm64 and x86_64 architectures. The protobuf library is statically linked, but all other libraries are provided by the system.
Diffstat (limited to 'macosx')
-rwxr-xr-xmacosx/build.sh11
-rw-r--r--macosx/gtar2
-rwxr-xr-xmacosx/port-deps.sh16
3 files changed, 25 insertions, 4 deletions
diff --git a/macosx/build.sh b/macosx/build.sh
index 7740fcc..acd2860 100755
--- a/macosx/build.sh
+++ b/macosx/build.sh
@@ -39,7 +39,8 @@ echo "Building into prefix..."
#
PREFIX="$(pwd)/prefix"
-ARCHS=" ppc ppc64 i386 x86_64"
+HOST="x86_64-apple-macosx${MACOSX_DEPLOYMENT_TARGET}"
+ARCH_TRIPLES="x86_64-apple-macosx arm64-apple-macos"
pushd .. > /dev/null
@@ -52,16 +53,18 @@ fi
#
# Build archs one by one.
#
-for arch in $ARCHS; do
+for triple in $ARCH_TRIPLES; do
+ arch=$(echo $triple | cut -d- -f1)
echo "Building for ${arch}..."
prefix="${PREFIX}_${arch}"
rm -rf "${prefix}"
mkdir "${prefix}"
- if ./configure --prefix="${prefix}/local" \
+ if ./configure --prefix="${prefix}/local" --build="${triple}${MACOSX_DEPLOYMENT_TARGET}"\
+ --host="${HOST}" \
CC="cc -arch ${arch}" CPP="cc -arch ${arch} -E" CXX="c++ -arch ${arch}" \
TINFO_LIBS=-lncurses &&
make clean &&
- make install -j8 &&
+ make install -j8 V=1 &&
rm -f "${prefix}/etc"
then
# mosh-client built with Xcode 3.1.2 bus-errors if the binary is stripped.
diff --git a/macosx/gtar b/macosx/gtar
new file mode 100644
index 0000000..5814696
--- /dev/null
+++ b/macosx/gtar
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec sudo /usr/local/bin/gtar.orig "$@"
diff --git a/macosx/port-deps.sh b/macosx/port-deps.sh
new file mode 100755
index 0000000..1ea2e65
--- /dev/null
+++ b/macosx/port-deps.sh
@@ -0,0 +1,16 @@
+describe() {
+ /opt/local/bin/port version > port-version.txt
+ /opt/local/bin/port -v -q installed > port-packages.txt
+}
+
+deps() {
+ # Set up macports to respect the deployment target before building universal packages
+ echo "macosx_deployment_target 11.0" | sudo tee -a /opt/local/etc/macports/macports.conf
+ sudo /opt/local/bin/port install protobuf3-cpp +universal
+ sudo /opt/local/bin/port install ncurses +universal
+ sudo /opt/local/bin/port install pkgconfig
+ sudo /opt/local/bin/port install autoconf automake
+}
+
+set -e
+"$@"