diff --git a/gui/Scyther/Scyther.py b/gui/Scyther/Scyther.py index 1232f23..4b2f31c 100755 --- a/gui/Scyther/Scyther.py +++ b/gui/Scyther/Scyther.py @@ -30,6 +30,8 @@ import os.path import sys import io import tempfile +import platform + try: import hashlib HASHLIB = True @@ -170,7 +172,13 @@ 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. + if platform.processor().startswith("arm"): + scythername = "scyther-mac-arm" + else: + scythername = "scyther-mac" elif sys.platform.startswith('win'): diff --git a/src/BuildMacArm.cmake b/src/BuildMacArm.cmake new file mode 100644 index 0000000..8183577 --- /dev/null +++ b/src/BuildMacArm.cmake @@ -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") diff --git a/src/BuildMacIntel.cmake b/src/BuildMacIntel.cmake index 6ad6e16..0272a1e 100644 --- a/src/BuildMacIntel.cmake +++ b/src/BuildMacIntel.cmake @@ -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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72a1df5..0f413db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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") @@ -17,7 +16,7 @@ set (Scyther_sources arachne.c binding.c claim.c color.c compiler.c cost.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 - 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 tempfile.c termlist.c termmap.c term.c timer.c type.c warshall.c xmlout.c diff --git a/src/GetOS.cmake b/src/GetOS.cmake index 981ed7a..aabe6f9 100644 --- a/src/GetOS.cmake +++ b/src/GetOS.cmake @@ -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) diff --git a/src/build.sh b/src/build.sh index 30b8316..dfbabd0 100755 --- a/src/build.sh +++ b/src/build.sh @@ -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 diff --git a/src/subbuild-mac-arm.sh b/src/subbuild-mac-arm.sh new file mode 100644 index 0000000..ceaca01 --- /dev/null +++ b/src/subbuild-mac-arm.sh @@ -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 "---------------------------------------------------------"