X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=493ffbe21c64bc8653994a1b1d8fc69dda68e620;hb=ab03b5b37726fb8b39a6f6c915f8668bddd779ee;hp=217fe05a0037877f2cd0bb432f7a70bdb2eda8ae;hpb=c509e4175838e03bd9258d398af731be3a72e060;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 217fe05a..493ffbe2 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -138,21 +138,28 @@ def versionFileGenerator(project_info, version_file): version = bertosVersion(project_info.info("BERTOS_PATH")) return version_file.replace('$version', version) -def userMkGenerator(project_info, makefile): +def userMkGenerator(project_info): + makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_user.mk"), "r").read() + destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + "_user.mk") + # Deadly performances loss was here :( mk_data = {} mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH")) + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c" for key in mk_data: while makefile.find(key) != -1: makefile = makefile.replace(key, mk_data[key]) - return makefile + open(destination, "w").write(makefile) -def mkGenerator(project_info, makefile): +def mkGenerator(project_info): """ Generates the mk file for the current project. """ + makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read() + destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + ".mk") mk_data = {} mk_data["$pname"] = project_info.info("PROJECT_NAME") + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ") cpu_mk_parameters = [] for key, value in project_info.info("CPU_INFOS").items(): @@ -166,16 +173,22 @@ def mkGenerator(project_info, makefile): for key in mk_data: while makefile.find(key) != -1: makefile = makefile.replace(key, mk_data[key]) - return makefile + open(destination, "w").write(makefile) -def makefileGenerator(project_info, makefile): +def makefileGenerator(project_info): """ Generate the Makefile for the current project. """ + makefile = open(os.path.join(const.DATA_DIR, "mktemplates/Makefile"), "r").read() + destination = os.path.join(project_info.maindir, "Makefile") # TODO write a general function that works for both the mk file and the Makefile - while makefile.find("$pname") != -1: - makefile = makefile.replace("$pname", project_info.info("PROJECT_NAME")) - return makefile + mk_data = {} + mk_data["$pname"] = project_info.info("PROJECT_NAME") + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) + for key in mk_data: + while makefile.find(key) != -1: + makefile = makefile.replace(key, mk_data[key]) + open(destination, "w").write(makefile) def csrcGenerator(project_info): modules = project_info.info("MODULES") @@ -270,12 +283,13 @@ def findModuleFiles(module, project_info): try: version_string = bertosVersion(project_info.info("BERTOS_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 + # If the version file hasn't a valid version number assume it's an older + # project. + version_list = [0, 0] + if version_list < [2, 5]: + # For older versions of BeRTOS add the toolchain to the tags + tags.append(project_info.info("CPU_INFOS")["TOOLCHAIN"]) for tag in tags: for filename, path in project_info.searchFiles(module + "_" + tag + ".c"):