Add the check for the right toolchain for the selected cpu
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 7 Jan 2009 14:45:45 +0000 (14:45 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 7 Jan 2009 14:45:45 +0000 (14:45 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2135 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BCpuPage.py
wizard/BToolchainPage.py
wizard/bertos.qrc
wizard/bertos_utils.py
wizard/images/error.png [new file with mode: 0755]

index 93919c9cf64d7effdd22f9dfb1a4324e83a927c7..f35790b8bb7257cda82110546f671fe6db921bed 100644 (file)
@@ -29,7 +29,7 @@ class BCpuPage(BWizardPage):
             item = QListWidgetItem(cpu["CPU_NAME"])
             # The CPU_DESC field in the cpu definition is a list of string, so we need to 
             # store it as a QStringList in a QVariant
-            item.setData(Qt.UserRole, QVariant(QStringList(cpu["CPU_DESC"])))
+            item.setData(Qt.UserRole, QVariant(cpu))
             self.pageContent.cpuList.addItem(item)
     
     def _connectSignals(self):
@@ -54,15 +54,17 @@ class BCpuPage(BWizardPage):
     
     def isComplete(self):
         if self.pageContent.cpuList.currentRow() != -1:
-            self._projectInfoStore("CPU_NAME", self.pageContent.cpuList.currentItem().text())
+            self._projectInfoStore("CPU_INFOS", self.pageContent.cpuList.currentItem().data(Qt.UserRole).toMap())
             return True
         else:
             return False
         
     def rowChanged(self):
-        description = self.pageContent.cpuList.currentItem().data(Qt.UserRole).toStringList()
+        description = self.pageContent.cpuList.currentItem().data(Qt.UserRole).toMap()
+        # I don't like to use QString as key in the dict, but the QVariant.toMap() return a dict<QString,QVariant>
+        description =  description[QString("CPU_DESC")].toStringList()
         # We need to convert the list of QString in a list of unicode
-        description =  [unicode(line) for line in description]
+        description = [unicode(line) for line in description]
         self.pageContent.descriptionLabel.setText("<br>".join(description))
         self.pageContent.descriptionLabel.setVisible(True)
         self.emit(SIGNAL("completeChanged()"))
index 546a7e0b908c937b604e6ee27e6df297de38b348..6c43ec10d403390a052062ab3f96ecd7e3ef905b 100644 (file)
@@ -9,6 +9,8 @@
 # Author: Lorenzo Berni <duplo@develer.com>
 #
 
+import os
+
 from BWizardPage import *
 import BToolchainSearch
 import bertos_utils
@@ -68,13 +70,17 @@ class BToolchainPage(BWizardPage):
     
     def _validItem(self, index, infos):
         item = self.pageContent.toolchainList.item(index)
-        item.setIcon(QIcon(":/images/ok.png"))
+        needed = self._projectInfoRetrieve("CPU_INFOS")
+        if infos["target"].find(unicode(needed[QString("TOOLCHAIN")])) != -1:
+            item.setIcon(QIcon(":/images/ok.png"))
+        else:
+            item.setIcon(QIcon(":/images/warning.png"))
         item.setToolTip("Version: " + infos["version"] + "<br>Target: " + infos["target"] +
             "<br>Thread model: " + infos["thread"])
     
     def _invalidItem(self, index):
         item = self.pageContent.toolchainList.item(index)
-        item.setIcon(QIcon(":/images/warning.png"))
+        item.setIcon(QIcon(":/images/error.png"))
     
     def addToolchain(self):
         sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "")
@@ -106,7 +112,7 @@ class BToolchainPage(BWizardPage):
             self._validationProcess = QProcess()
             self._validationProcess.start(filename, ["-v"])
             self._validationProcess.waitForStarted(10)
-            if self._validationProcess.waitForFinished(10):
+            if self._validationProcess.waitForFinished(20):
                 description = str(self._validationProcess.readAllStandardError())
                 infos = bertos_utils.getToolchainInfo(description)
                 if len(infos.keys()) == 4:
index 8249cc1a2d9158e99c218dc2b47f8547b4985e34..3704b483eff728122b5ad077eaf44e70667ffa2e 100644 (file)
@@ -6,6 +6,7 @@
        <file>images/listadd.png</file>
        <file>images/ok.png</file>
        <file>images/warning.png</file>
+       <file>images/error.png</file>
        <file>images/folderopen.png</file>
   </qresource>
 </RCC>
index ed66a3b80d3e67ee2067dda814aa997624909d05..99a84414cae75b30970ef6a2b40fb128e739b66b 100644 (file)
@@ -71,12 +71,16 @@ def findDefinitions(ftype, path):
 def loadCpuInfos(path):
     cpuInfos = []
     for definition in findDefinitions(const.CPU_DEFINITION, path):
-        D = {}
-        D.update(const.CPU_DEF)
-        def include(filename, dict = D, directory=definition[1]):
-            execfile(directory + "/" + filename, {}, D)
-        D["include"] = include
-        include(definition[0], D)
-        D["CPU_NAME"] = definition[0].split(".")[0]
-        cpuInfos.append(D)
+        cpuInfos.append(getInfos(definition))
     return cpuInfos
+
+def getInfos(definition):
+    D = {}
+    D.update(const.CPU_DEF)
+    def include(filename, dict = D, directory=definition[1]):
+        execfile(directory + "/" + filename, {}, D)
+    D["include"] = include
+    include(definition[0], D)
+    D["CPU_NAME"] = definition[0].split(".")[0]
+    D["DEFINITION_PATH"] = definition[1] + "/" + definition[0]
+    return D
\ No newline at end of file
diff --git a/wizard/images/error.png b/wizard/images/error.png
new file mode 100755 (executable)
index 0000000..6e0ea6e
Binary files /dev/null and b/wizard/images/error.png differ