From fafcb39f354c890b8dba04b5db0e31ea7a188c99 Mon Sep 17 00:00:00 2001 From: arokem Date: Fri, 20 Jun 2014 16:36:30 -0700 Subject: [PATCH 1/2] Working towards a better build experience. --- messenger/{mexmaci64 => }/make.py | 18 ++++++++- messenger/mexa64/make.py | 61 ------------------------------- messenger/mexmaci64/local.cfg | 2 +- 3 files changed, 17 insertions(+), 64 deletions(-) rename messenger/{mexmaci64 => }/make.py (77%) delete mode 100755 messenger/mexa64/make.py diff --git a/messenger/mexmaci64/make.py b/messenger/make.py similarity index 77% rename from messenger/mexmaci64/make.py rename to messenger/make.py index 8b82177..3ea8c71 100755 --- a/messenger/mexmaci64/make.py +++ b/messenger/make.py @@ -4,13 +4,25 @@ import sys import fnmatch import subprocess +import shutil # Check the system platform first platform = sys.platform print "This is a " + platform + " system" +if platform.startswith('linux'): + messenger_dir = 'mexa64' +elif platform.startswith('darwin'): + messenger_dir = 'mexmaci64' +if platform.startswith('win32'): + windowsversion = sys.getwindowsversion() + if windowsversion == 'foo': + messenger_dir = 'mexw32' + elif windowsversion == 'bar': + messenger_dir = 'mexw64' + # Open the configure file and start parsing -config = open('local.cfg', 'r') +config = open(os.path.join(messenger_dir, 'local.cfg'), 'r') for line in config: path = line.split('=') @@ -56,6 +68,8 @@ mex = "\\mex.bat" else: mex = "/mex" -make_cmd = '"' + matlab_bin + mex + '"' + " -O -I" + header_path + " -L" + lib_path + " -lzmq ../src/messenger.c" +make_cmd = '"' + matlab_bin + mex + '"' + " -O -I" + header_path + " -L" + lib_path + " -lzmq ./src/messenger.c" os.system(make_cmd) +shutil.move('messenger.%s'%extension, messenger_dir) + diff --git a/messenger/mexa64/make.py b/messenger/mexa64/make.py deleted file mode 100755 index d76b675..0000000 --- a/messenger/mexa64/make.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python - -import os -import sys -import fnmatch -import subprocess - -# Check the system platform first -platform = sys.platform -print "This is a " + platform + " system" - -# Open the configure file and start parsing -config = open('local.cfg', 'r') - -for line in config: - path = line.split('=') - - if path[0] == "MATLAB_BIN": - print "Searching for Matlab bin folder in local.cfg ..." - matlab_bin = path[1].rstrip('\r\n') - if matlab_bin == "": - raise ValueError("Could not find Matlab bin folder. Please add it to local.cfg") - print "Matlab found in " + matlab_bin - - elif path[0] == "HEADER_PATH": - print "Searching for zmq.h in local.cfg ..." - header_path = path[1].rstrip('\r\n') - if header_path == "": - raise ValueError("Could not find zmq.h. Please add its path to local.cfg") - print "zmq.h found in " + header_path - - elif path[0] == "LIB_PATH": - print "Searching for zmq library in local.cfg ..." - lib_path = path[1].rstrip('\r\n') - if lib_path == "": - raise ValueError("Could not find zmq library. Please add its path to local.cfg") - - print "zmq library found in " + lib_path - -config.close() - -# Get the extension -if platform == 'win32': - extcmd = '"' + matlab_bin + "\\mexext.bat" + '"' - check_extension = subprocess.Popen(extcmd, stdout = subprocess.PIPE) - extension = check_extension.stdout.readline().rstrip('\r\n') -else: - extcmd = matlab_bin + "/mexext" - check_extension = subprocess.Popen(extcmd, stdout = subprocess.PIPE) - extension = check_extension.stdout.readline().rstrip('\r\n') - -print "Building messenger." + extension + " ..." - -# Build the mex file -if platform == 'win32': - mex = "\\mex.bat" -else: - mex = "/mex" -make_cmd = '"' + matlab_bin + mex + '"' + " -v -I" + header_path + " -L" + lib_path + " -lzmq ../src/messenger.c" -os.system(make_cmd) - diff --git a/messenger/mexmaci64/local.cfg b/messenger/mexmaci64/local.cfg index d8d9ff6..b83ed1d 100644 --- a/messenger/mexmaci64/local.cfg +++ b/messenger/mexmaci64/local.cfg @@ -1,3 +1,3 @@ -MATLAB_BIN=/Applications/MATLAB_R2012a.app/bin +MATLAB_BIN=/Applications/MATLAB_R2012b.app/bin HEADER_PATH=/usr/include LIB_PATH=/usr/local/lib From af6e3655e730e9ef1e7bc92d80792ad7baa76476 Mon Sep 17 00:00:00 2001 From: arokem Date: Sun, 22 Jun 2014 12:16:39 -0700 Subject: [PATCH 2/2] Use maxint to differentiate 32 bit from 64 bit Windows. --- messenger/make.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/messenger/make.py b/messenger/make.py index 3ea8c71..cc35a94 100755 --- a/messenger/make.py +++ b/messenger/make.py @@ -15,12 +15,13 @@ elif platform.startswith('darwin'): messenger_dir = 'mexmaci64' if platform.startswith('win32'): - windowsversion = sys.getwindowsversion() - if windowsversion == 'foo': - messenger_dir = 'mexw32' - elif windowsversion == 'bar': + # We further need to differniate 32 from 64 bit: + maxint = sys.maxint() + if maxint == 9223372036854775807: messenger_dir = 'mexw64' - + elif maxint == 2147483647: + messenger_dir = 'mexw32' + # Open the configure file and start parsing config = open(os.path.join(messenger_dir, 'local.cfg'), 'r')