From c32e38a1c926be72928c7e4a9df71ad795b434da Mon Sep 17 00:00:00 2001 From: daid Date: Wed, 22 Feb 2012 15:58:22 +0100 Subject: [PATCH 1/3] Added check for windows to check for SSE2 instructions. Needs a custom executable :( --- .../skeinforge_application/skeinforge.py | 8 +++++++ build.sh | 9 ++++++++ checkSSE2/Makefile | 6 ++++++ checkSSE2/main.c | 21 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 checkSSE2/Makefile create mode 100644 checkSSE2/main.c diff --git a/SkeinPyPy/skeinforge_application/skeinforge.py b/SkeinPyPy/skeinforge_application/skeinforge.py index 33279a9..9afb64e 100755 --- a/SkeinPyPy/skeinforge_application/skeinforge.py +++ b/SkeinPyPy/skeinforge_application/skeinforge.py @@ -579,6 +579,14 @@ class SkeinforgeRepository: self.executeTitle = 'Skeinforge a file...' def getPyPyExe(self): + if platform.system() == "Windows": + checkSSE2exe = os.path.dirname(os.path.abspath(__file__)) + "/checkSSE2.exe" + if os.path.exists(checkSSE2exe): + if subprocess.call(checkSSE2exe) != 0: + print "*****************************************************" + print "* Your CPU is lacking SSE2 support, cannot use PyPy *" + print "*****************************************************" + return False if platform.system() == "Windows": pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/pypy.exe")); else: diff --git a/build.sh b/build.sh index 675b5b8..5240d64 100755 --- a/build.sh +++ b/build.sh @@ -110,6 +110,15 @@ fi #add Skeinforge cp -a SkeinPyPy ${TARGET_DIR}/SkeinPyPy +#Add the SSE2 check if we can build it +if [ $BUILD_TARGET = "win32" ]; then + WINCC=`whereis i386-mingw32-gcc` + if [ "$WINCC" != "" ]; then + make -C checkSSE2 CC=${WINCC} TARGET=checkSSE2.exe + cp checkSSE2/checkSSE2.exe ${TARGET_DIR}/SkeinPyPy + fi +fi + #add printrun mv Printrun ${TARGET_DIR}/Printrun diff --git a/checkSSE2/Makefile b/checkSSE2/Makefile new file mode 100644 index 0000000..02d7b57 --- /dev/null +++ b/checkSSE2/Makefile @@ -0,0 +1,6 @@ +CC ?= gcc +TARGET ?= checkSSE2 + +$(TARGET): main.c + $(CC) -o $(TARGET) main.c -Os + diff --git a/checkSSE2/main.c b/checkSSE2/main.c new file mode 100644 index 0000000..9c66aa9 --- /dev/null +++ b/checkSSE2/main.c @@ -0,0 +1,21 @@ +#include +#include + +//Read CPU flags, and return 0 if we support SSE2, else return 1 +//See: http://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits + +int main(int argc, char** argv) +{ + int features; + + //Read the CPU features. + asm("mov $1, %%eax\n" + "cpuid\n" + "mov %%edx, %0" + : "=r"(features) : : "%eax", "%edx", "%ecx"); + + //Check bit 26, this indicates SSE2 support + if (features & (1 << 26)) + return 0; + return 1; +} \ No newline at end of file From e09b08c85e5cc85263ca2e8730b65fc2fa4e72ea Mon Sep 17 00:00:00 2001 From: daid Date: Wed, 22 Feb 2012 16:06:53 +0100 Subject: [PATCH 2/3] Added same patch for checkSSE2 to newUI version --- SkeinPyPy_NewUI/newui/skeinRun.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SkeinPyPy_NewUI/newui/skeinRun.py b/SkeinPyPy_NewUI/newui/skeinRun.py index 08be13c..8c86237 100644 --- a/SkeinPyPy_NewUI/newui/skeinRun.py +++ b/SkeinPyPy_NewUI/newui/skeinRun.py @@ -6,6 +6,14 @@ from skeinforge_application.skeinforge_utilities import skeinforge_craft def getPyPyExe(): "Return the path to the pypy executable if we can find it. Else return False" + if platform.system() == "Windows": + checkSSE2exe = os.path.dirname(os.path.abspath(__file__)) + "/checkSSE2.exe" + if os.path.exists(checkSSE2exe): + if subprocess.call(checkSSE2exe) != 0: + print "*****************************************************" + print "* Your CPU is lacking SSE2 support, cannot use PyPy *" + print "*****************************************************" + return False if platform.system() == "Windows": pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/pypy.exe")); else: From 535854ab0fe28385e44299a201ccd89251ebdacd Mon Sep 17 00:00:00 2001 From: daid Date: Wed, 22 Feb 2012 18:44:14 +0100 Subject: [PATCH 3/3] Added some clean actions to build, which save a lot of final package size --- build.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 5240d64..358c743 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,8 @@ #!/bin/bash +# This script is to build the SkeinPyPy package for Windows/Linux and OSx +# This script should run under Linux and OSx, as well as Windows with Cygwin. + ############################# # CONFIGURATION ############################# @@ -96,6 +99,16 @@ if [ $BUILD_TARGET = "win32" ]; then mv PURELIB/serial ${TARGET_DIR}/python/Lib rm -rf \$_OUTDIR rm -rf PURELIB + + #Clean up portable python a bit, to keep the package size down. + rm -rf ${TARGET_DIR}/python/PyScripter.* + rm -rf ${TARGET_DIR}/python/Doc + rm -rf ${TARGET_DIR}/python/locale + #rm -rf ${TARGET_DIR}/python/tcl + rm -rf ${TARGET_DIR}/python/Lib/test + rm -rf ${TARGET_DIR}/python/Lib/distutils + rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-2.8-msw-unicode/wx/tools + rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-2.8-msw-unicode/wx/locale fi #Extract pypy @@ -106,11 +119,14 @@ else cd ${TARGET_DIR}; $TAR -xjf ../pypy-${PYPY_VERSION}-${BUILD_TARGET}.tar.bz2; cd .. mv ${TARGET_DIR}/pypy-${PYPY_VERSION} ${TARGET_DIR}/pypy fi +#Cleanup pypy +rm -rf ${TARGET_DIR}/pypy/lib-python/2.7/test #add Skeinforge cp -a SkeinPyPy ${TARGET_DIR}/SkeinPyPy -#Add the SSE2 check if we can build it +#Add the SSE2 check if we can build it, else we skip it. +# If we don't have it SkeinPyPy will still function. But crash on machines that don't have SSE2 if [ $BUILD_TARGET = "win32" ]; then WINCC=`whereis i386-mingw32-gcc` if [ "$WINCC" != "" ]; then @@ -131,6 +147,7 @@ cp README ${TARGET_DIR}/README.txt #package the result if (( ${ARCHIVE_FOR_DISTRIBUTION} )); then if [ $BUILD_TARGET = "win32" ]; then + rm ${TARGET_DIR}.zip cd ${TARGET_DIR} 7z a ../${TARGET_DIR}.zip * cd ..