X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tools%2Ftinyos%2Fmisc%2Ftos-storage-stm25p.in;h=9ef1428f4094f257550b3f239fd7ff8530f2c1c0;hb=4b943ec81ebdc1582de77b529dbec1419e611af5;hp=8002cf853f70dc7da8cb5a62aa6be3bfe6f6ba4c;hpb=8205c3ed1905491954757c0536f86a33cc39d34f;p=tinyos-2.x.git diff --git a/tools/tinyos/misc/tos-storage-stm25p.in b/tools/tinyos/misc/tos-storage-stm25p.in index 8002cf85..9ef1428f 100644 --- a/tools/tinyos/misc/tos-storage-stm25p.in +++ b/tools/tinyos/misc/tos-storage-stm25p.in @@ -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] \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: @@ -140,7 +152,7 @@ def parseHeader( dotplatform ): paths.append(path) return paths except: - return None + return [] def findFile( paths, filename ): """ Find the first occurrence of 'filename' in the list of paths given. """ @@ -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: @@ -184,9 +197,8 @@ if paths: NUM_SECTORS = int(enums["STM25P_NUM_SECTORS"]) SECTOR_SIZE = 2**int(enums["STM25P_SECTOR_SIZE_LOG2"]) if NUM_SECTORS == 0 or SECTOR_SIZE == 0: - stderr.write( 'No valid Stm25p.h in PFLAGS path; check .platform file\n' ) stderr.write( "tos-storage-stm25p: no valid Stm25p.h found.\n\t" - "Check the platform's .platform file\n" ) + "Check @includes in the platform's .platform file\n" ) exit(2) volumes = {} @@ -321,8 +333,8 @@ if cthreads == True: outFile.write(" interface BlockWrite[uint8_t volume_id]; \n") outFile.write(" interface LogRead[uint8_t volumeId]; \n") outFile.write(" interface LogWrite[uint8_t volumeId]; \n") -# outFile.write(" interface Mount[uint8_t volumeId]; \n") -# outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") + outFile.write(" interface Mount[uint8_t volumeId]; \n") + outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") outFile.write(" } \n") outFile.write("} \n") outFile.write("\n") @@ -333,6 +345,8 @@ if cthreads == True: outFile.write(" BlockWrite = VolumeMapP; \n") outFile.write(" LogRead = VolumeMapP; \n") outFile.write(" LogWrite = VolumeMapP; \n") + outFile.write(" Mount = VolumeMapP; \n") + outFile.write(" ConfigStorage = VolumeMapP; \n") for i in range(len(volumeNames)): if volumeTypes[volumeNames[i]] == "block": @@ -349,8 +363,8 @@ if cthreads == True: outFile.write(" VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n") outFile.write("\n") -# elif volumeTypes[volumeNames[i]] == "config": -# outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + elif volumeTypes[volumeNames[i]] == "config": + outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") outFile.write("} \n")