X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=a6bef914e904d6d989f74ba1282e645333c4176e;hb=47219caf366ee98c051346d9e3fbdd30eca45827;hp=8d4b644917a0664c8905ac0beac9dbf1ceee3bc1;hpb=35aeb5229a132f6555b1eff44ba2a00596003f22;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 8d4b6449..a6bef914 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -140,6 +140,18 @@ def versionFileGenerator(project_info, version_file): version = bertosVersion(project_info.info("BERTOS_PATH")) return version_file.replace('$version', version) +def userMkGeneratorFromPreset(project_info): + project_name = project_info.info("PROJECT_NAME") + preset_path = project_info.info("PRESET_PATH") + preset_name = project_info.info("PRESET_NAME") + preset_src_dir = project_info.info("PRESET_SRC_PATH") + makefile = open(os.path.join(preset_path, preset_src_dir, "%s_user.mk" %preset_name), 'r').read() + destination = os.path.join(project_info.prjdir, "%s_user.mk" %project_info.info("PROJECT_NAME")) + # Temporary code. + # TODO: write it using regular expressions to secure this function + makefile = makefile.replace(preset_name + "_", project_name + "_") + open(destination, "w").write(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") @@ -149,8 +161,7 @@ def userMkGenerator(project_info): mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH")) mk_data["$main"] = os.path.join("$(%s_SRC_PATH)" %project_info.info("PROJECT_NAME"), "main.c") for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def mkGenerator(project_info): @@ -172,8 +183,7 @@ def mkGenerator(project_info): mk_data["$prefix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[0]) mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[1]) for key in mk_data: - while makefile.find(key) != -1: - makefile = makefile.replace(key, mk_data[key]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def makefileGenerator(project_info): @@ -187,8 +197,7 @@ def makefileGenerator(project_info): 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]) + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def csrcGenerator(project_info): @@ -310,8 +319,7 @@ def replaceSeparators(path): Replace the separators in the given path with unix standard separator. """ if os.sep != "/": - while path.find(os.sep) != -1: - path = path.replace(os.sep, "/") + path = path.replace(os.sep, "/") return path def getSystemPath():