Merge pull request #36 from SamJakob/master

Add Apple Silicon Support
This commit is contained in:
Cas Cremers 2023-11-09 21:40:36 +01:00 committed by GitHub
commit aaeed080fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 75 additions and 15 deletions

View File

@ -30,6 +30,8 @@ import os.path
import sys
import io
import tempfile
import platform
try:
import hashlib
HASHLIB = True
@ -170,7 +172,15 @@ def getScytherBackend():
elif "darwin" in sys.platform:
""" OS X """
scythername = "scyther-mac"
# Check if there is an ARM version available at scyther-mac-arm
# Otherwise, just fallback to the default scyther-mac which is the
# Intel version for backwards-compatibility reasons.
has_arm_build = os.path.exists(os.path.join(getBinDir(),"scyther-mac-arm"))
if platform.processor().startswith("arm") and has_arm_build:
scythername = "scyther-mac-arm"
else:
scythername = "scyther-mac"
elif sys.platform.startswith('win'):

View File

@ -0,0 +1,11 @@
################################################################
# Name: BuildMacIntel.cmake
# Purpose: Build MacIntel binary
# Author: Cas Cremers
################################################################
message (STATUS "Building Apple Mac Intel version (cross-compiling)")
set (scythername "scyther-mac")
add_executable (${scythername} ${Scyther_sources})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6 -arch x86_64")
set (CMAKE_OSX_ARCHITECTURES "x86_64")

10
src/BuildMacArm.cmake Normal file
View File

@ -0,0 +1,10 @@
################################################################
# Name: BuildMacArm.cmake
# Purpose: Build MacArm binary
# Author: Sam Jakob M.
################################################################
message (STATUS "Building Apple Mac ARM (Apple Silicon) version")
set (scythername "scyther-mac")
add_executable (${scythername} ${Scyther_sources})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.15")

View File

@ -7,5 +7,5 @@
message (STATUS "Building Apple Mac Intel version")
set (scythername "scyther-mac")
add_executable (${scythername} ${Scyther_sources})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.6 -arch x86_64")
set (CMAKE_OSX_ARCHITECTURES "x86_64")

View File

@ -6,8 +6,7 @@
# Scyther project
project (Scyther)
# I need 2.4 for flex/etc although it does not run yet
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
CMAKE_MINIMUM_REQUIRED(VERSION 2.18)
# Try clang
#set (CMAKE_C_COMPILER "clang")

View File

@ -18,9 +18,13 @@ if (WIN32)
else (WIN32)
# Not windows, is it a mac?
if (APPLE)
# TODO: A mac, but what architecture?
# For now we assume intel
set (Source_OS "MacIntel")
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64" AND NOT DEFINED ENV{ARCH})
# If Apple and Arm64, set Source_OS to MacArm
set(Source_OS "MacArm")
else(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64" AND NOT DEFINED ENV{ARCH})
# If not arm64, assume Intel for legacy reasons.
set(Source_OS "MacIntel")
endif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64" AND NOT DEFINED ENV{ARCH})
else (APPLE)
# Not a mac, not windows
if (UNIX)

View File

@ -5,13 +5,19 @@
# Different choice if on Darwin
PLATFORM=`uname`
echo $PLATFORM
if [ "$PLATFORM" = "Darwin" ]
then
./subbuild-mac-intel.sh
echo "Platform: $PLATFORM"
if [ "$PLATFORM" = "Darwin" ]; then
ARCH=`arch`
echo "Architecture: $ARCH"
if [ "$ARCH" = "arm64" ]; then
./subbuild-mac-arm.sh
else
./subbuild-mac-intel.sh
fi
else
if [ "$PLATFORM" = "Linux" ]
then
if [ "$PLATFORM" = "Linux" ]; then
# Build linux version
./subbuild-unix-unix.sh
else

20
src/subbuild-mac-arm.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
# Default flags
CMFLAGS="-D CMAKE_BUILD_TYPE:STRING=Release"
# Make for intel
cmake $CMFLAGS -D TARGETOS=MacArm . && make scyther-mac
echo
echo
echo "---------------------------------------------------------"
echo "Built the Mac ARM binary"
# Copy to the correct locations
cp scyther-mac ../gui/Scyther/scyther-mac-arm
echo Copied the files to their respective locations
echo "---------------------------------------------------------"