Add the Makefile template in the mktemplates directory
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 2 Feb 2009 17:43:06 +0000 (17:43 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 2 Feb 2009 17:43:06 +0000 (17:43 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2249 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/mktemplates/Makefile [new file with mode: 0644]

index 6fbd254acdb6d52f8d1d528c853bcda9944dda20..05fd35465c5901119c9fea424dfcc409e9e204e2 100644 (file)
@@ -39,7 +39,9 @@ def createBertosProject(projectInfos):
     makefile = directory + "/Makefile"
     if os.path.exists(makefile):
         os.remove(makefile)
-    shutil.copy(sourcesDir + "/Makefile", makefile)
+    makefile = open("mktemplates/Makefile").read()
+    makefile = makefileGenerator(makefile)
+    open(directory + "/Makefile", "w").write(makefile)
     ## Destination project dir
     prjdir = directory + "/" + os.path.basename(directory)
     shutil.rmtree(prjdir, True)
@@ -61,7 +63,7 @@ def createBertosProject(projectInfos):
     ## Destinatio mk file
     makefile = open("mktemplates/template.mk", "r").read()
     makefile = mkGenerator(projectInfos, makefile)
-    open(prjdir + "/" + "template.mk", "w").write(makefile)
+    open(prjdir + "/" + "project.mk", "w").write(makefile)
 
 def mkGenerator(projectInfos, makefile):
     """
@@ -77,6 +79,15 @@ def mkGenerator(projectInfos, makefile):
             makefile = makefile.replace(key, mkData[key])
     return makefile
 
+def makefileGenerator(projectInfos, makefile):
+    """
+    Generate the Makefile for the current project.
+    """
+    # TODO: write a general function that works for both the mk file and the Makefile
+    while makefile.find("project_name") != -1:
+        makefile = makefile.replace("project_name", os.path.basename(projectInfos.info("PROJECT_PATH")))
+    return makefile
+
 def getSystemPath():
     path = os.environ["PATH"]
     if os.name == "nt":
diff --git a/wizard/mktemplates/Makefile b/wizard/mktemplates/Makefile
new file mode 100644 (file)
index 0000000..46f049f
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+# Set to 1 for verbose build output, 0 for terse output
+V := 0
+
+default: all
+
+include bertos/config.mk
+
+include project_name/project_name.mk
+
+include bertos/rules.mk