BeRTOS modules accept non-module dependencies (.c or .s files, for examples)
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 24 Mar 2009 10:08:22 +0000 (10:08 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 24 Mar 2009 10:08:22 +0000 (10:08 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2406 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BModulePage.py
wizard/bertos_utils.py

index 7241c80e0a2a28ba93dbe5a0c977898b40c96978..97ae77030b7374bfc7987fce705bd15a3766130c 100644 (file)
@@ -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):
index 47fa4b6b8572315b8c11e3bb53888bd7029bb82a..3c7a6eaf7006206a3f4f89943b9b626c9925d8d5 100644 (file)
@@ -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):
     """