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():
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")
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"):