chore: Add Apple silicon support

This commit is contained in:
Alex Jbanca 2023-03-10 12:36:03 +02:00 committed by Alex Jbanca
parent eecaa0c7b9
commit 4ccdcdf44e
3 changed files with 44 additions and 14 deletions

View File

@ -78,6 +78,8 @@ ifeq ($(detected_OS),Darwin)
export MACOSX_DEPLOYMENT_TARGET
PKG_TARGET := pkg-macos
RUN_TARGET := run-macos
QMAKE_PATH := $(shell which qmake);
QT_ARCH := $(shell lipo -archs $(QMAKE_PATH))
else ifeq ($(detected_OS),Windows)
LIBSTATUS_EXT := dll
PKG_TARGET := pkg-windows
@ -115,10 +117,14 @@ endif
ifeq ($(detected_OS),Darwin)
BOTTLES_DIR := $(shell pwd)/bottles
BOTTLES := $(addprefix $(BOTTLES_DIR)/,openssl@1.1 pcre)
ifeq ($(QT_ARCH),arm64)
EXCLUDE_BOTTLES := 'linux'
else
EXCLUDE_BOTTLES := 'arm|linux'
endif
$(BOTTLES): | $(BOTTLES_DIR)
echo -e "\033[92mFetching:\033[39m $(notdir $@) bottle"
./scripts/fetch-brew-bottle.sh $(notdir $@)
echo -e "\033[92mFetching:\033[39m $(notdir $@) bottle arch $(QT_ARCH)"
./scripts/fetch-brew-bottle.sh $(notdir $@) $(EXCLUDE_BOTTLES)
$(BOTTLES_DIR):
echo -e "\033[92mUpdating:\033[39m macOS Homebrew"
@ -197,11 +203,15 @@ endif
ifeq ($(detected_OS),Darwin)
ifeq ("$(shell sysctl -nq hw.optional.arm64)","1")
# Building on M1 is still not supported, so in the meantime we crosscompile to amd64
DOTHERSIDE_CMAKE_PARAMS += -DCMAKE_OSX_ARCHITECTURES=x86_64
ifeq ("$(shell sysctl -nq hw.optional.arm64)","1")
ifneq ($(QT_ARCH),arm64)
STATUSGO_MAKE_PARAMS += GOBIN_SHARED_LIB_CFLAGS="CGO_ENABLED=1 GOOS=darwin GOARCH=amd64"
STATUSKEYCARDGO_MAKE_PARAMS += CGOFLAGS="CGO_ENABLED=1 GOOS=darwin GOARCH=amd64"
DOTHERSIDE_CMAKE_PARAMS += -DCMAKE_OSX_ARCHITECTURES=x86_64
QRCODEGEN_MAKE_PARAMS += CFLAGS="-target x86_64-apple-macos10.12"
NIM_PARAMS += --cpu:amd64 --os:MacOSX --passL:"-arch x86_64" --passC:"-arch x86_64"
endif
endif
endif
RELEASE ?= false
@ -257,7 +267,7 @@ status-go: $(STATUSGO)
$(STATUSGO): | deps
echo -e $(BUILD_MSG) "status-go"
+ cd vendor/status-go && \
$(MAKE) statusgo-shared-library $(HANDLE_OUTPUT)
$(MAKE) statusgo-shared-library $(STATUSGO_MAKE_PARAMS) $(HANDLE_OUTPUT)
STATUSKEYCARDGO := vendor/status-keycard-go/build/libkeycard/libkeycard.$(LIBSTATUS_EXT)
STATUSKEYCARDGO_LIBDIR := $(shell pwd)/$(shell dirname "$(STATUSKEYCARDGO)")
@ -267,7 +277,7 @@ status-keycard-go: $(STATUSKEYCARDGO)
$(STATUSKEYCARDGO): | deps
echo -e $(BUILD_MSG) "status-keycard-go"
+ cd vendor/status-keycard-go && \
$(MAKE) build-lib $(HANDLE_OUTPUT)
$(MAKE) build-lib $(STATUSKEYCARDGO_MAKE_PARAMS) $(HANDLE_OUTPUT)
QRCODEGEN := vendor/QR-Code-generator/c/libqrcodegen.a
@ -633,6 +643,7 @@ zip-windows: check-pkg-target-windows $(STATUS_CLIENT_7Z)
clean: | clean-common
rm -rf bin/* node_modules bottles/* pkg/* tmp/* $(STATUSGO) $(STATUSKEYCARDGO)
+ $(MAKE) -C vendor/DOtherSide/build --no-print-directory clean
+ $(MAKE) -C vendor/QR-Code-generator/c/ --no-print-directory clean
clean-git:
./scripts/clean-git.sh

View File

@ -10,10 +10,10 @@ function get_gh_pkgs_token() {
}
function get_bottle_json() {
brew info --json=v1 "${1}" | jq '
brew info --json=v1 "${1}" | jq "
.[0].bottle.stable.files | to_entries
| map(select(.key | test("(arm|linux)") | not))
| first.value'
| map(select(.key | test(\"${2}\") | not))
| first.value"
}
function fetch_bottle() {
@ -30,11 +30,12 @@ if [[ $(uname) != "Darwin" ]]; then
exit 1
fi
if [[ $# -ne 1 ]]; then
echo "usage: $0 <bottle_name>" >&2
if [[ $# -ne 2 ]]; then
echo "usage: $0 <bottle_name> <bottle_filter1|bottle_filter2>" >&2
exit 1
fi
BOTTLE_NAME="${1}"
BOTTLE_FILTER="${2}"
BOTTLE_PATH="/tmp/${BOTTLE_NAME}.tar.gz"
# GitHub Packages requires authentication.
@ -49,7 +50,9 @@ else
fi
echo "${BOTTLE_NAME} - Finding bottle URL"
BOTTLE_JSON=$(get_bottle_json "${BOTTLE_NAME}")
echo "Excluding: ${BOTTLE_FILTER}"
BOTTLE_JSON=$(get_bottle_json "${BOTTLE_NAME}" "${BOTTLE_FILTER}")
BOTTLE_URL=$(echo "${BOTTLE_JSON}" | jq -r .url)
BOTTLE_SHA=$(echo "${BOTTLE_JSON}" | jq -r .sha256)

View File

@ -8,6 +8,9 @@ import constants as main_constants
import app/global/global_singleton
import app/boot/app_controller
when defined(macosx) and defined(arm64):
import posix
logScope:
topics = "status-app"
@ -78,6 +81,19 @@ proc setupRemoteSignalsHandling() =
keycard_go.setSignalEventCallback(callbackKeycardGo)
proc mainProc() =
when defined(macosx) and defined(arm64):
echo "Experimental support for Apple Silicon"
var signalStack: cstring = cast[cstring](allocShared(SIGSTKSZ))
var ss: ptr Stack = cast[ptr Stack](allocShared0(sizeof(Stack)))
var ss2: ptr Stack = nil
ss.ss_sp = signalStack
ss.ss_flags = 0
ss.ss_size = SIGSTKSZ
if sigaltstack(ss[], ss2[]) < 0:
echo("sigaltstack error!")
quit()
if main_constants.IS_MACOS and defined(production):
setCurrentDir(getAppDir())