From: duplo Date: Tue, 24 Mar 2009 10:08:22 +0000 (+0000) Subject: BeRTOS modules accept non-module dependencies (.c or .s files, for examples) X-Git-Tag: 2.1.0~276 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=bc3d64cfb66274dad453e765c08c3df97da2ff33;p=bertos.git BeRTOS modules accept non-module dependencies (.c or .s files, for examples) git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2406 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BModulePage.py b/wizard/BModulePage.py index 7241c80e..97ae7703 100644 --- a/wizard/BModulePage.py +++ b/wizard/BModulePage.py @@ -238,6 +238,7 @@ class BModulePage(BWizardPage): self._moduleSelected(module) else: self._moduleUnselected(module) + self.removeFileDependencies(module) def _moduleSelected(self, selectedModule): modules = self._projectInfoRetrieve("MODULES") @@ -281,11 +282,18 @@ class BModulePage(BWizardPage): def selectDependencyCheck(self, module): unsatisfied = set() modules = self._projectInfoRetrieve("MODULES") + files = self._projectInfoRetrieve("FILES") for dependency in modules[module]["depends"]: - if not modules[dependency]["enabled"]: + if dependency in modules and not modules[dependency]["enabled"]: unsatisfied |= set([dependency]) if dependency not in unsatisfied: unsatisfied |= self.selectDependencyCheck(dependency) + if dependency not in modules: + if dependency in files: + files[dependency] += 1 + else: + files[dependency] = 1 + self._projectInfoStore("FILES", files) return unsatisfied def unselectDependencyCheck(self, dependency): @@ -297,6 +305,17 @@ class BModulePage(BWizardPage): if dependency not in unsatisfied: unsatisfied |= self.unselectDependencyCheck(module) return unsatisfied + + def removeFileDependencies(self, module): + modules = self._projectInfoRetrieve("MODULES") + files = self._projectInfoRetrieve("FILES") + dependencies = modules[module]["depends"] + for dependency in dependencies: + if dependency in files: + files[dependency] -= 1 + if files[dependency] == 0: + del files[dependency] + self._projectInfoStore("FILES", files) class QControlGroup(QObject): def __init__(self): diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 47fa4b6b..3c7a6eaf 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -92,7 +92,7 @@ def mkGenerator(projectInfo, makefile): 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" + mkData["$main"] = os.path.basename(projectInfo.info("PROJECT_PATH")) + "/main.c" for key in mkData: while makefile.find(key) != -1: makefile = makefile.replace(key, mkData[key]) @@ -109,6 +109,7 @@ def makefileGenerator(projectInfo, makefile): def csrcGenerator(projectInfo): modules = projectInfo.info("MODULES") + files = projectInfo.info("FILES") if "harvard" in projectInfo.info("CPU_INFOS")["CPU_TAGS"]: harvard = True else: @@ -116,33 +117,38 @@ def csrcGenerator(projectInfo): csrc = [] pcsrc = [] constants = {} + moduleFiles = set([]) 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")) + moduleFiles |= set(findModuleFiles(module, projectInfo)) + for fileDependency in information["depends"]: + if fileDependency in files: + moduleFiles |= set(findModuleFiles(fileDependency, projectInfo)) + for file in moduleFiles: if not harvard or "harvard" not in information or information["harvard"] == "both": - csrc.append(path + "/" + filename) + csrc.append(file) 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")) - 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")) - 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) + pcsrc.append(file) 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 findModuleFiles(module, projectInfo): + files = [] + for filename, path in findDefinitions(module + ".c", projectInfo): + path = path.replace(projectInfo.info("SOURCES_PATH") + "/", "") + files.append(path + "/" + filename) + for filename, path in findDefinitions(module + "_" + projectInfo.info("CPU_INFOS")["TOOLCHAIN"] + ".c", projectInfo): + path = path.replace(projectInfo.info("SOURCES_PATH") + "/", "") + files.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") + "/", "") + files.append(path + "/" + filename) + return files def codeliteProjectGenerator(projectInfo): template = open("cltemplates/bertos.project").read() @@ -341,6 +347,7 @@ def loadModuleData(project): moduleInfoDict = {} listInfoDict = {} configurationInfoDict = {} + fileDict = {} for filename, path in findDefinitions("*.h", project): commentList = getCommentList(open(path + "/" + filename, "r").read()) if len(commentList) > 0: @@ -376,6 +383,7 @@ def loadModuleData(project): project.setInfo("MODULES", moduleInfoDict) project.setInfo("LISTS", listInfoDict) project.setInfo("CONFIGURATIONS", configurationInfoDict) + project.setInfo("FILES", fileDict) def formatParamNameValue(text): """