Add a first stub of the makefile generation function
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jan 2009 16:36:22 +0000 (16:36 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jan 2009 16:36:22 +0000 (16:36 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2246 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py

index d3e7127eed4dbab8b40feeace72193e83f297630..27bb57f351f2dee0d5052745056874dea1459aa6 100644 (file)
@@ -58,6 +58,22 @@ def createBertosProject(projectInfos):
         f = open(cfgdir + "/" + os.path.basename(key), "w")
         f.write(string)
         f.close()
+    ## Destinatio mk file
+    makefile = open(sourcesDir + "/" + "template.mk", "r").read()
+    makefile = mkGenerator(projectInfos, makefile)
+    open(prjdir + "/" + "template.km", "w").write(makefile)
+
+def mkGenerator(projectInfos, makefile):
+    mkData = {}
+    mkData["pname"] = os.path.basename(projectInfos.info("PROJECT_PATH"))
+    mkData["cpuname"] = projectInfos.info("CPU_INFOS")["CPU_NAME"]
+    mkData["cflags"] = " ".join(projectInfos.info("CPU_INFOS")["C_FLAGS"])
+    mkData["ldflags"] = " ".join(projectInfos.info("CPU_INFOS")["LD_FLAGS"])
+    for key in mkData:
+        print key, mkData[key]
+        while makefile.find(key) != -1:
+            makefile = makefile.replace(key, mkData[key])
+    return makefile
 
 def getSystemPath():
     path = os.environ["PATH"]