Make smarter the selection of the header to parse
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 11 Feb 2009 09:56:29 +0000 (09:56 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 11 Feb 2009 09:56:29 +0000 (09:56 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2342 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BModulePage.py
wizard/bertos_utils.py
wizard/test/testModulePage.py

index c592d1d32a32fe27a538fa9bf6b4d8989a12b24f..101aba6913883f768f5f97d1775e42f2adaecb5f 100644 (file)
@@ -39,9 +39,7 @@ class BModulePage(BWizardPage):
     
     def _loadModuleData(self):
         try:
-            bertos_utils.loadModuleInfosDict(self._project())
-            bertos_utils.loadDefineListsDict(self._project())
-            bertos_utils.loadConfigurationInfosDict(self._project())
+            bertos_utils.loadModuleData(self._project())
         except ModuleDefineException, e:
             self._exceptionOccurred(self.tr("Error parsing module information in file %1").arg(e.path))
         except EnumDefineException, e:
index 700d72e7ef65087eb0b826cbed6e0be2c47137da..7e16c1bf11aede8741bc3005fe736cd6bac3c1b9 100644 (file)
@@ -164,6 +164,23 @@ def getInfos(definition):
     del D["include"]
     return D
 
+def loadModuleData(project):
+    moduleInfosDict = {}
+    listInfosDict = {}
+    configurationsInfoDict = {}
+    for filename, path in findDefinitions("*.h", project):
+        moduleInfos, listInfos, configurationInfos= loadModuleInfos(path + "/" + filename)
+        moduleInfosDict.update(moduleInfos)
+        listInfosDict.update(listInfos)
+        for configuration in configurationInfos.keys():
+            configurationsInfoDict[configuration] = loadConfigurationInfos(project.info("SOURCES_PATH") + "/" + configuration)
+    print "*_" + project.info("CPU_INFOS")["TOOLCHAIN"] + ".h"
+    for filename, path in findDefinitions("*_" + project.info("CPU_INFOS")["TOOLCHAIN"] + ".h", project):
+        listInfosDict.update(loadDefineLists(path + "/" + filename))
+    project.setInfo("MODULES", moduleInfosDict)
+    project.setInfo("LISTS", listInfosDict)
+    project.setInfo("CONFIGURATIONS", configurationsInfoDict)
+
 def getDefinitionBlocks(text):
     """
     Take a text and return a list of tuple (description, name-value).
@@ -258,24 +275,32 @@ def loadModuleInfos(path):
     """
     try:
         moduleInfos = {}
+        listInfos = {}
+        configurationsInfos = {}
         string = open(path, "r").read()
         commentList = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/", string)
         commentList = [" ".join(re.findall(r"^\s*\*?\s*(.*?)\s*?(?:/{2}.*?)?$", comment, re.MULTILINE)).strip() for comment in commentList]
-        for comment in commentList:
-            index = comment.find("$WIZARD_MODULE")
-            if index != -1:
-                exec(comment[index + 1:])
-                moduleInfos[WIZARD_MODULE["name"]] = {"depends": WIZARD_MODULE["depends"],
-                                                        "configuration": WIZARD_MODULE["configuration"],
-                                                        "description": "",
-                                                        "enabled": False}
-                index = comment.find("\\brief")
+        if len(commentList) > 0:
+            comment = commentList[0]
+            if comment.find("$WIZARD_MODULE") != -1:
+                index = comment.find("$WIZARD_MODULE")
                 if index != -1:
-                    description = comment[index + 7:]
-                    description = description[:description.find(" * ")]
-                    moduleInfos[WIZARD_MODULE["name"]]["description"] = description
-                return moduleInfos
-        return {}
+                    # 14 is the length of "$WIZARD_MODULE"
+                    if len(comment[index + 14:].strip()) > 0:
+                        exec(comment[index + 1:])
+                        moduleInfos[WIZARD_MODULE["name"]] = {"depends": WIZARD_MODULE["depends"],
+                                                                "configuration": WIZARD_MODULE["configuration"],
+                                                                "description": "",
+                                                                "enabled": False}
+                        index = comment.find("\\brief")
+                        if index != -1:
+                            description = comment[index + 7:]
+                            description = description[:description.find(" * ")]
+                            moduleInfos[WIZARD_MODULE["name"]]["description"] = description
+                        if "configuration" in WIZARD_MODULE.keys() and len(WIZARD_MODULE["configuration"]) > 0:
+                            configurationsInfos[WIZARD_MODULE["configuration"]] = {}
+                    listInfos.update(loadDefineLists(path))
+        return moduleInfos, listInfos, configurationsInfos
     except SyntaxError:
         raise DefineException.ModuleDefineException(path)
 
index 026e9ae9d9bafe4e91bf0d66f98ef9af7d75be87..6c4f8dc7d91c2cccd56f1d5e952b34cd80c831a5 100644 (file)
@@ -19,6 +19,7 @@ sys.path.append("../")
 
 import BProject
 import BModulePage
+import bertos_utils
 
 # Add a custom UI_LOCATION constant
 BModulePage.UI_LOCATION = "../ui"
@@ -28,6 +29,8 @@ def main():
     app.project = BProject.BProject()
     page = BModulePage.BModulePage()
     page._projectInfoStore("SOURCES_PATH", "../../")
+    page._projectInfoStore("CPU_INFOS", {"TOOLCHAIN": "avr"})
+    bertos_utils.loadSourceTree(page._project())
     page.reloadData()
     page.show()
     app.exec_()