4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
20 def isBertosDir(directory):
21 return os.path.exists(directory + "/VERSION")
23 def bertosVersion(directory):
24 return open(directory + "/VERSION").readline().strip()
26 def createBertosProject(directory):
27 if not os.path.isdir(directory):
29 open(directory + "/project.bertos", "w")
32 path = os.environ["PATH"]
34 path = path.split(";")
36 path = path.split(":")
39 def findToolchains(pathList):
41 for element in pathList:
42 for toolchain in glob.glob(element+ "/" + const.GCC_NAME):
43 if not os.path.islink(toolchain):
44 toolchains.append(toolchain)
45 return list(set(toolchains))
47 def getToolchainInfo(output):
48 info = collections.defaultdict(unicode)
49 expr = re.compile("Target: .*")
50 target = expr.findall(output)
52 info["target"] = target[0].split("Target: ")[1]
53 expr = re.compile("gcc version [0-9,.]*")
54 version = expr.findall(output)
56 info["version"] = version[0].split("gcc version ")[1]
57 expr = re.compile("gcc version [0-9,.]* \(.*\)")
58 build = expr.findall(output)
60 build = build[0].split("gcc version ")[1]
61 build = build[build.find("(") + 1 : build.find(")")]
63 expr = re.compile("Configured with: .*")
64 configured = expr.findall(output)
65 if len(configured) == 1:
66 info["configured"] = configured[0].split("Configured with: ")[1]
67 expr = re.compile("Thread model: .*")
68 thread = expr.findall(output)
70 info["thread"] = thread[0].split("Thread model: ")[1]
73 def findDefinitions(ftype, path):
76 for filename in element[2]:
77 if fnmatch.fnmatch(filename, ftype):
78 yield (filename, element[0])
80 def loadCpuInfos(path):
82 for definition in findDefinitions(const.CPU_DEFINITION, path):
83 cpuInfos.append(getInfos(definition))
86 def getInfos(definition):
88 D.update(const.CPU_DEF)
89 def include(filename, dict = D, directory=definition[1]):
90 execfile(directory + "/" + filename, {}, D)
91 D["include"] = include
92 include(definition[0], D)
93 D["CPU_NAME"] = definition[0].split(".")[0]
94 D["DEFINITION_PATH"] = definition[1] + "/" + definition[0]