🛠 Make --universal a build option

This commit is contained in:
Chris Araman 2021-05-07 11:33:39 -07:00
parent 3e88d28622
commit c177fa79a1
No known key found for this signature in database
GPG key ID: BB4499D9E11B61E0
5 changed files with 33 additions and 12 deletions

View file

@ -6,10 +6,21 @@
# Builds the Swift Package.
#
# Build for the host architecture by default.
ARCH=
if [[ "$1" == '--universal' ]]; then
ARCH='--arch arm64 --arch x86_64'
fi
# Disable the manifest cache on Xcode 12.5 and later.
CACHE=
if [[ "$(swift build --help)" =~ manifest-cache ]]; then
CACHE='--manifest-cache none'
fi
echo "==> 🏗️ Building mas ($(script/version))"
swift build \
--configuration release \
--arch arm64 \
--arch x86_64 \
${ARCH} \
--disable-sandbox \
--manifest-cache none
${CACHE}

View file

@ -11,6 +11,5 @@ VERSION=$(script/version)
echo "Building mas $VERSION artifacts"
script/clean
script/build
script/archive
script/build --universal
script/package

View file

@ -10,18 +10,29 @@
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
#
ARCH=$(uname -m)
RELEASE=.build/${ARCH}-apple-macosx/release
VERSION=$(script/version)
# Override default prefix path with optional 1st arg
if test -n "$1"; then
PREFIX="$1"
elif [[ $(uname -m) == 'arm64' ]]; then
if [[ $(uname -m) == 'arm64' ]]; then
PREFIX=/opt/homebrew
else
PREFIX=/usr/local
fi
while test -n "$1"; do
if [[ "$1" == '--universal' ]]; then
ARCH=universal
RELEASE=.build/apple/Products/Release
else
# Override default prefix path with optional arg
PREFIX="$1"
fi
shift
done
echo "==> 📲 Installing mas ($VERSION) for $ARCH to $PREFIX"
ditto -v \
".build/apple/Products/Release/mas" \
"$RELEASE/mas" \
"$PREFIX/bin/"

View file

@ -18,7 +18,7 @@ DISTRIBUTION_PLIST="Package/Distribution.plist"
# Destination for install root
DSTROOT=.build/distributions
script/install "$DSTROOT/usr/local"
script/install "$DSTROOT/usr/local" --universal
VERSION=$(script/version)

View file

@ -3,7 +3,7 @@
# script/uninstall
# mas
#
# Removes mas and MasKit from PREFIX.
# Removes mas from PREFIX.
#
# Override default prefix path with optional 1st arg