4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
19 def isBertosDir(directory):
20 return os.path.exists(directory + "/VERSION")
22 def bertosVersion(directory):
23 return open(directory + "/VERSION").readline().strip()
25 def createBertosProject(directory):
26 if not os.path.isdir(directory):
28 open(directory + "/project.bertos", "w")
31 path = os.environ["PATH"]
33 path = path.split(";")
35 path = path.split(":")
38 def findToolchains(pathList):
40 for element in pathList:
41 toolchains += glob.glob(element+ "/" + const.GCC_NAME)
44 def getToolchainInfo(output):
46 expr = re.compile("Target: .*")
47 target = expr.findall(output)
49 info["target"] = target[0].split("Target: ")[1]
50 expr = re.compile("gcc version .*")
51 version = expr.findall(output)
53 info["version"] = version[0].split("gcc version ")[1]
54 expr = re.compile("Configured with: .*")
55 configured = expr.findall(output)
56 if len(configured) == 1:
57 info["configured"] = configured[0].split("Configured with: ")[1]
58 expr = re.compile("Thread model: .*")
59 thread = expr.findall(output)
61 info["thread"] = thread[0].split("Thread model: ")[1]
64 def findDefinitions(ftype, path):
67 for filename in element[2]:
68 if fnmatch.fnmatch(filename, ftype):
69 yield (filename, element[0])
71 def loadCpuInfos(path):
73 for definition in findDefinitions(const.CPU_DEFINITION, path):
74 cpuInfos.append(getInfos(definition))
77 def getInfos(definition):
79 D.update(const.CPU_DEF)
80 def include(filename, dict = D, directory=definition[1]):
81 execfile(directory + "/" + filename, {}, D)
82 D["include"] = include
83 include(definition[0], D)
84 D["CPU_NAME"] = definition[0].split(".")[0]
85 D["DEFINITION_PATH"] = definition[1] + "/" + definition[0]