[GRASS-SVN] r49271 - grass-addons/tools/addons

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 16 10:15:56 EST 2011


Author: martinl
Date: 2011-11-16 07:15:55 -0800 (Wed, 16 Nov 2011)
New Revision: 49271

Modified:
   grass-addons/tools/addons/build-xml.py
   grass-addons/tools/addons/compile-xml.sh
   grass-addons/tools/addons/compile.sh
Log:
addons management: updated supporting scripts


Modified: grass-addons/tools/addons/build-xml.py
===================================================================
--- grass-addons/tools/addons/build-xml.py	2011-11-16 15:13:44 UTC (rev 49270)
+++ grass-addons/tools/addons/build-xml.py	2011-11-16 15:15:55 UTC (rev 49271)
@@ -2,10 +2,12 @@
 
 import os
 import sys
+import glob
 
 def get_list(addons):
-    mlist = os.listdir(os.path.join(addons, 'bin')) + \
-        os.listdir(os.path.join(addons, 'scripts'))
+    mlist = os.listdir(os.path.join(addons))
+    for f in ('log', 'make.log', 'modules.xml'):
+        mlist.remove(f)
     mlist.sort()
     return mlist
 
@@ -28,9 +30,6 @@
     gsetup.init(gisbase,
                 gisdbase, location, mapset)
  
-    os.environ['PATH'] += os.pathsep + os.path.join(sys.argv[1], 'bin') + os.pathsep + \
-        os.path.join(sys.argv[1], 'scripts')
-
 def parse_modules(fd, mlist):
     indent = 4
     for m in mlist:
@@ -40,18 +39,46 @@
         indent += 4
         fd.write('%s<description>%s</description>\n' % (' ' * indent, desc))
         fd.write('%s<keywords>%s</keywords>\n' % (' ' * indent, ','.join(keyw)))
+        fd.write('%s<binary>\n' % (' ' * indent))
+        indent += 4
+        for f in get_module_files(m):
+            fd.write('%s<file>%s</file>\n' % (' ' * indent, f))
         indent -= 4
+        fd.write('%s</binary>\n' % (' ' * indent))
+        indent -= 4
         fd.write('%s</task>\n' % (' ' * indent))
         if desc:
             print " SUCCESS"
         else:
             print " FAILED"
+  
+
+def scandirs(path):
+    flist = list()
+    for f in glob.glob(os.path.join(path, '*') ):
+        if os.path.isdir(f):
+            flist += scandirs(f)
+        else:
+            flist.append(f)
     
+    return flist
+
+def get_module_files(name):
+    os.chdir(os.path.join(sys.argv[1], name))
+    return scandirs('*')
+                    
 def get_module_metadata(name):
     import grass.script.task as gtask
+    path = os.environ['PATH']
+    os.environ['PATH'] += os.pathsep + os.path.join(sys.argv[1], name, 'bin') + os.pathsep + \
+        os.path.join(sys.argv[1], name, 'scripts')
     try:
         task = gtask.parse_interface(name)
     except:
+        task = None
+
+    os.environ['PATH'] = path
+    if not task:
         return '', ''
     
     return task.get_description(full = True), \
@@ -61,10 +88,10 @@
     import grass.script.core as grass
     fd.write('<?xml version="1.0" encoding="UTF-8"?>\n')
     fd.write('<!DOCTYPE task SYSTEM "grass-addons.dtd">\n') # TODO
-    fd.write('<modules version=%s>\n' % grass.version()['version'])
+    fd.write('<addons version="%s">\n' % grass.version()['version'])
 
 def footer(fd):
-    fd.write('</modules>\n')
+    fd.write('</addons>\n')
 
 def main():
     if len(sys.argv) < 2:

Modified: grass-addons/tools/addons/compile-xml.sh
===================================================================
--- grass-addons/tools/addons/compile-xml.sh	2011-11-16 15:13:44 UTC (rev 49270)
+++ grass-addons/tools/addons/compile-xml.sh	2011-11-16 15:15:55 UTC (rev 49271)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 compile() {
-    ./compile.sh $1 $2 $3
+    ./compile.sh $1 $2 $3 1
 }
 
 build_xml() {

Modified: grass-addons/tools/addons/compile.sh
===================================================================
--- grass-addons/tools/addons/compile.sh	2011-11-16 15:13:44 UTC (rev 49270)
+++ grass-addons/tools/addons/compile.sh	2011-11-16 15:15:55 UTC (rev 49271)
@@ -1,8 +1,8 @@
 #!/bin/sh
 
 if [ -z "$3" ]; then
-    echo "usage: $0 svn_path topdir addons_path"
-    echo "eg. $0 ~/src/grass-addons/grass7/ ~/src/grass_trunk/dist.i686-pc-linux-gnu/ ~/.grass7/addons"
+    echo "usage: $0 svn_path topdir addons_path [separate]"
+    echo "eg. $0 ~/src/grass-addons/grass7/ ~/src/grass_trunk/dist.x86_64-unknown-linux-gnu ~/.grass7/addons"
     exit 1
 fi
 
@@ -10,6 +10,12 @@
 TOPDIR="$2"
 ADDON_PATH="$3"
 
+if [ -n "$4" ] ; then
+    SEP=1 # useful for collecting files (see build-xml.py)
+else
+    SEP=0
+fi
+
 rm -rf $ADDON_PATH
 mkdir  $ADDON_PATH
 
@@ -30,12 +36,17 @@
 	m="${m%%/}"
 	echo -n "Compiling $m..."
 	cd $m
+	if [ $SEP -eq 1 ] ; then
+	    path=${ADDON_PATH}/$m
+	else
+	    path=$ADDON_PATH
+	fi
 	make MODULE_TOPDIR=$TOPDIR \
-	    BIN=$ADDON_PATH/bin \
-	    HTMLDIR=$ADDON_PATH/docs/html \
-	    MANDIR=$ADDON_PATH/man/man1 \
-	    SCRIPTDIR=$ADDON_PATH/scripts \
-	    ETC=$ADDON_PATH/etc \
+	    BIN=$path/bin \
+	    HTMLDIR=$path/docs/html \
+	    MANDIR=$path/man/man1 \
+	    SCRIPTDIR=$path/scripts \
+	    ETC=$path/etc \
 	    MANIFEST= WINDRES= MANIFEST_OBJ= >$ADDON_PATH/log/${m}.log 2>&1
 	if [ `echo $?` -eq 0 ] ; then
 	    printf "%-30s%s\n" "$c/$m" "SUCCESS" >> $ADDON_PATH/make.log



More information about the grass-commit mailing list