Add other compilation flags
[bertos.git] / wizard / bertos_utils.py
index f4547f1f7245942472523ad108783261eccd144e..2c84468a9f0aee681a764a227ce45c1a412b8eba 100644 (file)
@@ -85,13 +85,18 @@ def mkGenerator(project_info, makefile):
     """
     mk_data = {}
     mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH"))
+    mk_data["$cpuflag"] = project_info.info("CPU_INFOS")["CPU_FLAG_NAME"]
     mk_data["$cpuname"] = project_info.info("CPU_INFOS")["CORE_CPU"]
     mk_data["$cflags"] = " ".join(project_info.info("CPU_INFOS")["C_FLAGS"])
     mk_data["$ldflags"] = " ".join(project_info.info("CPU_INFOS")["LD_FLAGS"])
+    mk_data["$cppflags"] = " ".join(project_info.info("CPU_INFOS")["CPP_FLAGS"])
+    mk_data["$cppaflags"] = " ".join(project_info.info("CPU_INFOS")["CPPA_FLAGS"])
+    mk_data["$cxxflags"] = " ".join(project_info.info("CPU_INFOS")["CXX_FLAGS"])
+    mk_data["$asflags"] = " ".join(project_info.info("CPU_INFOS")["AS_FLAGS"])
+    mk_data["$arflags"] = " ".join(project_info.info("CPU_INFOS")["AR_FLAGS"])
     mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info)
     mk_data["$prefix"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[0]
     mk_data["$suffix"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[1]
-    mk_data["$cross"] = project_info.info("TOOLCHAIN")["path"].split("gcc")[0]
     mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c"
     for key in mk_data:
         while makefile.find(key) != -1:
@@ -140,19 +145,19 @@ def csrcGenerator(project_info):
                     asm_files |= set(dependencySFiles)
             for file in module_files:
                 if not harvard or "harvard" not in information or information["harvard"] == "both":
-                    csrc.append(os.path.normpath(file))
+                    csrc.append(file)
                 if harvard and "harvard" in information:
-                    pcsrc.append(os.path.normpath(file))
+                    pcsrc.append(file)
             for file in dependency_files:
-                csrc.append(os.path.normpath(file))
+                csrc.append(file)
             for file in asm_files:
-                asrc.append(os.path.normpath(file))
+                asrc.append(file)
     csrc = " \\\n\t".join(csrc) + " \\"
     pcsrc = " \\\n\t".join(pcsrc) + " \\"
     asrc = " \\\n\t".join(asrc) + " \\"
     constants = "\n".join([os.path.basename(project_info.info("PROJECT_PATH")) + "_" + key + " = " + str(value) for key, value in constants.items()])
     return csrc, pcsrc, asrc, constants
-    
+
 def findModuleFiles(module, project_info):
     # Find the files related to the selected module
     cfiles = []
@@ -160,26 +165,42 @@ def findModuleFiles(module, project_info):
     # .c files related to the module and the cpu architecture
     for filename, path in findDefinitions(module + ".c", project_info) + \
             findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".c", project_info):
-        path = path.replace(project_info.info("SOURCES_PATH") + "/", "")
+        path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "")
+        if os.sep != "/":
+            path = replaceSeparators(path)
         cfiles.append(path + "/" + filename)
     # .s files related to the module and the cpu architecture
     for filename, path in findDefinitions(module + ".s", project_info) + \
             findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".s", project_info) + \
             findDefinitions(module + ".S", project_info) + \
             findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".S", project_info):
-        path = path.replace(project_info.info("SOURCES_PATH") + "/", "")
+        path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "")
+        if os.sep != "/":
+            path = replaceSeparators(path)
         sfiles.append(path + "/" + filename)
     # .c and .s files related to the module and the cpu tags
     for tag in project_info.info("CPU_INFOS")["CPU_TAGS"]:
         for filename, path in findDefinitions(module + "_" + tag + ".c", project_info):
-            path = path.replace(project_info.info("SOURCES_PATH") + "/", "")
+            path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "")
+            if os.sep != "/":
+                path = replaceSeparators(path)
             cfiles.append(path + "/" + filename)
         for filename, path in findDefinitions(module + "_" + tag + ".s", project_info) + \
                 findDefinitions(module + "_" + tag + ".S", project_info):
-            path = path.replace(project_info.info("SOURCES_PATH") + "/", "")
+            path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "")
+            if os.sep != "/":
+                path = replaceSeparators(path)
             sfiles.append(path + "/" + filename)
     return cfiles, sfiles
 
+def replaceSeparators(path):
+    """
+    Replace the separators in the given path with unix standard separator.
+    """
+    while path.find(os.sep) != -1:
+        path = path.replace(os.sep, "/")
+    return path
+
 def getSystemPath():
     path = os.environ["PATH"]
     if os.name == "nt":
@@ -314,10 +335,10 @@ def loadDefineLists(comment_list):
             define_list[key] = (value,)
     return define_list
 
-def getDescriptionInformations(comment): 
-    """ 
-    Take the doxygen comment and strip the wizard informations, returning the tuple 
-    (comment, wizard_information) 
+def getDescriptionInformations(comment):
+    """
+    Take the doxygen comment and strip the wizard informations, returning the tuple
+    (comment, wizard_information)
     """
     brief = ""
     description = ""
@@ -409,7 +430,7 @@ def loadModuleData(project):
     project.setInfo("LISTS", list_info_dict)
     project.setInfo("CONFIGURATIONS", configuration_info_dict)
     project.setInfo("FILES", file_dict)
-    
+
 def formatParamNameValue(text):
     """
     Take the given string and return a tuple with the name of the parameter in the first position