string = open(sourcesDir + "/" + key, "r").read()
for parameter, infos in value.items():
value = infos["value"]
+ if "type" in infos["informations"] and infos["informations"]["type"] == "autoenabled":
+ value = "1"
if "unsigned" in infos["informations"].keys() and infos["informations"]["unsigned"]:
value += "U"
if "long" in infos["informations"].keys() and infos["informations"]["long"]:
makefile = open("mktemplates/template.mk", "r").read()
makefile = mkGenerator(projectInfo, makefile)
open(prjdir + "/" + os.path.basename(prjdir) + ".mk", "w").write(makefile)
- workspace = codeliteWorkspaceGenerator(projectInfo)
- open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace)
- project = codeliteProjectGenerator(projectInfo)
- open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project)
+ ## Destination main.c file
+ main = open("srctemplates/main.c", "r").read()
+ open(prjdir + "/main.c", "w").write(main)
+ if "codelite" in projectInfo.info("OUTPUT"):
+ workspace = codeliteWorkspaceGenerator(projectInfo)
+ open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace)
+ project = codeliteProjectGenerator(projectInfo)
+ open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project)
def mkGenerator(projectInfo, makefile):
"""
"""
mkData = {}
mkData["$pname"] = os.path.basename(projectInfo.info("PROJECT_PATH"))
- mkData["$cpuname"] = projectInfo.info("CPU_INFOS")["CPU_NAME"]
+ mkData["$cpuname"] = projectInfo.info("CPU_INFOS")["CORE_CPU"]
mkData["$cflags"] = " ".join(projectInfo.info("CPU_INFOS")["C_FLAGS"])
mkData["$ldflags"] = " ".join(projectInfo.info("CPU_INFOS")["LD_FLAGS"])
- mkData["$csrc"] = csrcGenerator(projectInfo)
- mkData["$prefix"] = os.path.basename(projectInfo.info("TOOLCHAIN")["path"]).split("gcc")[0]
- mkData["$suffix"] = os.path.basename(projectInfo.info("TOOLCHAIN")["path"]).split("gcc")[1]
+ mkData["$csrc"], mkData["$pcsrc"], mkData["$constants"] = csrcGenerator(projectInfo)
+ mkData["$prefix"] = projectInfo.info("TOOLCHAIN")["path"].split("gcc")[0]
+ mkData["$suffix"] = projectInfo.info("TOOLCHAIN")["path"].split("gcc")[1]
+ mkData["$cross"] = projectInfo.info("TOOLCHAIN")["path"].split("gcc")[0]
+ mkData["$main"] = projectInfo.info("PROJECT_PATH") + "/" + os.path.basename(projectInfo.info("PROJECT_PATH")) + "/main.c"
for key in mkData:
while makefile.find(key) != -1:
makefile = makefile.replace(key, mkData[key])
def csrcGenerator(projectInfo):
modules = projectInfo.info("MODULES")
- files = []
+ if "harvard" in projectInfo.info("CPU_INFOS")["CPU_TAGS"]:
+ harvard = True
+ else:
+ harvard = False
+ csrc = []
+ pcsrc = []
+ constants = {}
for module, information in modules.items():
if information["enabled"]:
+ if "constants" in information:
+ constants.update(information["constants"])
for filename, path in findDefinitions(module + ".c", projectInfo):
- files.append(path + "/" + filename)
+ path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH"))
+ if not harvard or "harvard" not in information or information["harvard"] == "both":
+ csrc.append(path + "/" + filename)
+ if harvard and "harvard" in information:
+ pcsrc.append(path + "/" + filename)
for filename, path in findDefinitions(module + "_" + projectInfo.info("CPU_INFOS")["TOOLCHAIN"] + ".c", projectInfo):
- files.append(path + "/" + filename)
+ path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH"))
+ if not harvard or "harvard" not in information or information["harvard"] == "both":
+ csrc.append(path + "/" + filename)
+ if harvard and "harvard" in information:
+ pcsrc.append(path + "/" + filename)
for tag in projectInfo.info("CPU_INFOS")["CPU_TAGS"]:
for filename, path in findDefinitions(module + "_" + tag + ".c", projectInfo):
- files.append(path + "/" + filename)
- csrc = " \\\n\t".join(files) + " \\"
- return csrc
+ path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH"))
+ if not harvard or "harvard" not in information or information["harvard"] == "both":
+ csrc.append(path + "/" + filename)
+ if harvard and "harvard" in information:
+ pcsrc.append(path + "/" + filename)
+ csrc = " \\\n\t".join(csrc) + " \\"
+ pcsrc = " \\\n\t".join(pcsrc) + " \\"
+ constants = "\n".join([os.path.basename(projectInfo.info("PROJECT_PATH")) + "_" + key + " = " + str(value) for key, value in constants.items()])
+ return csrc, pcsrc, constants
def codeliteProjectGenerator(projectInfo):
template = open("cltemplates/bertos.project").read()
filelist = "\n".join(codelite_project.clFiles(codelite_project.findSources(projectInfo.info("PROJECT_PATH")), projectInfo.info("PROJECT_PATH")))
while template.find("$filelist") != -1:
template = template.replace("$filelist", filelist)
+ projectName = os.path.basename(projectInfo.info("PROJECT_PATH"))
+ while template.find("$project") != -1:
+ template = template.replace("$project", projectName)
return template
def codeliteWorkspaceGenerator(projectInfo):
moduleDefinition["module_description"] = line[line.find("\\brief") + len("\\brief "):]
moduleDict = {}
if "module_name" in moduleDefinition.keys():
- moduleDict[moduleDefinition["module_name"]] = {}
- if "module_depends" in moduleDefinition.keys():
- if type(moduleDefinition["module_depends"]) == str:
- moduleDefinition["module_depends"] = (moduleDefinition["module_depends"],)
- moduleDict[moduleDefinition["module_name"]]["depends"] = moduleDefinition["module_depends"]
+ moduleName = moduleDefinition[const.MODULE_DEFINITION["module_name"]]
+ del moduleDefinition[const.MODULE_DEFINITION["module_name"]]
+ moduleDict[moduleName] = {}
+ if const.MODULE_DEFINITION["module_depends"] in moduleDefinition.keys():
+ if type(moduleDefinition[const.MODULE_DEFINITION["module_depends"]]) == str:
+ moduleDefinition[const.MODULE_DEFINITION["module_depends"]] = (moduleDefinition[const.MODULE_DEFINITION["module_depends"]],)
+ moduleDict[moduleName]["depends"] = moduleDefinition[const.MODULE_DEFINITION["module_depends"]]
+ del moduleDefinition[const.MODULE_DEFINITION["module_depends"]]
else:
- moduleDict[moduleDefinition["module_name"]]["depends"] = ()
- if "module_configuration" in moduleDefinition.keys():
- moduleDict[moduleDefinition["module_name"]]["configuration"] = moduleDefinition["module_configuration"]
+ moduleDict[moduleName]["depends"] = ()
+ if const.MODULE_DEFINITION["module_configuration"] in moduleDefinition.keys():
+ moduleDict[moduleName]["configuration"] = moduleDefinition[const.MODULE_DEFINITION["module_configuration"]]
+ del moduleDefinition[const.MODULE_DEFINITION["module_configuration"]]
else:
- moduleDict[moduleDefinition["module_name"]]["configuration"] = ""
+ moduleDict[moduleName]["configuration"] = ""
if "module_description" in moduleDefinition.keys():
- moduleDict[moduleDefinition["module_name"]]["description"] = moduleDefinition["module_description"]
- moduleDict[moduleDefinition["module_name"]]["enabled"] = False
+ moduleDict[moduleName]["description"] = moduleDefinition["module_description"]
+ del moduleDefinition["module_description"]
+ if const.MODULE_DEFINITION["module_harvard"] in moduleDefinition.keys():
+ harvard = moduleDefinition[const.MODULE_DEFINITION["module_harvard"]]
+ if harvard == "both" or harvard == "pgm_memory":
+ moduleDict[moduleName]["harvard"] = harvard
+ del moduleDefinition[const.MODULE_DEFINITION["module_harvard"]]
+ moduleDict[moduleName]["constants"] = moduleDefinition
+ moduleDict[moduleName]["enabled"] = False
return toBeParsed, moduleDict
def loadDefineLists(commentList):