Add Apple Silicon support

This commit is contained in:
SamJakob 2023-11-08 15:04:19 +00:00
parent 4d50c3db49
commit 5d27a6cb4b
No known key found for this signature in database
GPG Key ID: 607AC91837DBB115
7 changed files with 62 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,13 @@ 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.
if platform.processor().startswith("arm"):
scythername = "scyther-mac-arm"
else:
scythername = "scyther-mac"
elif sys.platform.startswith('win'): elif sys.platform.startswith('win'):

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")
@ -17,7 +16,7 @@ set (Scyther_sources
arachne.c binding.c claim.c color.c compiler.c cost.c arachne.c binding.c claim.c color.c compiler.c cost.c
debug.c depend.c dotout.c error.c heuristic.c hidelevel.c debug.c depend.c dotout.c error.c heuristic.c hidelevel.c
intruderknowledge.c knowledge.c label.c list.c main.c mgu.c intruderknowledge.c knowledge.c label.c list.c main.c mgu.c
prune_bounds.c prune_theorems.c role.c prune_bounds.c prune_theorems.c role.c
specialterm.c states.c switches.c symbol.c system.c tac.c specialterm.c states.c switches.c symbol.c system.c tac.c
tempfile.c tempfile.c
termlist.c termmap.c term.c timer.c type.c warshall.c xmlout.c termlist.c termmap.c term.c timer.c type.c warshall.c xmlout.c

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 Normal 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 "---------------------------------------------------------"