giu icon indicating copy to clipboard operation
giu copied to clipboard

[Feature Request] Are there plans for Arm64 on MacOS?

Open macbutch opened this issue 2 years ago • 4 comments

Related problem

No response

Your request

It would be nice - if it is feasible - to be able to provide Universal binaries on MacOS. I believe the the M1 processor runs binaries built from Giu without trouble so I don't think there's anything like a deadline for this.

Alternative solution

No response

Additional context

No response

macbutch avatar Oct 22 '21 08:10 macbutch

I'm using this script to do universal binary and dmg at once:

#!/usr/bin/env bash

MODE=$1
BUNDLEPATH="release/macos/TheApp.app"
ICONSIZES=("16" "32" "64" "128" "256" "512")

rm -rf "${BUNDLEPATH}"

if [ "${MODE}" == "universal" ]; then
    # Build universal binary.
    echo "Building for darwin/arm64..."
    CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o binary_arm64 -ldflags '-s -w' main.go
    echo "Building for darwin/amd64..."
    CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o binary_amd64 -ldflags '-s -w' main.go
    echo "Building universal binary..."
    lipo -create -output binary binary_amd64 binary_arm64
fi

if [ "${MODE}" == "amd64" ]; then
    CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o binary -ldflags '-s -w' main.go
fi

echo "Creating bundle..."
mkdir -p "${BUNDLEPATH}/Contents/MacOS"
mkdir -p "${BUNDLEPATH}/Contents/Resources"
cp build/macos/Info.plist "${BUNDLEPATH}/Contents"
mv binary "${BUNDLEPATH}/Contents/MacOS"

mkdir assets/iconpack.iconset
for size in ${ICONSIZES[@]}; do
    x2size=$(echo $[ ${size} * 2 ])
    sips -z $size $size assets/icon.png --out assets/iconpack.iconset/icon_${size}x${size}.png
    sips -z $x2size $x2size assets/icon.png --out assets/iconpack.iconset/icon_${size}x${size}@2x.png
done

iconutil -c icns -o "${BUNDLEPATH}/Contents/Resources/icon.icns" assets/iconpack.iconset
rm -rf assets/iconpack.iconset

hdiutil create -volname TheApp -fs HFS+ -fsargs "-c c=64,a=16,e=16" -size 32M theapp.temp.dmg
device=$(hdiutil attach -readwrite -noverify -noautoopen "theapp.temp.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}')
mv "${BUNDLEPATH}" /Volumes/TheApp
hdiutil detach ${device}
hdiutil convert "theapp.temp.dmg" -format UDZO -imagekey zlib-level=9 -o "TheApp.dmg"

rm -f binary*

This script will also strip debug symbols and symbols table to minimize binary sizes (-s -w linker flags).

You still have to deal with notarization and code signing, this script only create universal binary and dmg for distribution.

pztrn avatar Nov 21 '21 18:11 pztrn

We can add that stuff to cmd/gmdeploy

gucio321 avatar Jul 08 '22 19:07 gucio321

@gucio321 Yeah, I will do it later today. :P

AllenDang avatar Jul 09 '22 02:07 AllenDang

@gucio321 Sigh... I'm stucked at home without my laptop due to the covid-19 quarantine...

AllenDang avatar Jul 11 '22 11:07 AllenDang

I think it is actually present in gmdeploy.

gucio321 avatar May 09 '23 16:05 gucio321