X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=4c6c3317c5469620ab4c263c52663438923ef874;hb=dfd6bde734886243cc7053d4477ff840c865a133;hp=c33e9c8ac33868f03bfc7026f9f757f9359ed5db;hpb=e5652672a648b1a8b77e497f1dfc7239c382811f;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index c33e9c8a..4c6c3317 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -45,7 +45,6 @@ import pickle import const import plugins import DefineException -import BProject from _wizard_version import WIZARD_VERSION @@ -76,6 +75,36 @@ def enabledModules(project_info): enabled_modules.append(name) return enabled_modules +def presetList(directory): + """ + Return the list of the preset found in the selected BeRTOS Version. + """ + abspath = os.path.join(directory, const.PREDEFINED_BOARDS_DIR) + preset_list = dict([ + (os.path.join(abspath, preset_dir), presetInfo(os.path.join(abspath, preset_dir))) + for preset_dir in os.listdir(os.path.join(directory, const.PREDEFINED_BOARDS_DIR)) + ]) + return preset_list + +def presetInfo(preset_dir): + """ + Return the preset-relevant info contined into the project_file. + """ + preset_info = pickle.loads(open(os.path.join(preset_dir, "project.bertos"), "r").read()) + try: + description = open(os.path.join(preset_dir, "description"), "r").read() + except IOError: + # No description file found. + description = "" + relevant_info = { + "CPU_NAME": preset_info.get("CPU_NAME"), + "SELECTED_FREQ": preset_info.get("SELECTED_FREQ"), + "WIZARD_VERSION": preset_info.get("WIZARD_VERSION", None), + "PRESET_NAME": preset_info.get("PROJECT_NAME"), + "PRESET_DESCRIPTION": description.decode("utf-8"), + } + return relevant_info + def mergeSources(srcdir, new_sources, old_sources): # The current mergeSources function provide only a raw copy of the sources in the # created project. @@ -409,12 +438,6 @@ def getToolchainName(toolchain_info): name = "GCC " + toolchain_info["version"] + " - " + toolchain_info["target"].strip() return name -def loadCpuInfos(project_info): - cpuInfos = [] - for definition in project_info.findDefinitions(const.CPU_DEFINITION): - cpuInfos.append(getInfos(definition)) - return cpuInfos - def getTagSet(cpu_info): tag_set = set([]) for cpu in cpu_info: