X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=wizard%2Fbertos_utils.py;h=8b6c90724269d4aa77e62b05242cca532c52c9cc;hb=25eab5ea346cafefaf53c6d82785262c3e408af9;hp=f4547f1f7245942472523ad108783261eccd144e;hpb=d33cc3bc1a94318cdf7624edb613eb6771a2fcb9;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index f4547f1f..8b6c9072 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -53,13 +53,21 @@ def createBertosProject(project_info): cfgdir = prjdir + "/cfg" shutil.rmtree(cfgdir, True) os.mkdir(cfgdir) + # Set to 1 the autoenabled for enabled modules + for module, information in project_info.info("MODULES").items(): + if information["enabled"] and "configuration" in information and information["configuration"] != "": + configurations = project_info.info("CONFIGURATIONS") + configuration = configurations[information["configuration"]] + for start, parameter in configuration["paramlist"]: + if "type" in configuration[parameter] and configuration[parameter]["type"] == "autoenabled": + configuration[parameter]["value"] = "1" + project_info.setInfo("CONFIGURATIONS", configurations) + # Copy all the configuration files for configuration, information in project_info.info("CONFIGURATIONS").items(): string = open(sources_dir + "/" + configuration, "r").read() for start, parameter in information["paramlist"]: infos = information[parameter] 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"]: @@ -85,13 +93,18 @@ def mkGenerator(project_info, makefile): """ mk_data = {} mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH")) + mk_data["$cpuflag"] = project_info.info("CPU_INFOS")["CPU_FLAG_NAME"] mk_data["$cpuname"] = project_info.info("CPU_INFOS")["CORE_CPU"] mk_data["$cflags"] = " ".join(project_info.info("CPU_INFOS")["C_FLAGS"]) mk_data["$ldflags"] = " ".join(project_info.info("CPU_INFOS")["LD_FLAGS"]) - mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info) + mk_data["$cppflags"] = " ".join(project_info.info("CPU_INFOS")["CPP_FLAGS"]) + mk_data["$cppaflags"] = " ".join(project_info.info("CPU_INFOS")["CPPA_FLAGS"]) + mk_data["$cxxflags"] = " ".join(project_info.info("CPU_INFOS")["CXX_FLAGS"]) + mk_data["$asflags"] = " ".join(project_info.info("CPU_INFOS")["AS_FLAGS"]) + mk_data["$arflags"] = " ".join(project_info.info("CPU_INFOS")["AR_FLAGS"]) + mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$cppasrc"], mk_data["$cxxsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info) mk_data["$prefix"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[0] mk_data["$suffix"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[1] - mk_data["$cross"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[0] mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c" for key in mk_data: while makefile.find(key) != -1: @@ -119,6 +132,10 @@ def csrcGenerator(project_info): # file to be included in PCSRC variable pcsrc = [] # files to be included in CPPASRC variable + cppasrc = [] + # files to be included in CXXSRC variable + cxxsrc = [] + # files to be included in ASRC variable asrc = [] # constants to be included at the beginning of the makefile constants = {} @@ -140,19 +157,31 @@ def csrcGenerator(project_info): asm_files |= set(dependencySFiles) for file in module_files: if not harvard or "harvard" not in information or information["harvard"] == "both": - csrc.append(os.path.normpath(file)) + csrc.append(file) if harvard and "harvard" in information: - pcsrc.append(os.path.normpath(file)) + pcsrc.append(file) for file in dependency_files: - csrc.append(os.path.normpath(file)) + csrc.append(file) + for file in project_info.info("CPU_INFOS")["C_SRC"]: + csrc.append(file) + for file in project_info.info("CPU_INFOS")["PC_SRC"]: + pcsrc.append(file) for file in asm_files: - asrc.append(os.path.normpath(file)) + cppasrc.append(file) + for file in project_info.info("CPU_INFOS")["CPPA_SRC"]: + cppasrc.append(file) + for file in project_info.info("CPU_INFOS")["CXX_SRC"]: + cxxsrc.append(file) + for file in project_info.info("CPU_INFOS")["ASRC"]: + asrc.append(file) csrc = " \\\n\t".join(csrc) + " \\" pcsrc = " \\\n\t".join(pcsrc) + " \\" + cppasrc = " \\\n\t".join(cppasrc) + " \\" + cxxsrc = " \\\n\t".join(cxxsrc) + " \\" asrc = " \\\n\t".join(asrc) + " \\" constants = "\n".join([os.path.basename(project_info.info("PROJECT_PATH")) + "_" + key + " = " + str(value) for key, value in constants.items()]) - return csrc, pcsrc, asrc, constants - + return csrc, pcsrc, cppasrc, cxxsrc, asrc, constants + def findModuleFiles(module, project_info): # Find the files related to the selected module cfiles = [] @@ -160,26 +189,42 @@ def findModuleFiles(module, project_info): # .c files related to the module and the cpu architecture for filename, path in findDefinitions(module + ".c", project_info) + \ findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".c", project_info): - path = path.replace(project_info.info("SOURCES_PATH") + "/", "") + path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + if os.sep != "/": + path = replaceSeparators(path) cfiles.append(path + "/" + filename) # .s files related to the module and the cpu architecture for filename, path in findDefinitions(module + ".s", project_info) + \ findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".s", project_info) + \ findDefinitions(module + ".S", project_info) + \ findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".S", project_info): - path = path.replace(project_info.info("SOURCES_PATH") + "/", "") + path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + if os.sep != "/": + path = replaceSeparators(path) sfiles.append(path + "/" + filename) # .c and .s files related to the module and the cpu tags for tag in project_info.info("CPU_INFOS")["CPU_TAGS"]: for filename, path in findDefinitions(module + "_" + tag + ".c", project_info): - path = path.replace(project_info.info("SOURCES_PATH") + "/", "") + path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + if os.sep != "/": + path = replaceSeparators(path) cfiles.append(path + "/" + filename) for filename, path in findDefinitions(module + "_" + tag + ".s", project_info) + \ findDefinitions(module + "_" + tag + ".S", project_info): - path = path.replace(project_info.info("SOURCES_PATH") + "/", "") + path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") + if os.sep != "/": + path = replaceSeparators(path) sfiles.append(path + "/" + filename) return cfiles, sfiles +def replaceSeparators(path): + """ + Replace the separators in the given path with unix standard separator. + """ + while path.find(os.sep) != -1: + path = path.replace(os.sep, "/") + return path + def getSystemPath(): path = os.environ["PATH"] if os.name == "nt": @@ -314,10 +359,10 @@ def loadDefineLists(comment_list): define_list[key] = (value,) return define_list -def getDescriptionInformations(comment): - """ - Take the doxygen comment and strip the wizard informations, returning the tuple - (comment, wizard_information) +def getDescriptionInformations(comment): + """ + Take the doxygen comment and strip the wizard informations, returning the tuple + (comment, wizard_information) """ brief = "" description = "" @@ -409,7 +454,7 @@ def loadModuleData(project): project.setInfo("LISTS", list_info_dict) project.setInfo("CONFIGURATIONS", configuration_info_dict) project.setInfo("FILES", file_dict) - + def formatParamNameValue(text): """ Take the given string and return a tuple with the name of the parameter in the first position