diff --git a/script/build b/script/build index d5cb5c8..46d4dd5 100755 --- a/script/build +++ b/script/build @@ -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} diff --git a/script/build_artifacts b/script/build_artifacts index a3b3a10..30d384b 100755 --- a/script/build_artifacts +++ b/script/build_artifacts @@ -11,6 +11,5 @@ VERSION=$(script/version) echo "Building mas $VERSION artifacts" script/clean -script/build -script/archive +script/build --universal script/package diff --git a/script/install b/script/install index 20c4466..7bb2379 100755 --- a/script/install +++ b/script/install @@ -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/" diff --git a/script/package b/script/package index 526c2c4..686647c 100755 --- a/script/package +++ b/script/package @@ -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) diff --git a/script/uninstall b/script/uninstall index 853e35b..8e2af57 100755 --- a/script/uninstall +++ b/script/uninstall @@ -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