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 sys
import io import io
import tempfile import tempfile
import platform
try: try:
import hashlib import hashlib
HASHLIB = True HASHLIB = True
@ -170,7 +172,15 @@ def getScytherBackend():
elif "darwin" in sys.platform: elif "darwin" in sys.platform:
""" OS X """ """ 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'): 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") message (STATUS "Building Apple Mac Intel version")
set (scythername "scyther-mac") set (scythername "scyther-mac")
add_executable (${scythername} ${Scyther_sources}) 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 # Scyther project
project (Scyther) project (Scyther)
# I need 2.4 for flex/etc although it does not run yet CMAKE_MINIMUM_REQUIRED(VERSION 2.18)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
# Try clang # Try clang
#set (CMAKE_C_COMPILER "clang") #set (CMAKE_C_COMPILER "clang")

View File

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

View File

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