Author: jm
Date: 2011-06-15 12:40:05 -0700 (Wed, 15 Jun 2011)
New Revision: 25759

Added:
   csplugins/trunk/toronto/jm/repacker/extract_natives.py
Modified:
   csplugins/trunk/toronto/jm/repacker/genheaders.py
   csplugins/trunk/toronto/jm/repacker/repack.sh
Log:
Updated repacker so it can deal with specific OS/processor combinations properly


Added: csplugins/trunk/toronto/jm/repacker/extract_natives.py
===================================================================
--- csplugins/trunk/toronto/jm/repacker/extract_natives.py                      
        (rev 0)
+++ csplugins/trunk/toronto/jm/repacker/extract_natives.py      2011-06-15 
19:40:05 UTC (rev 25759)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import sys
+import re
+import os
+import shutil
+
+from os.path import walk, join
+
+source_pattern = re.compile('.*-natives-(.+)[.]jar')
+
+def process_natives(destination, directory, filenames):
+    for filename in filenames:
+        if filename.startswith('lib') or filename.endswith('.dll'):
+            source = join(directory, filename)
+            shutil.move(source, destination)
+
+def extract_natives(source_file, root, destination):
+    matcher = source_pattern.match(source_file)
+    if not matcher:
+        return
+    
+    platform = matcher.group(1)
+    native_directory = join(destination, platform)
+    try:
+        os.makedirs(native_directory)
+    except:
+        pass
+    walk(root, process_natives, native_directory)
+
+if __name__ == '__main__':
+    source_file = sys.argv[1]
+    destination = sys.argv[2]
+    root = '.'
+    extract_natives(source_file, root, destination)
\ No newline at end of file


Property changes on: csplugins/trunk/toronto/jm/repacker/extract_natives.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: csplugins/trunk/toronto/jm/repacker/genheaders.py
===================================================================
--- csplugins/trunk/toronto/jm/repacker/genheaders.py   2011-06-15 19:15:54 UTC 
(rev 25758)
+++ csplugins/trunk/toronto/jm/repacker/genheaders.py   2011-06-15 19:40:05 UTC 
(rev 25759)
@@ -5,19 +5,32 @@
 from zipfile import ZipFile
 
 patterns = [
-    [re.compile('lib(.+)[.](dylib|jnilib)'), 'mac os x'],
-    [re.compile('lib(.+)[.]so'), 'linux'],
-    [re.compile('lib(.+)[.]dll'), 'win32'],
+    re.compile('((.*)/)?lib(.+)[.](dylib|jnilib)'),
+    re.compile('((.*)/)?lib(.+)[.]so'),
+    re.compile('((.*)/)?(.+)[.]dll'),
 ]
 
+all_processors = {
+    'universal': ['x86', 'x86-64'],
+    'i586': ['x86'],
+    'amd64': ['x86-64'],
+}
+
+all_oses = {
+    'macosx': 'mac os x',
+    'windows': 'win32',
+    'linux': 'linux',
+}
+
 def generate_headers(name, fragment_host):
     zip = ZipFile(name, 'r')
-    processors = ['x86-64', 'x86']
     platforms = {}
     for entry in zip.namelist():
-        for pattern, platform in patterns:
+        for pattern in patterns:
             matcher = pattern.match(entry)
             if matcher:
+                platform = matcher.group(2)
+                print platform, entry
                 if platform not in platforms:
                     entries = []
                     platforms[platform] = entries
@@ -29,9 +42,11 @@
         return
     
     platform_entries = []
-    for processor in processors:
-        for platform, entries in platforms.items():
-            platform_entries.append('%s;osname=%s;processor=%s' % 
(';'.join(entries), platform, processor))
+    for platform, entries in platforms.items():
+        os, processor_name = platform.split('-')
+        os = all_oses[os]
+        for processor in all_processors[processor_name]:
+            platform_entries.append('%s;osname=%s;processor=%s' % 
(';'.join(entries), os, processor))
     
     properties = open('%s.properties' % name, 'w')
     print >> properties, 'Bundle-NativeCode=%s' % ','.join(platform_entries + 
['*'])

Modified: csplugins/trunk/toronto/jm/repacker/repack.sh
===================================================================
--- csplugins/trunk/toronto/jm/repacker/repack.sh       2011-06-15 19:15:54 UTC 
(rev 25758)
+++ csplugins/trunk/toronto/jm/repacker/repack.sh       2011-06-15 19:40:05 UTC 
(rev 25759)
@@ -11,13 +11,12 @@
 for JAR in "$@"
 do
     unzip -o "../${JAR}"
+    python ../extract_natives.py ${JAR} ../temp-natives
 done
-find . -name 'lib*[.]*' -exec mv "{}" ../temp-natives ";"
 
 jar cvf ../${BUNDLE_NAME}.jar *
 popd
 
-
 pushd temp-natives
 jar cvf ../${BUNDLE_NAME}-natives.jar *
 popd

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to