X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=99a84414cae75b30970ef6a2b40fb128e739b66b;hb=d5403b5adfbe4ef86d77498932bbf514143bb842;hp=e5a21d9b4989fa898ee518f9e55d936d88df9b66;hpb=7aaf72a1c2b435d9704f0161459f1b338ec608c5;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index e5a21d9b..99a84414 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -11,6 +11,10 @@ import os import fnmatch +import glob +import re + +import const def isBertosDir(directory): return os.path.exists(directory + "/VERSION") @@ -23,11 +27,60 @@ def createBertosProject(directory): os.mkdir(directory) open(directory + "/project.bertos", "w") +def getSystemPath(): + path = os.environ["PATH"] + if os.name == "nt": + path = path.split(";") + else: + path = path.split(":") + return path + +def findToolchains(pathList): + toolchains = [] + for element in pathList: + toolchains += glob.glob(element+ "/" + const.GCC_NAME) + return toolchains + +def getToolchainInfo(output): + info = {} + expr = re.compile("Target: .*") + target = expr.findall(output) + if len(target) == 1: + info["target"] = target[0].split("Target: ")[1] + expr = re.compile("gcc version .*") + version = expr.findall(output) + if len(version) == 1: + info["version"] = version[0].split("gcc version ")[1] + expr = re.compile("Configured with: .*") + configured = expr.findall(output) + if len(configured) == 1: + info["configured"] = configured[0].split("Configured with: ")[1] + expr = re.compile("Thread model: .*") + thread = expr.findall(output) + if len(thread) == 1: + info["thread"] = thread[0].split("Thread model: ")[1] + return info + def findDefinitions(ftype, path): - l = os.walk(path) - definitions = {} - for element in l: + L = os.walk(path) + for element in L: for filename in element[2]: - if fnmatch.fnmatch(filename, "*." + ftype): - definitions[filename] = element[0] - return definitions \ No newline at end of file + if fnmatch.fnmatch(filename, ftype): + yield (filename, element[0]) + +def loadCpuInfos(path): + cpuInfos = [] + for definition in findDefinitions(const.CPU_DEFINITION, path): + cpuInfos.append(getInfos(definition)) + return cpuInfos + +def getInfos(definition): + D = {} + D.update(const.CPU_DEF) + def include(filename, dict = D, directory=definition[1]): + execfile(directory + "/" + filename, {}, D) + D["include"] = include + include(definition[0], D) + D["CPU_NAME"] = definition[0].split(".")[0] + D["DEFINITION_PATH"] = definition[1] + "/" + definition[0] + return D \ No newline at end of file