wizard: use a deterministic order for files in the Makefiles
[bertos.git] / wizard / bertos_utils.py
index f0d5494469e33955d203ba5d937a1c87bbfbe201..feb5c987fb33ad3fc736ce96689bb4c621fa6eea 100644 (file)
@@ -273,17 +273,17 @@ def csrcGenerator(project_info):
         cxxsrc.append(file)
     for file in project_info.info("CPU_INFOS")["ASRC"]:
         asrc.append(file)
-    csrc = set(csrc)
+    csrc = sorted(set(csrc))
     csrc = " \\\n\t".join(csrc) + " \\"
-    pcsrc = set(pcsrc)
+    pcsrc = sorted(set(pcsrc))
     pcsrc = " \\\n\t".join(pcsrc) + " \\"
-    cppasrc = set(cppasrc)
+    cppasrc = sorted(set(cppasrc))
     cppasrc = " \\\n\t".join(cppasrc) + " \\"
-    cxxsrc = set(cxxsrc)
+    cxxsrc = sorted(set(cxxsrc))
     cxxsrc = " \\\n\t".join(cxxsrc) + " \\"
-    asrc = set(asrc)
+    asrc = sorted(set(asrc))
     asrc = " \\\n\t".join(asrc) + " \\"
-    constants = "\n".join([os.path.basename(project_info.info("PROJECT_PATH")) + "_" + key + " = " + unicode(value) for key, value in constants.items()])
+    constants = "\n".join([project_info.info("PROJECT_NAME") + "_" + key + " = " + unicode(value) for key, value in constants.items()])
     return csrc, pcsrc, cppasrc, cxxsrc, asrc, constants
 
 def findModuleFiles(module, project_info):
@@ -340,12 +340,17 @@ def replaceSeparators(path):
 
 def getSystemPath():
     path = os.environ["PATH"]
-    if os.name == "nt":
-        path = path.split(";")
-    else:
-        path = path.split(":")
+    path = path.split(os.pathsep)
     return path
 
+def findInPath(file, path=None):
+    if path is None:
+        path = os.environ.get('PATH', '')
+    if type(path) is type(''):
+        path = path.split(os.pathsep)
+    return filter(os.path.exists, map(lambda dir, file=file: os.path.join(dir, file), path))
+
+
 def findToolchains(path_list):
     toolchains = []
     for element in path_list: