]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Teach tos-storage-stm25p about platform families
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 4 Oct 2012 16:23:55 +0000 (10:23 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 4 Oct 2012 16:36:11 +0000 (10:36 -0600)
tools/tinyos/misc/tos-storage-stm25p.in

index ed9eb63aa6c65acc36a61bd2a61e4b406feb9941..4d8013dc3dbff5a7ddcc0387a9b28b2ed56790ab 100644 (file)
@@ -68,11 +68,18 @@ except GetoptError, err:
   
 if len( args ) == 1:
   platformdir = args[0]
-  # This gives the whole string when there's no / in platformdir
-  platform = platformdir[platformdir.rfind( "/" ) + 1:]
+  platform = os.path.basename(platformdir)
+  # In case platformdir was specified with a trailing path separator
+  if not platform:
+    platformdir = os.path.dirname(platformdir)
+    platform = os.path.basename(platformdir)
+  familydir = os.path.dirname(platformdir)
+  if familydir and not os.path.isfile(os.path.join(familydir, '.family')):
+    familydir = ""
 elif len( args ) == 0:
   platformdir = ""
   platform = ""
+  familydir = ""
 else:
   stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
   
@@ -106,6 +113,11 @@ def expand_path( path ):
         sub = platform
       elif c == 'P':
         sub = platformdir
+      elif c == 'F':
+        if not familydir:
+          nfail( "invalid include-path substitution character " + c + "; " + \
+              platform + " not in a family" )
+        sub = familydir
       elif c == 'T':
         sub = Popen( ["ncc", "-print-tosdir"], stdout=PIPE ).communicate( )[0]
         sub = sub[:-1] # remove newline
@@ -121,14 +133,14 @@ HEADER_FILE = 'Stm25p.h'
 NUM_SECTORS = 0
 SECTOR_SIZE = 0
 
-def parseHeader( dotplatform ):
-  """ Return an ordered list of paths from the dotplatform file """
+def parseHeader( dotfile ):
+  """ Return an ordered list of paths from the dotfile """
   paths = []
   inArray = False
   p = re.compile('push\s*\(\s*@includes,\s*qw\s*\(');
   q = re.compile('\)\s*\)\s*;');
   try:
-    with open(dotplatform, 'r') as file:
+    with open(dotfile, 'r') as file:
       for line in file:
        path = line.strip()
        if path:
@@ -173,7 +185,8 @@ def findVars( path, vars ):
          if vars.has_key(m.group(1)):
            vars[m.group(1)] = m.group(2)
 
-paths = parseHeader(platformdir + '/.platform')
+paths = parseHeader(os.path.join(familydir, '.family')) + \
+       parseHeader(os.path.join(platformdir, '.platform'))
 if paths:
   path = findFile(paths, HEADER_FILE)
   if path: