X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=fcd329ff22984c90ac3bef97f5b19f6ecfddbfb5;hb=f35b6066ecdeffcc8998dd566b5246bdcf43c548;hp=c19f3d5322503c356394d1f1a25d246ea8dec788;hpb=3cd73c355f9d5bd07eaee38425661f5f4310f020;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index c19f3d53..fcd329ff 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. @@ -328,21 +357,32 @@ def findModuleFiles(module, project_info): cfiles = [] sfiles = [] # .c files related to the module and the cpu architecture - for filename, path in project_info.searchFiles(module + ".c") + \ - project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".c"): + for filename, path in project_info.searchFiles(module + ".c"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") path = replaceSeparators(path) cfiles.append(path + "/" + filename) # .s files related to the module and the cpu architecture for filename, path in project_info.searchFiles(module + ".s") + \ - project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".s") + \ - project_info.searchFiles(module + ".S") + \ - project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".S"): + project_info.searchFiles(module + ".S"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") path = replaceSeparators(path) sfiles.append(path + "/" + filename) # .c and .s files related to the module and the cpu tags - for tag in project_info.info("CPU_INFOS")["CPU_TAGS"]: + tags = project_info.info("CPU_INFOS")["CPU_TAGS"] + + # Awful, but secure check for version + # TODO: split me in a method/function + try: + version_string = bertosVersion(project_info.info("SOURCES_PATH")) + version_list = [int(i) for i in version_string.split()[-1].split('.')] + if version_list < [2, 5]: + # For older versions of BeRTOS add the toolchain to the tags + tags.append(project_info.info("CPU_INFOS")["TOOLCHAIN"]) + except ValueError: + # If the version file hasn't a valid version number do nothing + pass + + for tag in tags: for filename, path in project_info.searchFiles(module + "_" + tag + ".c"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") if os.sep != "/":