X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=47fa4b6b8572315b8c11e3bb53888bd7029bb82a;hb=e80b8410edc8e74e94662722194d1cfddbb19ec5;hp=92d85fdfd0f433947c4b4912e8d75d7869ceed53;hpb=1dddbaedac5a7769f5b908cc58c716fa16aecd54;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 92d85fdf..47fa4b6b 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -56,6 +56,8 @@ def createBertosProject(projectInfo): 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"]: @@ -68,6 +70,9 @@ def createBertosProject(projectInfo): makefile = open("mktemplates/template.mk", "r").read() makefile = mkGenerator(projectInfo, makefile) open(prjdir + "/" + os.path.basename(prjdir) + ".mk", "w").write(makefile) + ## 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) @@ -83,10 +88,11 @@ def mkGenerator(projectInfo, makefile): 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"], mkData["$pcsrc"] = csrcGenerator(projectInfo) + 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]) @@ -104,32 +110,39 @@ def makefileGenerator(projectInfo, makefile): def csrcGenerator(projectInfo): modules = projectInfo.info("MODULES") if "harvard" in projectInfo.info("CPU_INFOS")["CPU_TAGS"]: - pcsrc_need = projectInfo.info("CPU_INFOS")["PC_SRC"] + harvard = True else: - pcsrc_need = [] + 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): path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH")) - csrc.append(path + "/" + filename) - if module in pcsrc_need: + 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): path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH")) - csrc.append(path + "/" + filename) - if module in pcsrc_need: + 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): path = path.replace(projectInfo.info("SOURCES_PATH"), projectInfo.info("PROJECT_PATH")) - csrc.append(path + "/" + filename) - if module in pcsrc_need: + 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) + " \\" - return csrc, 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() @@ -240,20 +253,31 @@ def loadModuleDefinition(first_comment): 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):