Add the wait cursor while validating toolchains
[bertos.git] / wizard / bertos_utils.py
index b27c754e3945180cc65e54288242fc651dd24d87..1066f034e4c7f9a66aebdc9c709d410877f85697 100644 (file)
@@ -78,6 +78,8 @@ def mkGenerator(projectInfo, makefile):
     mkData["$cflags"] = " ".join(projectInfo.info("CPU_INFOS")["C_FLAGS"])
     mkData["$ldflags"] = " ".join(projectInfo.info("CPU_INFOS")["LD_FLAGS"])
     mkData["$csrc"] = csrcGenerator(projectInfo)
+    mkData["$prefix"] = os.path.basename(projectInfo.info("TOOLCHAIN")["path"]).split("gcc")[0]
+    mkData["$suffix"] = os.path.basename(projectInfo.info("TOOLCHAIN")["path"]).split("gcc")[1]
     for key in mkData:
         while makefile.find(key) != -1:
             makefile = makefile.replace(key, mkData[key])
@@ -104,7 +106,7 @@ def csrcGenerator(projectInfo):
             for tag in projectInfo.info("CPU_INFOS")["CPU_TAGS"]:
                 for filename, path in findDefinitions(module + "_" + tag + ".c", projectInfo):
                     files.append(path + "/" + filename)
-    csrc = " \\\n\t".join(files)
+    csrc = " \\\n\t".join(files) + " \\"
     return csrc
     
 def getSystemPath():
@@ -119,8 +121,7 @@ def findToolchains(pathList):
     toolchains = []
     for element in pathList:
         for toolchain in glob.glob(element+ "/" + const.GCC_NAME):
-            if not os.path.islink(toolchain):
-                toolchains.append(toolchain)
+            toolchains.append(toolchain)
     return list(set(toolchains))
 
 def getToolchainInfo(output):
@@ -236,19 +237,27 @@ def getDescriptionInformations(comment):
     Take the doxygen comment and strip the wizard informations, returning the tuple 
     (comment, wizard_information) 
     """
+    brief = ""
     description = ""
     information = {}
     for num, line in enumerate(comment):
         index = line.find("$WIZ$")
         if index != -1:
-            description += " " + line[:index]
+            if len(brief) == 0:
+                brief += line[:index].strip()
+            else:
+                description += " " + line[:index]
             try:
                 exec line[index + len("$WIZ$ "):] in {}, information
             except:
                 raise ParseError(num, line[index:])
         else:
-            description += " " + line
-    return description.strip(), information
+            if len(brief) == 0:
+                brief += line.strip()
+            else:
+                description += " " + line
+                description = description.strip()
+    return brief.strip(), description.strip(), information
 
 def getDefinitionBlocks(text):
     """
@@ -277,14 +286,15 @@ def loadModuleData(project):
             try:
                 toBeParsed, moduleDict = loadModuleDefinition(commentList[0])
             except ParseError, err:
-                print "error in file %s. line: %d - statement %s" % (path + "/" + filename, err.line_number, err.line)
-                print err.args
-                print err.message
-                raise Exception
+                raise DefineException.ModuleDefineException(path, err.line_number, err.line)
             for module, information in moduleDict.items():
+                information["category"] = os.path.basename(path)
                 if "configuration" in information.keys() and len(information["configuration"]):
                     configuration = moduleDict[module]["configuration"]
-                    configurationInfo[configuration] = loadConfigurationInfos(project.info("SOURCES_PATH") + "/" + configuration)
+                    try:
+                        configurationInfo[configuration] = loadConfigurationInfos(project.info("SOURCES_PATH") + "/" + configuration)
+                    except ParseError, err:
+                        raise DefineException.ConfigurationDefineException(project.info("SOURCES_PATH") + "/" + configuration, err.line_number, err.line)
             moduleInfoDict.update(moduleDict)
             configurationInfoDict.update(configurationInfo)
             if toBeParsed:
@@ -292,10 +302,7 @@ def loadModuleData(project):
                     listDict = loadDefineLists(commentList[1:])
                     listInfoDict.update(listDict)
                 except ParseError, err:
-                    print "error in file %s. line: %d - statement %s" % (path + "/" + filename, err.line_number, err.line)
-                    print err.args
-                    print err.message
-                    raise Exception
+                    raise DefineException.EnumDefineException(path, err.line_number, err.line)
     for filename, path in findDefinitions("*_" + project.info("CPU_INFOS")["TOOLCHAIN"] + ".h", project):
         commentList = getCommentList(open(path + "/" + filename, "r").read())
         listInfoDict.update(loadDefineLists(commentList))
@@ -328,31 +335,26 @@ def loadConfigurationInfos(path):
             "long": boolean indicating if the num is a long
             "value_list": the name of the enum for enum parameters
     """
-    try:
-        configurationInfos = {}
-        for comment, define in getDefinitionBlocks(open(path, "r").read()):
-            name, value = formatParamNameValue(define)
-            description, informations = getDescriptionInformations(comment)
-            configurationInfos[name] = {}
-            configurationInfos[name]["value"] = value
-            configurationInfos[name]["informations"] = informations
-            if ("type" in configurationInfos[name]["informations"].keys() and
-                    configurationInfos[name]["informations"]["type"] == "int" and
-                    configurationInfos[name]["value"].find("L") != -1):
-                configurationInfos[name]["informations"]["long"] = True
-                configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
-            if ("type" in configurationInfos[name]["informations"].keys() and
-                    configurationInfos[name]["informations"]["type"] == "int" and
-                    configurationInfos[name]["value"].find("U") != -1):
-                configurationInfos[name]["informations"]["unsigned"] = True
-                configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
-            configurationInfos[name]["description"] = description
-        return configurationInfos
-    except ParseError, err:
-        print "error in file %s. line: %d - statement %s" % (path, err.line_number, err.line)
-        print err.args
-        print err.message
-        raise Exception
+    configurationInfos = {}
+    for comment, define in getDefinitionBlocks(open(path, "r").read()):
+        name, value = formatParamNameValue(define)
+        brief, description, informations = getDescriptionInformations(comment)
+        configurationInfos[name] = {}
+        configurationInfos[name]["value"] = value
+        configurationInfos[name]["informations"] = informations
+        if ("type" in configurationInfos[name]["informations"].keys() and
+                configurationInfos[name]["informations"]["type"] == "int" and
+                configurationInfos[name]["value"].find("L") != -1):
+            configurationInfos[name]["informations"]["long"] = True
+            configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
+        if ("type" in configurationInfos[name]["informations"].keys() and
+                configurationInfos[name]["informations"]["type"] == "int" and
+                configurationInfos[name]["value"].find("U") != -1):
+            configurationInfos[name]["informations"]["unsigned"] = True
+            configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
+        configurationInfos[name]["description"] = description
+        configurationInfos[name]["brief"] = brief
+    return configurationInfos
 
 def sub(string, parameter, value):
     """