import bertos_utils
import qvariant_converter
+from const import *
+
class BToolchainPage(BWizardPage):
def __init__(self):
- BWizardPage.__init__(self, "toolchain_select.ui")
+ BWizardPage.__init__(self, UI_LOCATION + "/toolchain_select.ui")
self.setTitle(self.tr("Select toolchain"))
self._validationProcess = None
self._updateUi()
self.pageContent.toolchainList.clear()
def _selectionChanged(self):
- infos = collections.defaultdict(lambda: unicode("not defined"))
- infos.update(qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole)))
- self.pageContent.infoLabel.setText("GCC " + infos["version"] + " (" + infos["build"] + ")\nTarget: " + infos["target"] + "\nPath: " + infos["path"])
- self.pageContent.infoLabel.setVisible(True)
- self.emit(SIGNAL("completeChanged()"))
+ if self.pageContent.toolchainList.currentIndex != -1:
+ infos = collections.defaultdict(lambda: unicode("not defined"))
+ infos.update(qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole)))
+ self.pageContent.infoLabel.setText("GCC " + infos["version"] + " (" + infos["build"] + ")\nTarget: " + infos["target"] + "\nPath: " + os.path.normpath(infos["path"]))
+ self.pageContent.infoLabel.setVisible(True)
+ self.emit(SIGNAL("completeChanged()"))
def _search(self):
dirList = self.searchDirList()
- if(self.pathSearch()):
+ if self.pathSearch():
dirList += [element for element in bertos_utils.getSystemPath()]
toolchainList = bertos_utils.findToolchains(dirList)
storedToolchains = self.toolchains()
newData.update(infos)
item.setData(Qt.UserRole, qvariant_converter.convertStringDict(newData))
needed = self._projectInfoRetrieve("CPU_INFOS")
- if infos["target"].find(needed["TOOLCHAIN"]) != -1:
+ if "target" in infos.keys() and infos["target"].find(needed["TOOLCHAIN"]) != -1:
item.setIcon(QIcon(":/images/ok.png"))
else:
item.setIcon(QIcon(":/images/warning.png"))
sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "")
if not sel_toolchain.isEmpty():
item = QListWidgetItem(sel_toolchain)
- item.setData(Qt.UserRole, qvariant_converter.convertString(sel_toolchain))
+ item.setData(Qt.UserRole, qvariant_converter.convertString({"path": sel_toolchain}))
self.pageContent.toolchainList.addItem(item)
toolchains = self.toolchains()
toolchains[sel_toolchain] = False
def validateToolchain(self, i):
filename = qvariant_converter.getStringDict(self.pageContent.toolchainList.item(i).data(Qt.UserRole))["path"]
- self._validationProcess = QProcess()
- self._validationProcess.start(filename, ["-v"])
- self._validationProcess.waitForStarted(1000)
- if self._validationProcess.waitForFinished(200):
- description = str(self._validationProcess.readAllStandardError())
- infos = bertos_utils.getToolchainInfo(description)
- if len(infos.keys()) >= 4:
- self._validItem(i, infos)
+ valid = False
+ info = {}
+ ## Check for the other tools of the toolchain
+ for tool in TOOLCHAIN_ITEMS:
+ if os.path.exists(filename.replace("gcc", tool)):
+ valid = True
+ else:
+ valid = False
+ break
+ ## Try to retrieve the informations about the toolchain only for the valid toolchains
+ if valid:
+ self._validationProcess = QProcess()
+ self._validationProcess.start(filename, ["-v"])
+ self._validationProcess.waitForStarted(1000)
+ if self._validationProcess.waitForFinished(200):
+ description = str(self._validationProcess.readAllStandardError())
+ info = bertos_utils.getToolchainInfo(description)
+ if len(info.keys()) >= 4:
+ valid = True
else:
- self._invalidItem(i)
+ self._validationProcess.kill()
+ ## Add the item in the list with the appropriate associate data.
+ if valid:
+ self._validItem(i, info)
else:
- self._validationProcess.kill()
self._invalidItem(i)
toolchains = self.toolchains()
toolchains[filename] = True
def isComplete(self):
if self.pageContent.toolchainList.currentRow() != -1:
self._projectInfoStore("TOOLCHAIN",
- qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))["path"])
+ qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole)))
return True
else:
return False