Compare commits
10 Commits
e9578bcffd
...
50f3324c10
| Author | SHA1 | Date | |
|---|---|---|---|
| 50f3324c10 | |||
|
|
2a698faef3 | ||
|
|
aaeed080fb | ||
|
|
ac40694691 | ||
|
|
5ea557e0a3 | ||
|
|
cb054f92b8 | ||
|
|
149c9d737e | ||
|
|
8073fed85e | ||
|
|
5d27a6cb4b | ||
|
|
4d50c3db49 |
9
Makefile
9
Makefile
@@ -1,10 +1,13 @@
|
||||
# Make recurse into 'src' directory
|
||||
.PHONY: default clean
|
||||
.PHONY: default clean manual
|
||||
|
||||
default:
|
||||
cd src; ./build.sh
|
||||
|
||||
|
||||
manual:
|
||||
cd manual; make
|
||||
|
||||
clean:
|
||||
cd src; make clean; cd ..
|
||||
cd src; make clean
|
||||
|
||||
|
||||
|
||||
@@ -152,6 +152,12 @@ class EditorStc(Editor):
|
||||
self.errorstyle = 5
|
||||
self.control.StyleSetSpec(self.errorstyle, "fore:#FFFF0000,back:#FF0000")
|
||||
|
||||
try:
|
||||
if wx.SystemSettings.GetAppearance().IsDark():
|
||||
self.control.StyleSetSpec(STC_STYLE_LINENUMBER, "fore:#FFFFFF")
|
||||
except:
|
||||
pass
|
||||
|
||||
def GetText(self):
|
||||
return self.control.GetText()
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
import wx
|
||||
import os.path
|
||||
|
||||
from time import sleep
|
||||
|
||||
import threading
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
""" Import scyther-gui components """
|
||||
@@ -42,6 +46,8 @@ ID_VERIFY = 100
|
||||
ID_AUTOVERIFY = 101
|
||||
ID_CHARACTERIZE = 102
|
||||
ID_CHECK = 103
|
||||
ID_WATCH = 104
|
||||
ID_STOP_WATCH = 105
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -63,6 +69,9 @@ class MainWindow(wx.Frame):
|
||||
self.filename = ''
|
||||
self.filepath = ""
|
||||
|
||||
self.watchfile = None
|
||||
self.watchThread = None
|
||||
|
||||
self.load = False
|
||||
|
||||
# test
|
||||
@@ -162,6 +171,8 @@ class MainWindow(wx.Frame):
|
||||
(wx.ID_NEW, '&New\tCTRL-N', 'Create a new file', self.OnNew),
|
||||
(wx.ID_OPEN, '&Open\tCTRL-O', 'Open a new file', self.OnOpen),
|
||||
(wx.ID_SAVE, '&Save\tCTRL-S', 'Save the current file', self.OnSave),
|
||||
(ID_WATCH, 'Watch', 'Whatch a file for changes', self.OnWatch),
|
||||
(ID_STOP_WATCH, 'Stop Watch', 'Stop watching for changes', self.OnStopWatch),
|
||||
(wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
|
||||
self.OnSaveAs),
|
||||
(None, None, None, None),
|
||||
@@ -188,7 +199,10 @@ class MainWindow(wx.Frame):
|
||||
def SetTitle(self):
|
||||
# MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to
|
||||
# call it using super:
|
||||
super(MainWindow, self).SetTitle('Scyther: %s'%self.filename)
|
||||
if self.filename:
|
||||
super(MainWindow, self).SetTitle('Scyther: %s'%self.filename)
|
||||
else:
|
||||
super(MainWindow, self).SetTitle('Scyther: Unsaved File...')
|
||||
|
||||
# Helper methods:
|
||||
|
||||
@@ -214,8 +228,7 @@ class MainWindow(wx.Frame):
|
||||
return userProvidedFilename
|
||||
|
||||
# Are we dropping a changed file?
|
||||
|
||||
def ConfirmLoss(self,text=None):
|
||||
def ConfirmLoss(self):
|
||||
"""
|
||||
Try to drop the current file. If it was changed, try to save
|
||||
(as)
|
||||
@@ -226,16 +239,18 @@ class MainWindow(wx.Frame):
|
||||
if self.editor.GetChanged():
|
||||
# File changed, we need to confirm this
|
||||
title = "Unsaved changes"
|
||||
if text:
|
||||
title = "%s - " + title
|
||||
txt = "The protocol file '%s' has been modified.\n\n" % (self.filename)
|
||||
if self.filename:
|
||||
title = ("%s - " + title) % (self.filename)
|
||||
txt = "The protocol file '%s' has been modified.\n\n" % (self.filename)
|
||||
else:
|
||||
txt = "You have unsaved changes.\n\n"
|
||||
txt = txt + "Do you want to"
|
||||
txt = txt + " save your changes (Yes)"
|
||||
txt = txt + " or"
|
||||
txt = txt + " discard them (No)"
|
||||
txt = txt + "?"
|
||||
dialog = wx.MessageDialog(self,txt,title,wx.YES_NO | wx.CANCEL | wx.ICON_EXCLAMATION)
|
||||
result = dialog.ShowModal()
|
||||
result = dialog.ShowModal()
|
||||
dialog.Destroy()
|
||||
if result == wx.ID_NO:
|
||||
# Drop changes
|
||||
@@ -263,19 +278,74 @@ class MainWindow(wx.Frame):
|
||||
dlg.Destroy()
|
||||
|
||||
def OnExit(self, event):
|
||||
if self.ConfirmLoss("Exit"):
|
||||
if self.ConfirmLoss():
|
||||
self.Close() # Close the main window.
|
||||
return True
|
||||
return False
|
||||
|
||||
def OnNew(self, event):
|
||||
if self.ConfirmLoss("Open"):
|
||||
if self.ConfirmLoss():
|
||||
self.editor.SetText('')
|
||||
self.filename = ''
|
||||
self.editor.SetOpened()
|
||||
self.SetTitle()
|
||||
return True
|
||||
return False
|
||||
|
||||
def OnWatch(self, event):
|
||||
if self.watchfile != None or self.watchThread != None:
|
||||
self.watchfile = None
|
||||
self.watchThread.join()
|
||||
self.watchThread = None
|
||||
|
||||
if self.ConfirmLoss():
|
||||
if self.askUserForFilename(style=wx.FD_OPEN, **self.defaultFileDialogOptions()):
|
||||
|
||||
self.editor.SetText("")
|
||||
self.editor.SetOpened()
|
||||
|
||||
self.editor.control.Enable(False)
|
||||
|
||||
name = str(self.filename)
|
||||
|
||||
self.watchfile = name
|
||||
|
||||
def runMain():
|
||||
while name == self.watchfile:
|
||||
textfile = open(os.path.join(self.dirname, self.filename), 'r')
|
||||
|
||||
data = textfile.read()
|
||||
|
||||
if data != self.editor.GetText():
|
||||
self.editor.SetText(data)
|
||||
textfile.close()
|
||||
self.editor.SetOpened()
|
||||
|
||||
# Clear errors before verification
|
||||
self.editor.SetErrors(None)
|
||||
# Verify spdl
|
||||
s = Scytherthread.ScytherRun(self,"verify",data,self.editor.SetErrors, watchMode=True, watchModeFile=self.filename)
|
||||
|
||||
sleep(0.9)
|
||||
|
||||
self.watchThread = threading.Thread(target=runMain)
|
||||
|
||||
self.watchThread.start()
|
||||
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def OnStopWatch(self, event):
|
||||
self.watchfile = None
|
||||
thread = self.watchThread
|
||||
self.watchThread = None
|
||||
thread.join()
|
||||
self.editor.control.Enable(True)
|
||||
self.editor.SetText("")
|
||||
self.editor.SetOpened()
|
||||
return True
|
||||
|
||||
def OnSave(self, event):
|
||||
if self.filename=='':
|
||||
return self.OnSaveAs(event)
|
||||
@@ -287,7 +357,7 @@ class MainWindow(wx.Frame):
|
||||
return True
|
||||
|
||||
def OnOpen(self, event):
|
||||
if self.ConfirmLoss("Open"):
|
||||
if self.ConfirmLoss():
|
||||
if self.askUserForFilename(style=wx.FD_OPEN,
|
||||
**self.defaultFileDialogOptions()):
|
||||
textfile = open(os.path.join(self.dirname, self.filename), 'r')
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
""" Import externals """
|
||||
import wx
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -39,6 +40,8 @@ from . import Icon
|
||||
from . import Error
|
||||
from . import Makeimage
|
||||
|
||||
from .Misc import dotOutputWrite
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if Preference.havePIL:
|
||||
import Image
|
||||
@@ -254,7 +257,7 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
def __init__(
|
||||
self, parent, parentwindow, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
|
||||
style=wx.DEFAULT_DIALOG_STYLE
|
||||
style=wx.DEFAULT_DIALOG_STYLE, watchMode = False, watchModeFile = None
|
||||
):
|
||||
|
||||
wx.Frame.__init__(self,parentwindow,-1,title,pos,size,style)
|
||||
@@ -263,6 +266,8 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
self.parent = parent
|
||||
self.thread = None
|
||||
self.watchMode = watchMode
|
||||
self.watchModeFile = watchModeFile
|
||||
aTable = wx.AcceleratorTable([
|
||||
(wx.ACCEL_CTRL, ord('W'), wx.ID_CLOSE),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CLOSE),
|
||||
@@ -277,12 +282,18 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
def onViewButton(self,evt):
|
||||
btn = evt.GetEventObject()
|
||||
try:
|
||||
w = Attackwindow.AttackWindow(btn.claim)
|
||||
w.Show(True)
|
||||
except Error.PILError:
|
||||
Error.ShowAndReturn("Problem with PIL imaging library: disabled zooming. Please retry to verify the protocol again.")
|
||||
self.onCloseWindow(None)
|
||||
|
||||
if self.watchMode:
|
||||
print("Watching generating image")
|
||||
dotOutputWrite(btn.claim.attacks[0].scytherDot, self.watchModeFile + ".png",["-Tpng"])
|
||||
subprocess.run(['xdg-open', self.watchModeFile + ".png"])
|
||||
else:
|
||||
try:
|
||||
w = Attackwindow.AttackWindow(btn.claim)
|
||||
w.Show(True)
|
||||
except Error.PILError:
|
||||
Error.ShowAndReturn("Problem with PIL imaging library: disabled zooming. Please retry to verify the protocol again.")
|
||||
self.onCloseWindow(None)
|
||||
|
||||
def onCloseWindow(self,evt):
|
||||
""" TODO we should kill self.thread """
|
||||
@@ -423,8 +434,10 @@ class ResultWindow(wx.Frame):
|
||||
|
||||
class ScytherRun(object):
|
||||
|
||||
def __init__(self,mainwin,mode,spdl,errorcallback=None):
|
||||
def __init__(self,mainwin,mode,spdl,errorcallback=None, watchMode=False, watchModeFile = None):
|
||||
|
||||
self.watchMode = watchMode
|
||||
self.watchModeFile = watchModeFile
|
||||
self.mainwin = mainwin
|
||||
self.mode = mode
|
||||
self.spdl = spdl
|
||||
@@ -505,7 +518,7 @@ class ScytherRun(object):
|
||||
|
||||
# Great, we verified stuff, progress to the claim report
|
||||
title = "Scyther results : %s" % self.mode
|
||||
self.resultwin = resultwin = ResultWindow(self,self.mainwin,title)
|
||||
self.resultwin = resultwin = ResultWindow(self,self.mainwin,title, watchMode=self.watchMode, watchModeFile=self.watchModeFile)
|
||||
|
||||
def attackDone(attack,total,done):
|
||||
if resultwin:
|
||||
|
||||
@@ -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'):
|
||||
|
||||
|
||||
BIN
gui/nsl3-broken.spdl.png
Normal file
BIN
gui/nsl3-broken.spdl.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
@@ -157,45 +157,6 @@ def parseArgs():
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MySplashScreen(WXPYTHONINFREQ.SplashScreen):
|
||||
def __init__(self,basedir):
|
||||
path = os.path.join(basedir,"Images")
|
||||
image = os.path.join(path,"scyther-splash.png")
|
||||
bmp = wx.Image(image).ConvertToBitmap()
|
||||
wx.SplashScreen.__init__(self, bmp,
|
||||
wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
|
||||
5000, None, -1)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnClose)
|
||||
self.fc = wx.FutureCall(2000, self.ShowMain)
|
||||
|
||||
def OnClose(self, evt):
|
||||
# Make sure the default handler runs too so this window gets
|
||||
# destroyed
|
||||
evt.Skip()
|
||||
self.Hide()
|
||||
|
||||
# if the timer is still running then go ahead and show the
|
||||
# main frame now
|
||||
if self.fc.IsRunning():
|
||||
self.fc.Stop()
|
||||
self.ShowMain()
|
||||
|
||||
|
||||
def ShowMain(self):
|
||||
if self.fc.IsRunning():
|
||||
self.Raise()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def isSplashNeeded(opts):
|
||||
if not opts.command:
|
||||
if opts.splashscreen and not (Preference.get('splashscreen') in ['false','off','disable','0']):
|
||||
return True
|
||||
return False
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class ScytherApp(wx.App):
|
||||
def OnInit(self):
|
||||
import os, inspect
|
||||
@@ -232,11 +193,6 @@ class ScytherApp(wx.App):
|
||||
self.SetTopWindow(self.mainWindow)
|
||||
self.mainWindow.Show()
|
||||
|
||||
if isSplashNeeded(opts):
|
||||
dlg = About.AboutScyther(self.mainWindow,basedir)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
return True
|
||||
|
||||
#def OnExit(self):
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
### Build process
|
||||
|
||||
- Ensure manual build is triggered from root directory Makefile, ideally after checking for the dependencies.
|
||||
- Ensure manual build is triggered from root directory Makefile, ideally after checking for the dependencies. (Partially done: `make manual` from root dir works now.)
|
||||
|
||||
### To document
|
||||
|
||||
|
||||
11
src/BuildMacArm-MacIntel.cmake
Normal file
11
src/BuildMacArm-MacIntel.cmake
Normal 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
10
src/BuildMacArm.cmake
Normal 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")
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
18
src/build.sh
18
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
|
||||
|
||||
20
src/subbuild-mac-arm.sh
Executable file
20
src/subbuild-mac-arm.sh
Executable 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 "---------------------------------------------------------"
|
||||
1
src/version.h
Normal file
1
src/version.h
Normal file
@@ -0,0 +1 @@
|
||||
#define TAGVERSION "b'v1.2-25-g2a698fa'"
|
||||
Reference in New Issue
Block a user