X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=99a84414cae75b30970ef6a2b40fb128e739b66b;hb=d5403b5adfbe4ef86d77498932bbf514143bb842;hp=0a1076911acf06ed8f470093c3c8c977b10f59f5;hpb=f7c35b4e4e3535fcfa22c28151cb692d13518fe5;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 0a107691..99a84414 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -11,6 +11,8 @@ import os import fnmatch +import glob +import re import const @@ -25,22 +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) for element in L: for filename in element[2]: - if fnmatch.fnmatch(filename, "*." + ftype): + if fnmatch.fnmatch(filename, ftype): yield (filename, element[0]) def loadCpuInfos(path): cpuInfos = [] for definition in findDefinitions(const.CPU_DEFINITION, path): - 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] - cpuInfos.append(D) + 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